diff --git a/.styleci.yml b/.styleci.yml index 974f5fa5..66efb576 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1 +1,5 @@ preset: symfony + +enabled: + - ordered_use + - short_array_syntax diff --git a/README.md b/README.md index dbafdd20..7573dc35 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ and licensed under the [MIT License](LICENSE). ## Requirements -* The Symfony Routing component (>= 2.2.0) +* PHP 5.6 / 7 +* The Symfony Routing component (2.2.0 - 3.\*) * See also the `require` section of [composer.json](composer.json) diff --git a/src/ChainRouter.php b/src/ChainRouter.php index 48e153bd..bd36ba6f 100644 --- a/src/ChainRouter.php +++ b/src/ChainRouter.php @@ -11,18 +11,18 @@ namespace Symfony\Cmf\Component\Routing; -use Symfony\Component\Routing\RouterInterface; +use Psr\Log\LoggerInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; +use Symfony\Component\Routing\Exception\MethodNotAllowedException; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; -use Psr\Log\LoggerInterface; +use Symfony\Component\Routing\RouterInterface; /** * The ChainRouter allows to combine several routers to try in a defined order. diff --git a/src/ChainRouterInterface.php b/src/ChainRouterInterface.php index 469b4de3..a0b07988 100644 --- a/src/ChainRouterInterface.php +++ b/src/ChainRouterInterface.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing; -use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; +use Symfony\Component\Routing\RouterInterface; /** * Interface for a router that proxies routing to other routers. diff --git a/src/ContentAwareGenerator.php b/src/ContentAwareGenerator.php index eece4748..4e094dc5 100644 --- a/src/ContentAwareGenerator.php +++ b/src/ContentAwareGenerator.php @@ -12,9 +12,9 @@ namespace Symfony\Cmf\Component\Routing; use Doctrine\Common\Collections\Collection; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Route as SymfonyRoute; -use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\RouteCollection; /** diff --git a/src/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php b/src/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php index ccb2379c..6999550f 100644 --- a/src/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php +++ b/src/DependencyInjection/Compiler/RegisterRouteEnhancersPass.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Component\Routing\DependencyInjection\Compiler; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * This compiler pass adds additional route enhancers diff --git a/src/DependencyInjection/Compiler/RegisterRoutersPass.php b/src/DependencyInjection/Compiler/RegisterRoutersPass.php index c941adfc..627b0ba4 100644 --- a/src/DependencyInjection/Compiler/RegisterRoutersPass.php +++ b/src/DependencyInjection/Compiler/RegisterRoutersPass.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Component\Routing\DependencyInjection\Compiler; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** * Compiler pass to register routers to the ChainRouter. diff --git a/src/DynamicRouter.php b/src/DynamicRouter.php index 0d3bc11a..dad2e5f7 100644 --- a/src/DynamicRouter.php +++ b/src/DynamicRouter.php @@ -11,23 +11,23 @@ namespace Symfony\Cmf\Component\Routing; +use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface; +use Symfony\Cmf\Component\Routing\Event\Events; +use Symfony\Cmf\Component\Routing\Event\RouterGenerateEvent; +use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\Exception\MethodNotAllowedException; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; +use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; -use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Cmf\Component\Routing\Event\Events; -use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; -use Symfony\Cmf\Component\Routing\Event\RouterGenerateEvent; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; +use Symfony\Component\Routing\RouterInterface; /** * A flexible router accepting matcher and generator through injection and diff --git a/src/Enhancer/RouteContentEnhancer.php b/src/Enhancer/RouteContentEnhancer.php index 8bc173f2..0348f1d8 100644 --- a/src/Enhancer/RouteContentEnhancer.php +++ b/src/Enhancer/RouteContentEnhancer.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Enhancer; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; /** * This enhancer sets the content to target field if the route provides content. diff --git a/src/LazyRouteCollection.php b/src/LazyRouteCollection.php index 59e5d8c0..bc1b1662 100644 --- a/src/LazyRouteCollection.php +++ b/src/LazyRouteCollection.php @@ -12,8 +12,8 @@ namespace Symfony\Cmf\Component\Routing; use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; class LazyRouteCollection extends RouteCollection { diff --git a/src/NestedMatcher/NestedMatcher.php b/src/NestedMatcher/NestedMatcher.php index 1e427694..9ddbca9c 100644 --- a/src/NestedMatcher/NestedMatcher.php +++ b/src/NestedMatcher/NestedMatcher.php @@ -11,10 +11,10 @@ namespace Symfony\Cmf\Component\Routing\NestedMatcher; +use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Cmf\Component\Routing\RouteProviderInterface; /** * A more flexible approach to matching. The route collection to match against diff --git a/src/NestedMatcher/RouteFilterInterface.php b/src/NestedMatcher/RouteFilterInterface.php index bbed0d23..fbcc5324 100644 --- a/src/NestedMatcher/RouteFilterInterface.php +++ b/src/NestedMatcher/RouteFilterInterface.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Component\Routing\NestedMatcher; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; +use Symfony\Component\Routing\RouteCollection; /** * A RouteFilter takes a RouteCollection and returns a filtered subset. diff --git a/src/NestedMatcher/UrlMatcher.php b/src/NestedMatcher/UrlMatcher.php index c383d749..21c6a52f 100644 --- a/src/NestedMatcher/UrlMatcher.php +++ b/src/NestedMatcher/UrlMatcher.php @@ -11,12 +11,12 @@ namespace Symfony\Cmf\Component\Routing\NestedMatcher; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Matcher\UrlMatcher as SymfonyUrlMatcher; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Matcher\UrlMatcher as SymfonyUrlMatcher; use Symfony\Component\Routing\RequestContext; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; /** * Extended UrlMatcher to provide an additional interface and enhanced features. diff --git a/src/ProviderBasedGenerator.php b/src/ProviderBasedGenerator.php index 6b516f48..12fd0895 100644 --- a/src/ProviderBasedGenerator.php +++ b/src/ProviderBasedGenerator.php @@ -11,11 +11,11 @@ namespace Symfony\Cmf\Component\Routing; +use Psr\Log\LoggerInterface; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGenerator; -use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Exception\RouteNotFoundException; -use Psr\Log\LoggerInterface; +use Symfony\Component\Routing\Route as SymfonyRoute; /** * A Generator that uses a RouteProvider rather than a RouteCollection. diff --git a/tests/Unit/Enhancer/FieldByClassEnhancerTest.php b/tests/Unit/Enhancer/FieldByClassEnhancerTest.php index 9e24ca12..c98d8fa1 100644 --- a/tests/Unit/Enhancer/FieldByClassEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldByClassEnhancerTest.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\FieldByClassEnhancer; +use Symfony\Component\HttpFoundation\Request; class FieldByClassEnhancerTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Enhancer/FieldMapEnhancerTest.php b/tests/Unit/Enhancer/FieldMapEnhancerTest.php index 682a4b87..73a9c7ec 100644 --- a/tests/Unit/Enhancer/FieldMapEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldMapEnhancerTest.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Mapper; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\FieldMapEnhancer; +use Symfony\Component\HttpFoundation\Request; class FieldMapEnhancerTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php b/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php index d880dfaf..edaa7f92 100644 --- a/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\FieldPresenceEnhancer; +use Symfony\Component\HttpFoundation\Request; class FieldPresenceEnhancerTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Enhancer/RouteContentEnhancerTest.php b/tests/Unit/Enhancer/RouteContentEnhancerTest.php index 2a30f6cc..4668f3e3 100644 --- a/tests/Unit/Enhancer/RouteContentEnhancerTest.php +++ b/tests/Unit/Enhancer/RouteContentEnhancerTest.php @@ -11,9 +11,9 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; -use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\RouteContentEnhancer; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; class RouteContentEnhancerTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Unit/Enhancer/RouteObject.php b/tests/Unit/Enhancer/RouteObject.php index 7ccc83a4..45c4faee 100644 --- a/tests/Unit/Enhancer/RouteObject.php +++ b/tests/Unit/Enhancer/RouteObject.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; -use Symfony\Component\Routing\Route; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\Route; /** * Empty abstract class to be able to mock an object that both extends Route diff --git a/tests/Unit/NestedMatcher/NestedMatcherTest.php b/tests/Unit/NestedMatcher/NestedMatcherTest.php index 44d3ec3e..984e5357 100644 --- a/tests/Unit/NestedMatcher/NestedMatcherTest.php +++ b/tests/Unit/NestedMatcher/NestedMatcherTest.php @@ -12,13 +12,13 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\NestedMatcher; use Symfony\Cmf\Component\Routing\NestedMatcher\FinalMatcherInterface; +use Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher; use Symfony\Cmf\Component\Routing\NestedMatcher\RouteFilterInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; class NestedMatcherTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/NestedMatcher/UrlMatcherTest.php b/tests/Unit/NestedMatcher/UrlMatcherTest.php index db1b6e72..391b0e99 100644 --- a/tests/Unit/NestedMatcher/UrlMatcherTest.php +++ b/tests/Unit/NestedMatcher/UrlMatcherTest.php @@ -11,14 +11,14 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\NestedMatcher; +use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Cmf\Component\Routing\Tests\Unit\Routing\RouteMock; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\CompiledRoute; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -use Symfony\Cmf\Component\Routing\NestedMatcher\UrlMatcher; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; class UrlMatcherTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Routing/ChainRouterTest.php b/tests/Unit/Routing/ChainRouterTest.php index 4e99a6cb..7d115ae9 100644 --- a/tests/Unit/Routing/ChainRouterTest.php +++ b/tests/Unit/Routing/ChainRouterTest.php @@ -12,7 +12,9 @@ namespace Symfony\Cmf\Component\Routing\Tests\Routing; use Psr\Log\LoggerInterface; +use Symfony\Cmf\Component\Routing\ChainRouter; use Symfony\Cmf\Component\Routing\VersatileGeneratorInterface; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; use Symfony\Component\Routing\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Exception\ResourceNotFoundException; @@ -20,11 +22,9 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\RequestContext; +use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Cmf\Component\Routing\ChainRouter; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Routing\Route; class ChainRouterTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Routing/ContentAwareGeneratorTest.php b/tests/Unit/Routing/ContentAwareGeneratorTest.php index 648457dd..fc7e730d 100644 --- a/tests/Unit/Routing/ContentAwareGeneratorTest.php +++ b/tests/Unit/Routing/ContentAwareGeneratorTest.php @@ -11,13 +11,13 @@ namespace Symfony\Cmf\Component\Routing\Tests\Routing; +use Symfony\Cmf\Component\Routing\ContentAwareGenerator; +use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; -use Symfony\Cmf\Component\Routing\ContentAwareGenerator; use Symfony\Cmf\Component\Routing\Tests\Unit\Routing\RouteMock; use Symfony\Component\Routing\CompiledRoute; use Symfony\Component\Routing\RequestContext; -use Symfony\Cmf\Component\Routing\ContentRepositoryInterface; use Symfony\Component\Routing\Route; class ContentAwareGeneratorTest extends \PHPUnit_Framework_TestCase diff --git a/tests/Unit/Routing/DynamicRouterTest.php b/tests/Unit/Routing/DynamicRouterTest.php index 67f4428e..5d5ad5b9 100644 --- a/tests/Unit/Routing/DynamicRouterTest.php +++ b/tests/Unit/Routing/DynamicRouterTest.php @@ -11,8 +11,10 @@ namespace Symfony\Cmf\Component\Routing\Tests\Routing; +use Symfony\Cmf\Component\Routing\DynamicRouter; use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface; use Symfony\Cmf\Component\Routing\Event\Events; +use Symfony\Cmf\Component\Routing\Event\RouterGenerateEvent; use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent; use Symfony\Cmf\Component\Routing\LazyRouteCollection; use Symfony\Cmf\Component\Routing\RouteProviderInterface; @@ -21,12 +23,10 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Cmf\Component\Routing\DynamicRouter; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouteCollection; -use Symfony\Cmf\Component\Routing\Event\RouterGenerateEvent; class DynamicRouterTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Routing/ProviderBasedGeneratorTest.php b/tests/Unit/Routing/ProviderBasedGeneratorTest.php index a7ec9725..7bb086e4 100644 --- a/tests/Unit/Routing/ProviderBasedGeneratorTest.php +++ b/tests/Unit/Routing/ProviderBasedGeneratorTest.php @@ -11,12 +11,12 @@ namespace Symfony\Cmf\Component\Routing\Tests\Routing; -use Symfony\Cmf\Component\Routing\RouteObjectInterface; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Route; use Symfony\Cmf\Component\Routing\ProviderBasedGenerator; +use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Cmf\Component\Routing\RouteProviderInterface; use Symfony\Component\Routing\CompiledRoute; +use Symfony\Component\Routing\RequestContext; +use Symfony\Component\Routing\Route; class ProviderBasedGeneratorTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Routing/RouteMock.php b/tests/Unit/Routing/RouteMock.php index 3ba8e4ea..ca5866c9 100644 --- a/tests/Unit/Routing/RouteMock.php +++ b/tests/Unit/Routing/RouteMock.php @@ -11,8 +11,8 @@ namespace Symfony\Cmf\Component\Routing\Tests\Unit\Routing; -use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Cmf\Component\Routing\RouteObjectInterface; +use Symfony\Component\Routing\Route as SymfonyRoute; class RouteMock extends SymfonyRoute implements RouteObjectInterface {