Skip to content

Commit d8d6e61

Browse files
Resolved deprecation issues (#25)
1 parent e232223 commit d8d6e61

23 files changed

Lines changed: 453 additions & 353 deletions

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Composer
2-
vendor/*
3-
composer.phar
1+
/var/
2+
/vendor/
43
composer.lock

.travis.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
11
language: php
2+
sudo: false
3+
cache:
4+
directories:
5+
- $HOME/.composer/cache/files
6+
7+
env:
8+
global:
9+
- PHPUNIT_FLAGS="-v"
210

311
matrix:
12+
fast_finish: true
413
include:
5-
- php: 5.6
6-
- php: 7.0
7-
- php: 7.0
8-
env: deps=lowest
9-
- php: 7.1
10-
- php: hhvm
14+
# Minimum supported dependencies with the latest and oldest PHP version
15+
- php: 7.2
16+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
17+
- php: 7.3
18+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
19+
20+
# Test the latest stable release
21+
- php: 7.2
22+
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
23+
- php: 7.3
24+
25+
# Latest commit to master
26+
- php: 7.2
27+
env: STABILITY="dev"
28+
- php: 7.3
29+
env: STABILITY="dev"
30+
1131
allow_failures:
12-
- php: hhvm
32+
# dev-master is allowed to fail.
33+
- env: STABILITY="dev"
34+
35+
before_install:
36+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
37+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
38+
- if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
1339

1440
install:
15-
- if [ -z "$deps" ]; then composer install; fi;
16-
- if [ "$deps" = "lowest" ]; then composer update --prefer-lowest -n; fi;
17-
18-
script: vendor/bin/phpunit
41+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
42+
43+
script:
44+
- composer validate --strict --no-check-lock
45+
- ./vendor/bin/phpunit $PHPUNIT_FLAGS

UPGRADE-2.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
UPGRADE FROM 1.0 to 2.0
2+
===============================
3+
4+
# General changes
5+
- PHP 7.2 is now the minimum requirement
6+
- Type hints have been added to all functions
7+
- This bundle is now Symfony 4 only

composer.json

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,42 @@
22
"name": "hostnet/entity-tracker-bundle",
33
"description": "Wraps around the hostnet/entity-tracker-component and allows configuration of several listener components",
44
"license": "MIT",
5+
"minimum-stability": "stable",
56
"require": {
6-
"php": "5.*,>=5.6||7.*",
7-
"hostnet/entity-tracker-component": "^2.0.0",
8-
"psr/log": "^1.0.0",
9-
"symfony/config": "^2.6|^3.0|^4.0",
10-
"symfony/dependency-injection": "^2.6|^3.0|^4.0",
11-
"symfony/http-kernel": "^2.6|^3.0|^4.0"
7+
"php": ">=7.2",
8+
"hostnet/entity-tracker-component": "^1.2.3",
9+
"psr/log": "^1.1.0",
10+
"symfony/config": "^4.0.0",
11+
"symfony/dependency-injection": "^4.0.0",
12+
"symfony/http-kernel": "^4.0.0",
13+
"symfony/yaml": "^4.0.0"
1214
},
1315
"require-dev": {
14-
"hostnet/entity-blamable-component": "^1.0.0",
15-
"phpunit/phpunit": "^5.5.0",
16-
"symfony/security": "^2.6|^3.0|^4.0",
17-
"symfony/security-bundle": "^2.6|^3.0|^4.0"
16+
"hostnet/entity-blamable-component": "^1.0.3",
17+
"hostnet/phpcs-tool": "^8.3.3",
18+
"phpunit/phpunit": "^8.1.3",
19+
"symfony/framework-bundle": "^4.2.8",
20+
"symfony/security": "^4.2.8",
21+
"symfony/security-bundle": "^4.2.8"
1822
},
1923
"suggest": {
20-
"hostnet/entity-revision-component": "Provides the @Revision annotation and listeners",
24+
"hostnet/entity-blamable-component": "Provides the @Blamable annotation and listeners",
2125
"hostnet/entity-mutation-component": "Provides the @Mutation annotation and listeners",
22-
"hostnet/entity-blamable-component": "Provides the @Blamable annotation and listeners"
26+
"hostnet/entity-revision-component": "Provides the @Revision annotation and listeners"
2327
},
24-
"minimum-stability": "stable",
2528
"autoload": {
2629
"psr-4": {
2730
"Hostnet\\Bundle\\EntityTrackerBundle\\": "src/"
2831
}
2932
},
3033
"autoload-dev": {
3134
"psr-4": {
32-
"Hostnet\\Bundle\\EntityTrackerBundle\\": "test/"
35+
"Hostnet\\Bundle\\EntityTrackerBundle\\": "tests/"
3336
}
3437
},
3538
"archive": {
3639
"exclude": [
37-
"/test"
40+
"/tests"
3841
]
39-
},
40-
"authors": [
41-
{
42-
"name": "Iltar van der Berg",
43-
"email": "ivanderberg@hostnet.nl"
44-
},
45-
{
46-
"name": "Yannick de Lange",
47-
"email": "ydelange@hostnet.nl"
48-
}
49-
]
42+
}
5043
}

phpunit.xml.dist

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.0/phpunit.xsd"
5-
colors="true" bootstrap="vendor/autoload.php">
2+
<phpunit forceCoversAnnotation="true"
3+
colors="true"
4+
bootstrap="vendor/autoload.php"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd">
67
<testsuites>
7-
<testsuite name="hostnet/entity-tracker-bundle test suite">
8-
<directory>./test</directory>
8+
<testsuite name="Entity Tracker Bundle - Unit Tests">
9+
<directory>./tests</directory>
910
</testsuite>
1011
</testsuites>
1112
<filter>
1213
<whitelist>
13-
<directory>src</directory>
14+
<directory>./src</directory>
1415
</whitelist>
1516
</filter>
1617
</phpunit>

src/DependencyInjection/Configuration.php

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
<?php
2+
/**
3+
* @copyright 2014-present Hostnet B.V.
4+
*/
5+
declare(strict_types=1);
6+
27
namespace Hostnet\Bundle\EntityTrackerBundle\DependencyInjection;
38

9+
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
410
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
511
use Symfony\Component\Config\Definition\ConfigurationInterface;
12+
use Symfony\Component\HttpKernel\Kernel;
613

7-
/**
8-
* @author Iltar van der Berg <ivanderberg@hostnet.nl>
9-
* @author Yannick de Lange <ydelange@hostnet.nl>
10-
*/
1114
class Configuration implements ConfigurationInterface
1215
{
13-
const REVISION_FACTORY_INTERFACE = 'Hostnet\Component\EntityRevision\Factory\RevisionFactoryInterface';
14-
const BLAMABLE_PROVIDER_INTERFACE = 'Hostnet\Component\EntityBlamable\Provider\BlamableProviderInterface';
15-
const BLAMABLE_DEFAULT_PROVIDER = "entity_tracker.provider.blamable";
16-
17-
/**
18-
* @see \Symfony\Component\Config\Definition\ConfigurationInterface::getConfigTreeBuilder()
19-
*/
20-
public function getConfigTreeBuilder()
16+
public const REVISION_FACTORY_INTERFACE = 'Hostnet\Component\EntityRevision\Factory\RevisionFactoryInterface';
17+
public const BLAMABLE_PROVIDER_INTERFACE = 'Hostnet\Component\EntityBlamable\Provider\BlamableProviderInterface';
18+
public const BLAMABLE_DEFAULT_PROVIDER = 'entity_tracker.provider.blamable';
19+
20+
private const CONFIG_ROOT = 'hostnet_entity_tracker';
21+
22+
public function getConfigTreeBuilder(): TreeBuilder
2123
{
22-
$tree_builder = new TreeBuilder();
23-
$root_node = $tree_builder->root('hostnet_entity_tracker');
24+
$tree_builder = $this->createTreeBuilder();
25+
$root_node = $this->retrieveRootNode($tree_builder);
2426

2527
$component_info = 'Configures and enables the %s listener';
2628

@@ -56,4 +58,30 @@ public function getConfigTreeBuilder()
5658

5759
return $tree_builder;
5860
}
61+
62+
private function createTreeBuilder(): TreeBuilder
63+
{
64+
if (Kernel::VERSION_ID >= 40200) {
65+
return new TreeBuilder(self::CONFIG_ROOT);
66+
}
67+
68+
if (Kernel::VERSION_ID < 40200) {
69+
return new TreeBuilder();
70+
}
71+
72+
throw new \RuntimeException('This bundle can only be used by Symfony 4.0 and up.');
73+
}
74+
75+
private function retrieveRootNode(TreeBuilder $tree_builder): NodeDefinition
76+
{
77+
if (Kernel::VERSION_ID >= 40200) {
78+
return $tree_builder->getRootNode();
79+
}
80+
81+
if (Kernel::VERSION_ID < 40200) {
82+
return $tree_builder->root(self::CONFIG_ROOT);
83+
}
84+
85+
throw new \RuntimeException('This bundle can only be used by Symfony 4.0 and up.');
86+
}
5987
}

src/DependencyInjection/HostnetEntityTrackerExtension.php

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?php
2+
/**
3+
* @copyright 2014-present Hostnet B.V.
4+
*/
5+
declare(strict_types=1);
6+
27
namespace Hostnet\Bundle\EntityTrackerBundle\DependencyInjection;
38

49
use Symfony\Component\Config\FileLocator;
@@ -7,42 +12,33 @@
712
use Symfony\Component\DependencyInjection\Reference;
813
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
914

10-
/**
11-
* This is the class that loads and manages your bundle configuration
12-
*
13-
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14-
*
15-
* @author Iltar van der Berg <ivanderberg@hostnet.nl>
16-
*/
1715
class HostnetEntityTrackerExtension extends Extension
1816
{
19-
const BLAMABLE = 'Hostnet\Component\EntityBlamable\Blamable';
20-
const MUTATION = 'Hostnet\Component\EntityMutation\Mutation';
21-
const REVISION = 'Hostnet\Component\EntityRevision\Revision';
17+
private const BLAMABLE = 'Hostnet\Component\EntityBlamable\Blamable';
18+
private const MUTATION = 'Hostnet\Component\EntityMutation\Mutation';
19+
private const REVISION = 'Hostnet\Component\EntityRevision\Revision';
2220

23-
/**
24-
* @see \Symfony\Component\DependencyInjection\Extension\ExtensionInterface::load()
25-
*/
26-
public function load(array $configs, ContainerBuilder $container)
21+
public function load(array $configs, ContainerBuilder $container): void
2722
{
2823
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
2924
$configuration = new Configuration();
3025
$config = $this->processConfiguration($configuration, $configs);
3126

32-
$loader->load('services.yml');
27+
$loader->load('services.yaml');
3328

34-
if (array_key_exists('blamable', $config)) {
29+
if (\array_key_exists('blamable', $config)) {
3530
$this->validateComponent(self::BLAMABLE, 'blamable');
36-
$loader->load('blamable.yml');
37-
if (
38-
$container->hasParameter('kernel.bundles')
39-
&& array_key_exists('SecurityBundle', $container->getParameter('kernel.bundles'))
31+
$loader->load('blamable.yaml');
32+
if ($container->hasParameter('kernel.bundles')
33+
&& \array_key_exists('SecurityBundle', $container->getParameter('kernel.bundles'))
4034
) {
41-
$loader->load('security.yml');
35+
$loader->load('security.yaml');
4236
}
37+
4338
$container
4439
->getDefinition('entity_tracker.listener.blamable')
4540
->replaceArgument(1, new Reference($config['blamable']['provider']));
41+
4642
if (isset($config['blamable']['default_username'])) {
4743
$container
4844
->getDefinition(Configuration::BLAMABLE_DEFAULT_PROVIDER)
@@ -52,19 +48,19 @@ public function load(array $configs, ContainerBuilder $container)
5248
$this->validateClass(self::BLAMABLE, 'blamable');
5349
}
5450

55-
if (array_key_exists('revision', $config)) {
51+
if (\array_key_exists('revision', $config)) {
5652
$this->validateComponent(self::REVISION, 'revision');
57-
$loader->load('revision.yml');
53+
$loader->load('revision.yaml');
5854
$container
5955
->getDefinition('entity_tracker.listener.revision')
6056
->replaceArgument(1, new Reference($config['revision']['factory']));
6157
} else {
6258
$this->validateClass(self::REVISION, 'revision');
6359
}
6460

65-
if (array_key_exists('mutation', $config)) {
61+
if (\array_key_exists('mutation', $config)) {
6662
$this->validateComponent(self::MUTATION, 'mutation');
67-
$loader->load('mutation.yml');
63+
$loader->load('mutation.yaml');
6864
} else {
6965
$this->validateClass(self::MUTATION, 'mutation');
7066
}
@@ -73,9 +69,10 @@ public function load(array $configs, ContainerBuilder $container)
7369
/**
7470
* @param string $annotation_class
7571
* @param string $config_name
72+
*
7673
* @throws \RuntimeException
7774
*/
78-
protected function validateComponent($annotation_class, $config_name)
75+
protected function validateComponent(string $annotation_class, string $config_name): void
7976
{
8077
if (class_exists($annotation_class)) {
8178
return;
@@ -91,9 +88,10 @@ protected function validateComponent($annotation_class, $config_name)
9188
/**
9289
* @param string $annotation_class
9390
* @param string $config_name
91+
*
9492
* @throws \RuntimeException
9593
*/
96-
protected function validateClass($annotation_class, $config_name)
94+
protected function validateClass(string $annotation_class, string $config_name): void
9795
{
9896
if (!class_exists($annotation_class)) {
9997
return;

src/HostnetEntityTrackerBundle.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
2+
/**
3+
* @copyright 2014-present Hostnet B.V.
4+
*/
5+
declare(strict_types=1);
6+
27
namespace Hostnet\Bundle\EntityTrackerBundle;
38

49
use Symfony\Component\HttpKernel\Bundle\Bundle;
510

6-
/**
7-
* @author Yannick de Lange <ydelange@hostnet.nl>
8-
*/
911
class HostnetEntityTrackerBundle extends Bundle
1012
{
11-
1213
}

0 commit comments

Comments
 (0)