diff --git a/.php_cs.dist b/.php_cs.dist index c0011033990d..a531438b1e97 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -11,7 +11,10 @@ return PhpCsFixer\Config::create() '@PHPUnit48Migration:risky' => true, 'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice 'array_syntax' => array('syntax' => 'long'), + 'ordered_imports' => true, 'protected_to_private' => false, + // Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading + 'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'), )) ->setRiskyAllowed(true) ->setFinder( @@ -24,12 +27,17 @@ return PhpCsFixer\Config::create() 'Symfony/Component/Routing/Tests/Fixtures/dumper', // fixture templates 'Symfony/Component/Templating/Tests/Fixtures/templates', + 'Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache', 'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom', // generated fixtures 'Symfony/Component/VarDumper/Tests/Fixtures', // resource templates 'Symfony/Bundle/FrameworkBundle/Resources/views/Form', + // explicit trigger_error tests + 'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/', )) + // Support for older PHPunit version + ->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php') // file content autogenerated by `var_export` ->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php') // test template @@ -37,8 +45,6 @@ return PhpCsFixer\Config::create() // explicit heredoc test ->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php') // explicit trigger_error tests - ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt') - ->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt') ->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php') ) ; diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index 2afe811abce7..cba2e57482bb 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -7,6 +7,16 @@ in 4.0 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.0.0...v4.0.1 +* 4.0.14 (2018-08-01) + + * security #cve-2018-14774 [HttpKernel] fix trusted headers management in HttpCache and InlineFragmentRenderer (nicolas-grekas) + * security #cve-2018-14773 [HttpFoundation] Remove support for legacy and risky HTTP headers (nicolas-grekas) + * bug #28003 [HttpKernel] Fixes invalid REMOTE_ADDR in inline subrequest when configuring trusted proxy with subnet (netiul) + * bug #28007 [FrameworkBundle] fixed guard event names for transitions (destillat) + * bug #28045 [HttpFoundation] Fix Cookie::isCleared (ro0NL) + * bug #28080 [HttpFoundation] fixed using _method parameter with invalid type (Phobetor) + * bug #28052 [HttpKernel] Fix merging bindings for controllers' locators (nicolas-grekas) + * 4.0.13 (2018-07-23) * bug #28005 [HttpKernel] Fixed templateExists on parse error of the template name (yceruto) diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index 9ba6912e0fae..20aaae85a1e4 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -54,7 +54,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null) $initialized = isset($this->initialized[$eventName]); foreach ($this->listeners[$eventName] as $hash => $listener) { - if (!$initialized && is_string($listener)) { + if (!$initialized && \is_string($listener)) { $this->listeners[$eventName][$hash] = $listener = $this->container->get($listener); } @@ -98,7 +98,7 @@ public function hasListeners($event) */ public function addEventListener($events, $listener) { - if (is_string($listener)) { + if (\is_string($listener)) { if ($this->initialized) { throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.'); } @@ -124,7 +124,7 @@ public function addEventListener($events, $listener) */ public function removeEventListener($events, $listener) { - if (is_string($listener)) { + if (\is_string($listener)) { $hash = '_service_'.$listener; } else { // Picks the hash code related to that listener diff --git a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php index e605c057e353..51577de0f5b2 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -14,9 +14,9 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Types\Type; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\DataCollector; /** * DoctrineDataCollector. @@ -134,14 +134,14 @@ private function sanitizeQuery($connectionName, $query) if (null === $query['params']) { $query['params'] = array(); } - if (!is_array($query['params'])) { + if (!\is_array($query['params'])) { $query['params'] = array($query['params']); } foreach ($query['params'] as $j => $param) { if (isset($query['types'][$j])) { // Transform the param according to the type $type = $query['types'][$j]; - if (is_string($type)) { + if (\is_string($type)) { $type = Type::getType($type); } if ($type instanceof Type) { @@ -168,15 +168,15 @@ private function sanitizeQuery($connectionName, $query) */ private function sanitizeParam($var): array { - if (is_object($var)) { - $className = get_class($var); + if (\is_object($var)) { + $className = \get_class($var); return method_exists($var, '__toString') ? array(sprintf('Object(%s): "%s"', $className, $var->__toString()), false) : array(sprintf('Object(%s)', $className), false); } - if (is_array($var)) { + if (\is_array($var)) { $a = array(); $original = true; foreach ($var as $k => $v) { @@ -188,7 +188,7 @@ private function sanitizeParam($var): array return array($a, $original); } - if (is_resource($var)) { + if (\is_resource($var)) { return array(sprintf('Resource(%s)', get_resource_type($var)), false); } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 2850ab47cd3e..b8064e435f04 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\DependencyInjection; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * This abstract classes groups common code that Doctrine Object Manager extensions (ORM, MongoDB, CouchDB) need. @@ -141,7 +141,7 @@ protected function setMappingDriverConfig(array $mappingConfig, $mappingName) */ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container) { - $bundleDir = dirname($bundle->getFileName()); + $bundleDir = \dirname($bundle->getFileName()); if (!$bundleConfig['type']) { $bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container); @@ -153,7 +153,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re } if (!$bundleConfig['dir']) { - if (in_array($bundleConfig['type'], array('annotation', 'staticphp'))) { + if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) { $bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName(); } else { $bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory(); @@ -240,7 +240,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir'])); } - if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) { + if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) { throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '. '"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '. 'You can register them by adding a new driver to the '. @@ -272,7 +272,7 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container) // add the closest existing directory as a resource $resource = $dir.'/'.$configPath; while (!is_dir($resource)) { - $resource = dirname($resource); + $resource = \dirname($resource); } $container->fileExists($resource, false); diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php index 5f74ecfbcc5a..b0db71c92936 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Registers additional validators. @@ -52,7 +52,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, string foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); - if ($container->fileExists($file = dirname($reflection->getFileName()).'/'.$validationPath)) { + if ($container->fileExists($file = \dirname($reflection->getFileName()).'/'.$validationPath)) { $files[] = $file; } } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php index d856b2c8db79..92a7b673e27d 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php @@ -141,7 +141,7 @@ private function findAndSortTags($tagName, ContainerBuilder $container) if ($sortedTags) { krsort($sortedTags); - $sortedTags = call_user_func_array('array_merge', $sortedTags); + $sortedTags = \call_user_func_array('array_merge', $sortedTags); } return $sortedTags; diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php index 4f140f81edd0..44ad1562196b 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; +use Symfony\Component\DependencyInjection\Reference; /** * Base class for the doctrine bundles to provide a compiler pass class that @@ -124,7 +124,7 @@ public function __construct($driver, array $namespaces, array $managerParameters $this->managerParameters = $managerParameters; $this->driverPattern = $driverPattern; $this->enabledParameter = $enabledParameter; - if (count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) { + if (\count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) { throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias'); } $this->configurationPattern = $configurationPattern; @@ -149,7 +149,7 @@ public function process(ContainerBuilder $container) $chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace)); } - if (!count($this->aliasMap)) { + if (!\count($this->aliasMap)) { return; } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php index 1f946266a095..352bf79bfbc7 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Doctrine\DependencyInjection\Security\UserProvider; -use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface; +use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index a5a08b13ea42..7df0c37a4ecd 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -83,7 +83,7 @@ public function loadValuesForChoices(array $choices, $value = null) // Optimize performance for single-field identifiers. We already // know that the IDs are used as values - $optimize = null === $value || is_array($value) && $value[0] === $this->idReader; + $optimize = null === $value || \is_array($value) && $value[0] === $this->idReader; // Attention: This optimization does not check choices for existence if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) { @@ -120,7 +120,7 @@ public function loadChoicesForValues(array $values, $value = null) // Optimize performance in case we have an object loader and // a single-field identifier - $optimize = null === $value || is_array($value) && $this->idReader === $value[0]; + $optimize = null === $value || \is_array($value) && $this->idReader === $value[0]; if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) { $unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values); diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php index 3f3a5c8ac40f..381d02fcbe04 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php @@ -42,8 +42,8 @@ public function __construct(ObjectManager $om, ClassMetadata $classMetadata) $this->om = $om; $this->classMetadata = $classMetadata; - $this->singleId = 1 === count($ids); - $this->intId = $this->singleId && in_array($idType, array('integer', 'smallint', 'bigint')); + $this->singleId = 1 === \count($ids); + $this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint')); $this->idField = current($ids); // single field association are resolved, since the schema column could be an int @@ -95,7 +95,7 @@ public function getIdValue($object) } if (!$this->om->contains($object)) { - throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_class($object))); + throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', \get_class($object))); } $this->om->initializeObject($object); diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php index 540fd0e03116..a2f1fa7ae8b7 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Doctrine\Form\ChoiceList; -use Doctrine\ORM\QueryBuilder; use Doctrine\DBAL\Connection; +use Doctrine\ORM\QueryBuilder; /** * Loads entities using a {@link QueryBuilder} instance. @@ -64,7 +64,7 @@ public function getEntitiesByIds($identifier, array $values) // Guess type $entity = current($qb->getRootEntities()); $metadata = $qb->getEntityManager()->getClassMetadata($entity); - if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) { + if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) { $parameterType = Connection::PARAM_INT_ARRAY; // Filter out non-integer values (e.g. ""). If we don't, some @@ -72,7 +72,7 @@ public function getEntitiesByIds($identifier, array $values) $values = array_values(array_filter($values, function ($v) { return (string) $v === (string) (int) $v || ctype_digit($v); })); - } elseif (in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) { + } elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) { $parameterType = Connection::PARAM_STR_ARRAY; // Like above, but we just filter out empty strings. diff --git a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php index 307361a52a3e..4010512ba9c4 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php @@ -11,10 +11,10 @@ namespace Symfony\Bridge\Doctrine\Form\DataTransformer; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\DataTransformerInterface; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Symfony\Component\Form\DataTransformerInterface; +use Symfony\Component\Form\Exception\TransformationFailedException; /** * @author Bernhard Schussek @@ -36,7 +36,7 @@ public function transform($collection) // For cases when the collection getter returns $collection->toArray() // in order to prevent modifications of the returned collection - if (is_array($collection)) { + if (\is_array($collection)) { return $collection; } diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php index 3d6fe3364f94..8b49f0662134 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php @@ -13,6 +13,7 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Common\Persistence\Mapping\MappingException; +use Doctrine\Common\Util\ClassUtils; use Doctrine\DBAL\Types\Type; use Doctrine\ORM\Mapping\ClassMetadataInfo; use Doctrine\ORM\Mapping\MappingException as LegacyMappingException; @@ -20,7 +21,6 @@ use Symfony\Component\Form\Guess\Guess; use Symfony\Component\Form\Guess\TypeGuess; use Symfony\Component\Form\Guess\ValueGuess; -use Doctrine\Common\Util\ClassUtils; class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface { @@ -133,7 +133,7 @@ public function guessMaxLength($class, $property) return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE); } - if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { + if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } } @@ -146,7 +146,7 @@ public function guessPattern($class, $property) { $ret = $this->getMetadata($class); if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) { - if (in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { + if (\in_array($ret[0]->getTypeOfField($property), array(Type::DECIMAL, Type::FLOAT))) { return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); } } diff --git a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php index 487523dd5dfe..22517181f759 100644 --- a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php +++ b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php @@ -12,9 +12,9 @@ namespace Symfony\Bridge\Doctrine\Form\EventListener; use Doctrine\Common\Collections\Collection; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Form\FormEvent; +use Symfony\Component\Form\FormEvents; /** * Merge changes from the request to a Doctrine\Common\Collections\Collection instance. @@ -45,7 +45,7 @@ public function onSubmit(FormEvent $event) // If all items were removed, call clear which has a higher // performance on persistent collections - if ($collection instanceof Collection && 0 === count($data)) { + if ($collection instanceof Collection && 0 === \count($data)) { $collection->clear(); } } diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php index 25b0aefecfe8..59cdc3b418eb 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -215,8 +215,8 @@ public function configureOptions(OptionsResolver $resolver) // Invoke the query builder closure so that we can cache choice lists // for equal query builders $queryBuilderNormalizer = function (Options $options, $queryBuilder) { - if (is_callable($queryBuilder)) { - $queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); + if (\is_callable($queryBuilder)) { + $queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); } return $queryBuilder; diff --git a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php index 4b07e83652c6..fa4176ee18f3 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php @@ -28,8 +28,8 @@ public function configureOptions(OptionsResolver $resolver) // Invoke the query builder closure so that we can cache choice lists // for equal query builders $queryBuilderNormalizer = function (Options $options, $queryBuilder) { - if (is_callable($queryBuilder)) { - $queryBuilder = call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); + if (\is_callable($queryBuilder)) { + $queryBuilder = \call_user_func($queryBuilder, $options['em']->getRepository($options['class'])); if (null !== $queryBuilder && !$queryBuilder instanceof QueryBuilder) { throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder'); diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 42574edcade5..0200c2657a0e 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Logger; +use Doctrine\DBAL\Logging\SQLLogger; use Psr\Log\LoggerInterface; use Symfony\Component\Stopwatch\Stopwatch; -use Doctrine\DBAL\Logging\SQLLogger; /** * @author Fabien Potencier @@ -71,12 +71,12 @@ private function normalizeParams(array $params) { foreach ($params as $index => $param) { // normalize recursively - if (is_array($param)) { + if (\is_array($param)) { $params[$index] = $this->normalizeParams($param); continue; } - if (!is_string($params[$index])) { + if (!\is_string($params[$index])) { continue; } diff --git a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php index c019c31a9ac0..bf73c0036d03 100644 --- a/src/Symfony/Bridge/Doctrine/ManagerRegistry.php +++ b/src/Symfony/Bridge/Doctrine/ManagerRegistry.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine; +use Doctrine\Common\Persistence\AbstractManagerRegistry; use ProxyManager\Proxy\LazyLoadingInterface; use Symfony\Component\DependencyInjection\Container; -use Doctrine\Common\Persistence\AbstractManagerRegistry; /** * References Doctrine connections and entity/document managers. diff --git a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php index f35984068f93..e0dcaae6c2f6 100644 --- a/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/RememberMe/DoctrineTokenProvider.php @@ -11,12 +11,12 @@ namespace Symfony\Bridge\Doctrine\Security\RememberMe; -use Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface; -use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface; -use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; -use Symfony\Component\Security\Core\Exception\TokenNotFoundException; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Types\Type as DoctrineType; +use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentToken; +use Symfony\Component\Security\Core\Authentication\RememberMe\PersistentTokenInterface; +use Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface; +use Symfony\Component\Security\Core\Exception\TokenNotFoundException; /** * This class provides storage for the tokens that is set in "remember me" diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index ea2793d471e3..726548e1744e 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -14,8 +14,8 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; -use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Component\Security\Core\User\UserProviderInterface; /** * Wrapper around a Doctrine ObjectManager. @@ -51,7 +51,7 @@ public function loadUserByUsername($username) $user = $repository->findOneBy(array($this->property => $username)); } else { if (!$repository instanceof UserLoaderInterface) { - throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository))); + throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, \get_class($repository))); } $user = $repository->loadUserByUsername($username); @@ -71,7 +71,7 @@ public function refreshUser(UserInterface $user) { $class = $this->getClass(); if (!$user instanceof $class) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); + throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user))); } $repository = $this->getRepository(); diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index ee1e36859ed1..06dc628475e9 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -14,8 +14,8 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Cache\ArrayCache; use Doctrine\ORM\Configuration; -use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use PHPUnit\Framework\TestCase; /** @@ -34,7 +34,7 @@ class DoctrineTestHelper */ public static function createTestEntityManager(Configuration $config = null) { - if (!extension_loaded('pdo_sqlite')) { + if (!\extension_loaded('pdo_sqlite')) { TestCase::markTestSkipped('Extension pdo_sqlite is required.'); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php index 692ee89e4bed..90dd1455921b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterMappingsPassTest.php @@ -4,8 +4,8 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; class RegisterMappingsPassTest extends TestCase { diff --git a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 9770e031a109..008cbd987d1e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -12,8 +12,8 @@ namespace Symfony\Bridge\Doctrine\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** @@ -68,7 +68,7 @@ public function testFixManagersAutoMappingsWithTwoAutomappings() 'SecondBundle' => 'My\SecondBundle', ); - $reflection = new \ReflectionClass(get_class($this->extension)); + $reflection = new \ReflectionClass(\get_class($this->extension)); $method = $reflection->getMethod('fixManagersAutoMappings'); $method->setAccessible(true); @@ -157,7 +157,7 @@ public function testFixManagersAutoMappings(array $originalEm1, array $originalE 'SecondBundle' => 'My\SecondBundle', ); - $reflection = new \ReflectionClass(get_class($this->extension)); + $reflection = new \ReflectionClass(\get_class($this->extension)); $method = $reflection->getMethod('fixManagersAutoMappings'); $method->setAccessible(true); diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php index 740a4f55f49c..8a9b00ddc73e 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class CompositeIntIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php index 10e083a8f429..0755a89e6a92 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class CompositeStringIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php index 5141e1669c9f..6c3f880eaacf 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/ContainerAwareFixture.php @@ -13,8 +13,8 @@ use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\Common\Persistence\ObjectManager; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; class ContainerAwareFixture implements FixtureInterface, ContainerAwareInterface { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNameEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNameEntity.php index cfb8e8b6664f..3559568787bc 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNameEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNameEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class DoubleNameEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNullableNameEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNullableNameEntity.php index 29b247b9b1c3..20ef14fd1b57 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNullableNameEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoubleNullableNameEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class DoubleNullableNameEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GroupableEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GroupableEntity.php index 2e36204bdfda..730a9b2b1dbf 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GroupableEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GroupableEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class GroupableEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GuidIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GuidIdEntity.php index 517f57495169..0d447ffc1e62 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GuidIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/GuidIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class GuidIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php index 19a5d8b9569f..6e383394bee4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; +use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\DiscriminatorColumn; use Doctrine\ORM\Mapping\DiscriminatorMap; -use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\InheritanceType; /** diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php index 954de338d3ca..5cd6d407962a 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleAssociationToIntIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\OneToOne; /** @Entity */ diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php index 6ee360e6a10a..d98b0ef93a60 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class SingleIntIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdNoToStringEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdNoToStringEntity.php index bcbe7a5f7bde..c94815ca02ca 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdNoToStringEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdNoToStringEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class SingleIntIdNoToStringEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdStringWrapperNameEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdStringWrapperNameEntity.php index d69d3de4b6f3..a06f4432a761 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdStringWrapperNameEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleIntIdStringWrapperNameEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper; /** @Entity */ diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php index 258c5a65158e..3e25e2aea52b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/SingleStringIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class SingleStringIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php index e59e32c27e82..c2ad425b61ea 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; use Symfony\Component\Security\Core\User\UserInterface; /** @Entity */ diff --git a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UuidIdEntity.php b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UuidIdEntity.php index 4998f7d7c545..46084ab292d4 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UuidIdEntity.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Fixtures/UuidIdEntity.php @@ -11,9 +11,9 @@ namespace Symfony\Bridge\Doctrine\Tests\Fixtures; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; +use Doctrine\ORM\Mapping\Id; /** @Entity */ class UuidIdEntity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php index 22a421ccefbd..211cb12e4df2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList; +use Doctrine\DBAL\Connection; +use Doctrine\ORM\Version; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; -use Doctrine\DBAL\Connection; -use Doctrine\ORM\Version; class ORMQueryBuilderLoaderTest extends TestCase { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index ac96ea21c531..f4f7effa61c2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -11,12 +11,12 @@ namespace Symfony\Bridge\Doctrine\Tests\Form\Type; -use Symfony\Component\Form\Test\FormPerformanceTestCase; -use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Doctrine\ORM\Tools\SchemaTool; +use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; +use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Component\Form\Extension\Core\CoreExtension; -use Symfony\Bridge\Doctrine\Form\DoctrineOrmExtension; +use Symfony\Component\Form\Test\FormPerformanceTestCase; /** * @author Bernhard Schussek @@ -72,7 +72,7 @@ protected function setUp() $ids = range(1, 300); foreach ($ids as $id) { - $name = 65 + (int) chr($id % 57); + $name = 65 + (int) \chr($id % 57); $this->em->persist(new SingleIntIdEntity($id, $name)); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 021371439732..c0061dabc540 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -23,7 +23,9 @@ use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeStringIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\GroupableEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleAssociationToIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringCastableIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity; use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView; @@ -31,8 +33,6 @@ use Symfony\Component\Form\Forms; use Symfony\Component\Form\Tests\Extension\Core\Type\BaseTypeTest; use Symfony\Component\Form\Tests\Extension\Core\Type\FormTypeTest; -use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleAssociationToIntIdEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; class EntityTypeTest extends BaseTypeTest { diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php index 1e3e6ca6ec80..38bbed12945f 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -145,7 +145,7 @@ public function testLogUTF8LongString() ; $testStringArray = array('é', 'á', 'ű', 'ő', 'ú', 'ö', 'ü', 'ó', 'í'); - $testStringCount = count($testStringArray); + $testStringCount = \count($testStringArray); $shortString = ''; $longString = ''; diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index f212ab25e6b8..dcb52718b117 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -30,7 +30,7 @@ class DoctrineExtractorTest extends TestCase protected function setUp() { - $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'), true); + $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'), true); $entityManager = EntityManager::create(array('driver' => 'pdo_sqlite'), $config); if (!DBALType::hasType('foo')) { diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php index 9517f6cc40d3..d02deb15bb7b 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php @@ -14,9 +14,9 @@ use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\OneToMany; use Doctrine\ORM\Mapping\ManyToMany; use Doctrine\ORM\Mapping\ManyToOne; +use Doctrine\ORM\Mapping\OneToMany; /** * @Entity diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php index 394eaebdefc6..8d0a9381143d 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineFooType.php @@ -50,7 +50,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform) return; } if (!$value instanceof Foo) { - throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', gettype($value))); + throw new ConversionException(sprintf('Expected %s, got %s', 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\Foo', \gettype($value))); } return $foo->bar; @@ -64,7 +64,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) if (null === $value) { return; } - if (!is_string($value)) { + if (!\is_string($value)) { throw ConversionException::conversionFailed($value, self::NAME); } diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineWithEmbedded.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineWithEmbedded.php index a1e011338f0b..aace866128b0 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineWithEmbedded.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineWithEmbedded.php @@ -12,9 +12,9 @@ namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures; use Doctrine\ORM\Mapping\Column; +use Doctrine\ORM\Mapping\Embedded; use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\Id; -use Doctrine\ORM\Mapping\Embedded; /** * @Entity diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 78a2cdb6f33b..9d0f79948ba6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -11,11 +11,11 @@ namespace Symfony\Bridge\Doctrine\Tests\Security\User; +use Doctrine\ORM\Tools\SchemaTool; use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Tests\Fixtures\User; -use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider; -use Doctrine\ORM\Tools\SchemaTool; class EntityUserProviderTest extends TestCase { @@ -146,7 +146,7 @@ public function testSupportProxy() $provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User', 'name'); $user2 = $em->getReference('Symfony\Bridge\Doctrine\Tests\Fixtures\User', array('id1' => 1, 'id2' => 1)); - $this->assertTrue($provider->supportsClass(get_class($user2))); + $this->assertTrue($provider->supportsClass(\get_class($user2))); } public function testLoadUserByUserNameShouldLoadUserWhenProperInterfaceProvided() diff --git a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php index efc611859a2b..a26ce98107f6 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php @@ -16,23 +16,23 @@ use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectRepository; use Doctrine\DBAL\Types\Type; +use Doctrine\ORM\Tools\SchemaTool; use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper; use Symfony\Bridge\Doctrine\Test\TestRepositoryFactory; -use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee; -use Symfony\Bridge\Doctrine\Tests\Fixtures\Person; +use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity; +use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2; use Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeObjectNoToStringIdEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity; -use Symfony\Bridge\Doctrine\Tests\Fixtures\AssociationEntity2; +use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee; +use Symfony\Bridge\Doctrine\Tests\Fixtures\Person; +use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdStringWrapperNameEntity; use Symfony\Bridge\Doctrine\Tests\Fixtures\Type\StringWrapper; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator; use Symfony\Component\Validator\Test\ConstraintValidatorTestCase; -use Doctrine\ORM\Tools\SchemaTool; /** * @author Bernhard Schussek diff --git a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index 004de6f67e5a..2015e7fb3acc 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -15,9 +15,9 @@ use Doctrine\Common\Persistence\Mapping\ClassMetadata; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Validator\Exception\ConstraintDefinitionException; use Symfony\Component\Validator\ConstraintValidator; +use Symfony\Component\Validator\Exception\ConstraintDefinitionException; +use Symfony\Component\Validator\Exception\UnexpectedTypeException; /** * Unique Entity Validator checks if one or a set of fields contain unique values. @@ -46,17 +46,17 @@ public function validate($entity, Constraint $constraint) throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity'); } - if (!is_array($constraint->fields) && !is_string($constraint->fields)) { + if (!\is_array($constraint->fields) && !\is_string($constraint->fields)) { throw new UnexpectedTypeException($constraint->fields, 'array'); } - if (null !== $constraint->errorPath && !is_string($constraint->errorPath)) { + if (null !== $constraint->errorPath && !\is_string($constraint->errorPath)) { throw new UnexpectedTypeException($constraint->errorPath, 'string or null'); } $fields = (array) $constraint->fields; - if (0 === count($fields)) { + if (0 === \count($fields)) { throw new ConstraintDefinitionException('At least one field has to be specified.'); } @@ -71,14 +71,14 @@ public function validate($entity, Constraint $constraint) throw new ConstraintDefinitionException(sprintf('Object manager "%s" does not exist.', $constraint->em)); } } else { - $em = $this->registry->getManagerForClass(get_class($entity)); + $em = $this->registry->getManagerForClass(\get_class($entity)); if (!$em) { - throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', get_class($entity))); + throw new ConstraintDefinitionException(sprintf('Unable to find the object manager associated with an entity of class "%s".', \get_class($entity))); } } - $class = $em->getClassMetadata(get_class($entity)); + $class = $em->getClassMetadata(\get_class($entity)); /* @var $class \Doctrine\Common\Persistence\Mapping\ClassMetadata */ $criteria = array(); @@ -133,7 +133,7 @@ public function validate($entity, Constraint $constraint) throw new ConstraintDefinitionException(sprintf('The "%s" entity repository does not support the "%s" entity. The entity should be an instance of or extend "%s".', $constraint->entityClass, $class->getName(), $supportedClass)); } } else { - $repository = $em->getRepository(get_class($entity)); + $repository = $em->getRepository(\get_class($entity)); } $result = $repository->{$constraint->repositoryMethod}($criteria); @@ -182,11 +182,11 @@ public function validate($entity, Constraint $constraint) private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, $value) { - if (!is_object($value) || $value instanceof \DateTimeInterface) { + if (!\is_object($value) || $value instanceof \DateTimeInterface) { return $this->formatValue($value, self::PRETTY_DATE); } - if ($class->getName() !== $idClass = get_class($value)) { + if ($class->getName() !== $idClass = \get_class($value)) { // non unique value might be a composite PK that consists of other entity objects if ($em->getMetadataFactory()->hasMetadataFor($idClass)) { $identifiers = $em->getClassMetadata($idClass)->getIdentifierValues($value); @@ -204,10 +204,10 @@ private function formatWithIdentifiers(ObjectManager $em, ClassMetadata $class, } array_walk($identifiers, function (&$id, $field) { - if (!is_object($id) || $id instanceof \DateTimeInterface) { + if (!\is_object($id) || $id instanceof \DateTimeInterface) { $idAsString = $this->formatValue($id, self::PRETTY_DATE); } else { - $idAsString = sprintf('object("%s")', get_class($id)); + $idAsString = sprintf('object("%s")', \get_class($id)); } $id = sprintf('%s => %s', $field, $idAsString); diff --git a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php index 42cafdd12947..010c051581e7 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php +++ b/src/Symfony/Bridge/Doctrine/Validator/DoctrineInitializer.php @@ -30,7 +30,7 @@ public function __construct(ManagerRegistry $registry) public function initialize($object) { - $manager = $this->registry->getManagerForClass(get_class($object)); + $manager = $this->registry->getManagerForClass(\get_class($object)); if (null !== $manager) { $manager->initializeObject($object); } diff --git a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php index 596fcdd84d2c..ed41929a2cef 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php +++ b/src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php @@ -12,8 +12,8 @@ namespace Symfony\Bridge\Monolog\Handler\FingersCrossed; use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; -use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\Exception\HttpException; /** * Activation strategy that ignores 404s for certain URLs. diff --git a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php index 966a7baf8307..9956edad386d 100644 --- a/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/FirePHPHandler.php @@ -12,8 +12,8 @@ namespace Symfony\Bridge\Monolog\Handler; use Monolog\Handler\FirePHPHandler as BaseFirePHPHandler; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; /** * FirePHPHandler. diff --git a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php index 99979c5a80ba..6c21a335f085 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php @@ -102,7 +102,7 @@ private function formatRecord(array $record) { if ($this->processors) { foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); + $record = \call_user_func($processor, $record); } } diff --git a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php index 63b5a8f07b6d..92b319f13a98 100644 --- a/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php @@ -14,13 +14,13 @@ use Monolog\Logger; use PHPUnit\Framework\TestCase; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; -use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\Console\Command\Command; /** * Tests the ConsoleHandler and also the ConsoleFormatter. diff --git a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php index aeb3b55fdc49..f3c54fdde50b 100644 --- a/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php +++ b/src/Symfony/Bridge/Monolog/Tests/LoggerTest.php @@ -13,8 +13,8 @@ use Monolog\Handler\TestHandler; use PHPUnit\Framework\TestCase; -use Symfony\Bridge\Monolog\Processor\DebugProcessor; use Symfony\Bridge\Monolog\Logger; +use Symfony\Bridge\Monolog\Processor\DebugProcessor; class LoggerTest extends TestCase { diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 40ed8ecc0e45..9ab2c779b33d 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -71,7 +71,7 @@ public static function microtime($asFloat = false) public static function register($class) { - $self = get_called_class(); + $self = \get_called_class(); $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); if (0 < strpos($class, '\\Tests\\')) { @@ -81,7 +81,7 @@ public static function register($class) $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { - if (function_exists($ns.'\time')) { + if (\function_exists($ns.'\time')) { continue; } eval(<<getFileName())); + $v = \dirname(\dirname($r->getFileName())); if (file_exists($v.'/composer/installed.json')) { $vendors[] = $v; } @@ -80,7 +80,7 @@ public static function register($mode = 0) return true; } foreach ($vendors as $vendor) { - if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) { + if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) { return true; } } @@ -112,7 +112,7 @@ public static function register($mode = 0) $group = 'other'; $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && $inVendors($file); - $i = count($trace); + $i = \count($trace); while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { // No-op } @@ -129,7 +129,7 @@ public static function register($mode = 0) // if the error has been triggered from vendor code. $isVendor = DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode && isset($parsedMsg['triggering_file']) && $inVendors($parsedMsg['triggering_file']); } else { - $class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class']; + $class = isset($trace[$i]['object']) ? \get_class($trace[$i]['object']) : $trace[$i]['class']; $method = $trace[$i]['function']; } @@ -141,7 +141,7 @@ public static function register($mode = 0) || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') - || in_array('legacy', $Test::getGroups($class, $method), true) + || \in_array('legacy', $Test::getGroups($class, $method), true) ) { $group = 'legacy'; } elseif ($isVendor) { @@ -154,12 +154,12 @@ public static function register($mode = 0) $e = new \Exception($msg); $r = new \ReflectionProperty($e, 'trace'); $r->setAccessible(true); - $r->setValue($e, array_slice($trace, 1, $i)); + $r->setValue($e, \array_slice($trace, 1, $i)); echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':'; echo "\n".$msg; echo "\nStack trace:"; - echo "\n".str_replace(' '.getcwd().DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString()); + echo "\n".str_replace(' '.getcwd().\DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString()); echo "\n"; exit(1); @@ -255,12 +255,12 @@ public static function register($mode = 0) // reset deprecations array foreach ($deprecations as $group => $arrayOrInt) { - $deprecations[$group] = is_int($arrayOrInt) ? 0 : array(); + $deprecations[$group] = \is_int($arrayOrInt) ? 0 : array(); } register_shutdown_function(function () use (&$deprecations, $isFailing, $displayDeprecations, $mode) { foreach ($deprecations as $group => $arrayOrInt) { - if (0 < (is_int($arrayOrInt) ? $arrayOrInt : count($arrayOrInt))) { + if (0 < (\is_int($arrayOrInt) ? $arrayOrInt : \count($arrayOrInt))) { echo "Shutdown-time deprecations:\n"; break; } @@ -307,7 +307,7 @@ public static function collectDeprecations($outputFile) */ private static function hasColorSupport() { - if (!defined('STDOUT')) { + if (!\defined('STDOUT')) { return false; } @@ -315,19 +315,19 @@ private static function hasColorSupport() return true; } - if (DIRECTORY_SEPARATOR === '\\') { - return (function_exists('sapi_windows_vt100_support') + if (\DIRECTORY_SEPARATOR === '\\') { + return (\function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)) || false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM'); } - if (function_exists('stream_isatty')) { + if (\function_exists('stream_isatty')) { return stream_isatty(STDOUT); } - if (function_exists('posix_isatty')) { + if (\function_exists('posix_isatty')) { return posix_isatty(STDOUT); } diff --git a/src/Symfony/Bridge/PhpUnit/DnsMock.php b/src/Symfony/Bridge/PhpUnit/DnsMock.php index a85ec977c71d..790cfa91af5c 100644 --- a/src/Symfony/Bridge/PhpUnit/DnsMock.php +++ b/src/Symfony/Bridge/PhpUnit/DnsMock.php @@ -163,7 +163,7 @@ public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = nul public static function register($class) { - $self = get_called_class(); + $self = \get_called_class(); $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); if (0 < strpos($class, '\\Tests\\')) { @@ -173,7 +173,7 @@ public static function register($class) $mockedNs[] = substr($class, 6, strrpos($class, '\\') - 6); } foreach ($mockedNs as $ns) { - if (function_exists($ns.'\checkdnsrr')) { + if (\function_exists($ns.'\checkdnsrr')) { continue; } eval(<<getTestResultObject(), 'addWarning') && class_exists(Warning::class)) { $test->getTestResultObject()->addWarning($test, new Warning($message), 0); } else { - $this->warnings[] = sprintf("%s::%s\n%s", get_class($test), $test->getName(), $message); + $this->warnings[] = sprintf("%s::%s\n%s", \get_class($test), $test->getName(), $message); } } @@ -75,7 +75,7 @@ public function startTest($test) $cache = $r->getValue(); $cache = array_replace_recursive($cache, array( - get_class($test) => array( + \get_class($test) => array( 'covers' => array($sutFqcn), ), )); @@ -90,7 +90,7 @@ private function findSutFqcn($test) return $resolver($test); } - $class = get_class($test); + $class = \get_class($test); $sutFqcn = str_replace('\\Tests\\', '\\', $class); $sutFqcn = preg_replace('{Test$}', '', $sutFqcn); diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 7ded32a78246..d072e7e91ffa 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -53,7 +53,7 @@ public function __construct(array $mockedNamespaces = array()) } foreach ($mockedNamespaces as $type => $namespaces) { - if (!is_array($namespaces)) { + if (!\is_array($namespaces)) { $namespaces = array($namespaces); } if ('time-sensitive' === $type) { @@ -98,10 +98,10 @@ public function startTestSuite($suite) $this->testsWithWarnings = array(); foreach ($suite->tests() as $test) { - if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { + if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { continue; } - if (null === $Test::getPreserveGlobalStateSettings(get_class($test), $test->getName(false))) { + if (null === $Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) { $test->setPreserveGlobalState(false); } } @@ -139,10 +139,10 @@ public function startTestSuite($suite) continue; } $groups = $Test::getGroups($test->getName()); - if (in_array('time-sensitive', $groups, true)) { + if (\in_array('time-sensitive', $groups, true)) { ClockMock::register($test->getName()); } - if (in_array('dns-sensitive', $groups, true)) { + if (\in_array('dns-sensitive', $groups, true)) { DnsMock::register($test->getName()); } } @@ -151,7 +151,7 @@ public function startTestSuite($suite) } elseif (2 === $this->state) { $skipped = array(); foreach ($suite->tests() as $test) { - if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) + if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) || isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName][$test->getName()])) { $skipped[] = $test; @@ -164,8 +164,8 @@ public function startTestSuite($suite) public function addSkippedTest($test, \Exception $e, $time) { if (0 < $this->state) { - if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) { - $class = get_class($test); + if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) { + $class = \get_class($test); $method = $test->getName(); } else { $class = $test->getName(); @@ -178,7 +178,7 @@ public function addSkippedTest($test, \Exception $e, $time) public function startTest($test) { - if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { + if (-2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { if (null !== $test->getTestResultObject()) { $this->reportUselessTests = $test->getTestResultObject()->isStrictAboutTestsThatDoNotTestAnything(); } @@ -196,25 +196,25 @@ public function startTest($test) $Test = 'PHPUnit\Util\Test'; $AssertionFailedError = 'PHPUnit\Framework\AssertionFailedError'; } - $groups = $Test::getGroups(get_class($test), $test->getName(false)); + $groups = $Test::getGroups(\get_class($test), $test->getName(false)); if (!$this->runsInSeparateProcess) { - if (in_array('time-sensitive', $groups, true)) { - ClockMock::register(get_class($test)); + if (\in_array('time-sensitive', $groups, true)) { + ClockMock::register(\get_class($test)); ClockMock::withClockMock(true); } - if (in_array('dns-sensitive', $groups, true)) { - DnsMock::register(get_class($test)); + if (\in_array('dns-sensitive', $groups, true)) { + DnsMock::register(\get_class($test)); } } - $annotations = $Test::parseTestMethodAnnotations(get_class($test), $test->getName(false)); + $annotations = $Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { $test->getTestResultObject()->addError($test, new $AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); } if (isset($annotations['method']['expectedDeprecation'])) { - if (!in_array('legacy', $groups, true)) { + if (!\in_array('legacy', $groups, true)) { $this->error = new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'); } @@ -228,7 +228,7 @@ public function startTest($test) public function addWarning($test, $e, $time) { - if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) { + if ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) { $this->testsWithWarnings[$test->getName()] = true; } } @@ -244,7 +244,7 @@ public function endTest($test, $time) $BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner'; $Warning = 'PHPUnit\Framework\Warning'; } - $className = get_class($test); + $className = \get_class($test); $classGroups = $Test::getGroups($className); $groups = $Test::getGroups($className, $test->getName(false)); @@ -265,7 +265,7 @@ public function endTest($test, $time) foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null)); if ($deprecation[0]) { - trigger_error($error, E_USER_DEPRECATED); + @trigger_error($error, E_USER_DEPRECATED); } else { @trigger_error($error, E_USER_DEPRECATED); } @@ -274,13 +274,13 @@ public function endTest($test, $time) } if ($this->expectedDeprecations) { - if (!in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) { - $test->addToAssertionCount(count($this->expectedDeprecations)); + if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) { + $test->addToAssertionCount(\count($this->expectedDeprecations)); } restore_error_handler(); - if (!$errored && !in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) { + if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) { try { $prefix = "@expectedDeprecation:\n"; $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); @@ -294,11 +294,11 @@ public function endTest($test, $time) $this->expectedDeprecations = $this->gatheredDeprecations = array(); $this->previousErrorHandler = null; } - if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { - if (in_array('time-sensitive', $groups, true)) { + if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { + if (\in_array('time-sensitive', $groups, true)) { ClockMock::withClockMock(false); } - if (in_array('dns-sensitive', $groups, true)) { + if (\in_array('dns-sensitive', $groups, true)) { DnsMock::withMockedHosts(array()); } } @@ -314,7 +314,7 @@ public function handleError($type, $msg, $file, $line, $context = array()) // If the message is serialized we need to extract the message. This occurs when the error is triggered by // by the isolated test path in \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest(). $parsedMsg = @unserialize($msg); - if (is_array($parsedMsg)) { + if (\is_array($parsedMsg)) { $msg = $parsedMsg['deprecation']; } if (error_reporting()) { diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/LazyLoadingValueHolderFactoryV2.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/LazyLoadingValueHolderFactoryV2.php index f41fc20b5d52..a643f33710dd 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/LazyLoadingValueHolderFactoryV2.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/LazyLoadingValueHolderFactoryV2.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\ProxyManager\LazyProxy\Instantiator; -use ProxyManager\ProxyGenerator\ProxyGeneratorInterface; use ProxyManager\Factory\LazyLoadingValueHolderFactory as BaseFactory; +use ProxyManager\ProxyGenerator\ProxyGeneratorInterface; use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator; /** diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php index 33fc49e1012d..7d083a6981e2 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php @@ -51,7 +51,7 @@ public function instantiateProxy(ContainerInterface $container, Definition $defi return $this->factory->createProxy( $definition->getClass(), function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) { - $wrappedInstance = call_user_func($realInstantiator); + $wrappedInstance = \call_user_func($realInstantiator); $proxy->setProxyInitializer(null); diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 0871c4ce9d70..18da9118a222 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -114,7 +114,7 @@ private static function getProxyManagerVersion(): string return '0.0.1'; } - return defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(); + return \defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(); } /** diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index 54a785c0a433..702edcbceaa7 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -83,7 +83,7 @@ public function getUser() } $user = $token->getUser(); - if (is_object($user)) { + if (\is_object($user)) { return $user; } } @@ -169,7 +169,7 @@ public function getFlashes($types = null) return $session->getFlashBag()->all(); } - if (is_string($types)) { + if (\is_string($types)) { return $session->getFlashBag()->get($types); } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 902dbb317d25..74e83919cfda 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -13,8 +13,8 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Twig\Environment; @@ -111,15 +111,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $firstNamespace = true; $prevHasSeparator = false; foreach ($this->getLoaderPaths() as $namespace => $paths) { - if (!$firstNamespace && !$prevHasSeparator && count($paths) > 1) { + if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) { $rows[] = array('', ''); } $firstNamespace = false; foreach ($paths as $path) { - $rows[] = array($namespace, $path.DIRECTORY_SEPARATOR); + $rows[] = array($namespace, $path.\DIRECTORY_SEPARATOR); $namespace = ''; } - if (count($paths) > 1) { + if (\count($paths) > 1) { $rows[] = array('', ''); $prevHasSeparator = true; } else { @@ -145,7 +145,7 @@ private function getLoaderPaths() foreach ($loader->getNamespaces() as $namespace) { $paths = array_map(function ($path) { if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) { - $path = ltrim(substr($path, strlen($this->projectDir)), DIRECTORY_SEPARATOR); + $path = ltrim(substr($path, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); } return $path; @@ -176,16 +176,16 @@ private function getMetadata($type, $entity) if (null === $cb) { return; } - if (is_array($cb)) { + if (\is_array($cb)) { if (!method_exists($cb[0], $cb[1])) { return; } $refl = new \ReflectionMethod($cb[0], $cb[1]); - } elseif (is_object($cb) && method_exists($cb, '__invoke')) { + } elseif (\is_object($cb) && method_exists($cb, '__invoke')) { $refl = new \ReflectionMethod($cb, '__invoke'); - } elseif (function_exists($cb)) { + } elseif (\function_exists($cb)) { $refl = new \ReflectionFunction($cb); - } elseif (is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) { + } elseif (\is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) { $refl = new \ReflectionMethod($m[1], $m[2]); } else { throw new \UnexpectedValueException('Unsupported callback type'); @@ -235,8 +235,8 @@ private function getPrettyMetadata($type, $entity) } if ('globals' === $type) { - if (is_object($meta)) { - return ' = object('.get_class($meta).')'; + if (\is_object($meta)) { + return ' = object('.\get_class($meta).')'; } return ' = '.substr(@json_encode($meta), 0, 50); diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php index 84a62ae93395..68eebf123cf8 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -77,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new SymfonyStyle($input, $output); $filenames = $input->getArgument('filename'); - if (0 === count($filenames)) { + if (0 === \count($filenames)) { if (0 !== ftell(STDIN)) { throw new RuntimeException('Please provide a filename or pipe template content to STDIN.'); } @@ -162,9 +162,9 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInf } if (0 === $errors) { - $io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo))); + $io->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo))); } else { - $io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors)); + $io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors)); } return min($errors, 1); @@ -217,7 +217,7 @@ private function getContext($template, $line, $context = 3) $lines = explode("\n", $template); $position = max(0, $line - $context); - $max = min(count($lines), $line - 1 + $context); + $max = min(\count($lines), $line - 1 + $context); $result = array(); while ($position < $max) { diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php index 8d9f58e64c1d..9e214fc73101 100644 --- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php +++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php @@ -11,10 +11,10 @@ namespace Symfony\Bridge\Twig\DataCollector; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; -use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\DataCollector\DataCollector; +use Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface; use Twig\Environment; use Twig\Markup; use Twig\Profiler\Dumper\HtmlDumper; diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index c0982fab00a2..f84eaeb7e72e 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -34,7 +34,7 @@ class CodeExtension extends AbstractExtension public function __construct($fileLinkFormat, string $rootDir, string $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR; + $this->rootDir = str_replace('/', \DIRECTORY_SEPARATOR, \dirname($rootDir)).\DIRECTORY_SEPARATOR; $this->charset = $charset; } @@ -94,7 +94,7 @@ public function formatArgs($args) $short = array_pop($parts); $formattedValue = sprintf('object(%s)', $item[1], $short); } elseif ('array' === $item[0]) { - $formattedValue = sprintf('array(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); + $formattedValue = sprintf('array(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); } elseif ('null' === $item[0]) { $formattedValue = 'null'; } elseif ('boolean' === $item[0]) { @@ -105,7 +105,7 @@ public function formatArgs($args) $formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset)); } - $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); + $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); } return implode(', ', $result); @@ -148,10 +148,10 @@ public function fileExcerpt($file, $line, $srcContext = 3) $lines = array(); if (0 > $srcContext) { - $srcContext = count($content); + $srcContext = \count($content); } - for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, count($content)); $i <= $max; ++$i) { + for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, \count($content)); $i <= $max; ++$i) { $lines[] = ''.self::fixCodeMarkup($content[$i - 1]).''; } @@ -173,11 +173,11 @@ public function formatFile($file, $line, $text = null) $file = trim($file); if (null === $text) { - $text = str_replace('/', DIRECTORY_SEPARATOR, $file); + $text = str_replace('/', \DIRECTORY_SEPARATOR, $file); if (0 === strpos($text, $this->rootDir)) { - $text = substr($text, strlen($this->rootDir)); - $text = explode(DIRECTORY_SEPARATOR, $text, 2); - $text = sprintf('%s%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : ''); + $text = substr($text, \strlen($this->rootDir)); + $text = explode(\DIRECTORY_SEPARATOR, $text, 2); + $text = sprintf('%s%s', $this->rootDir, $text[0], isset($text[1]) ? \DIRECTORY_SEPARATOR.$text[1] : ''); } } @@ -203,7 +203,7 @@ public function formatFile($file, $line, $text = null) public function getFileLink($file, $line) { if ($fmt = $this->fileLinkFormat) { - return is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); + return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line); } return false; diff --git a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php index 2cc3f1a4b044..3d4c6841f201 100644 --- a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php @@ -58,7 +58,7 @@ public function dump(Environment $env, $context) return; } - if (2 === func_num_args()) { + if (2 === \func_num_args()) { $vars = array(); foreach ($context as $key => $value) { if (!$value instanceof Template) { @@ -68,7 +68,7 @@ public function dump(Environment $env, $context) $vars = array($vars); } else { - $vars = func_get_args(); + $vars = \func_get_args(); unset($vars[0], $vars[1]); } diff --git a/src/Symfony/Bridge/Twig/Extension/FormExtension.php b/src/Symfony/Bridge/Twig/Extension/FormExtension.php index 834fbf096ef7..4f50215637dd 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -100,8 +100,8 @@ public function getName() */ function twig_is_selected_choice(ChoiceView $choice, $selectedValue) { - if (is_array($selectedValue)) { - return in_array($choice->value, $selectedValue, true); + if (\is_array($selectedValue)) { + return \in_array($choice->value, $selectedValue, true); } return $choice->value === $selectedValue; diff --git a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php index 0dad40cfa0a3..fe2778393cfd 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Twig\Extension; -use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Routing\RequestContext; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -97,7 +97,7 @@ public function generateAbsoluteUrl($path) if (!$path || '/' !== $path[0]) { $prefix = $request->getPathInfo(); - $last = strlen($prefix) - 1; + $last = \strlen($prefix) - 1; if ($last !== $pos = strrpos($prefix, '/')) { $prefix = substr($prefix, 0, $pos).'/'; } diff --git a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php index 3c1f1a015e10..6eea673e25fa 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Twig\Extension; -use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpKernel\Controller\ControllerReference; +use Symfony\Component\HttpKernel\Fragment\FragmentHandler; /** * Provides integration with the HttpKernel component. diff --git a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index 57e8902dce98..a23a62bb28ae 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -100,7 +100,7 @@ public function isUrlGenerationSafe(Node $argsNode) $argsNode->hasNode(1) ? $argsNode->getNode(1) : null ); - if (null === $paramsNode || $paramsNode instanceof ArrayExpression && count($paramsNode) <= 2 && + if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 && (!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression) ) { return array('html'); diff --git a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php index 1afbea5f363a..20b0471d53b2 100644 --- a/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Twig\Extension; -use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Bridge\Twig\TokenParser\StopwatchTokenParser; +use Symfony\Component\Stopwatch\Stopwatch; use Twig\Extension\AbstractExtension; /** diff --git a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php index f1131c52df61..fe1adc4a7dd0 100644 --- a/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php @@ -11,12 +11,12 @@ namespace Symfony\Bridge\Twig\Extension; -use Symfony\Bridge\Twig\TokenParser\TransTokenParser; +use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor; +use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; use Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser; use Symfony\Bridge\Twig\TokenParser\TransDefaultDomainTokenParser; +use Symfony\Bridge\Twig\TokenParser\TransTokenParser; use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor; -use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor; use Twig\Extension\AbstractExtension; use Twig\NodeVisitor\NodeVisitorInterface; use Twig\TokenParser\AbstractTokenParser; diff --git a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 81f1d32446ab..88b29d7c2312 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -42,7 +42,7 @@ public function encode($input, $inline = 0, $dumpObjects = 0) $dumper = new YamlDumper(); } - if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { + if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { return $dumper->dump($input, $inline, 0, $dumpObjects); } @@ -51,12 +51,12 @@ public function encode($input, $inline = 0, $dumpObjects = 0) public function dump($value, $inline = 0, $dumpObjects = false) { - if (is_resource($value)) { + if (\is_resource($value)) { return '%Resource%'; } - if (is_array($value) || is_object($value)) { - return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); + if (\is_array($value) || \is_object($value)) { + return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); } return $this->encode($value, $inline, $dumpObjects); diff --git a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php index 51abce710435..bf97e52ad346 100644 --- a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php +++ b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php @@ -98,7 +98,7 @@ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockNam // Check each theme whether it contains the searched block if (isset($this->themes[$cacheKey])) { - for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) { + for ($i = \count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) { $this->loadResourcesFromTheme($cacheKey, $this->themes[$cacheKey][$i]); // CONTINUE LOADING (see doc comment) } @@ -107,7 +107,7 @@ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockNam // Check the default themes once we reach the root view without success if (!$view->parent) { if (!isset($this->useDefaultThemes[$cacheKey]) || $this->useDefaultThemes[$cacheKey]) { - for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) { + for ($i = \count($this->defaultThemes) - 1; $i >= 0; --$i) { $this->loadResourcesFromTheme($cacheKey, $this->defaultThemes[$i]); // CONTINUE LOADING (see doc comment) } diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php index 1a60e67a2f94..6a34a037e48f 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -11,8 +11,8 @@ namespace Symfony\Bridge\Twig\NodeVisitor; -use Symfony\Bridge\Twig\Node\TransNode; use Symfony\Bridge\Twig\Node\TransDefaultDomainNode; +use Symfony\Bridge\Twig\Node\TransNode; use Twig\Environment; use Twig\Node\BlockNode; use Twig\Node\Expression\ArrayExpression; @@ -64,7 +64,7 @@ protected function doEnterNode(Node $node, Environment $env) return $node; } - if ($node instanceof FilterExpression && in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) { + if ($node instanceof FilterExpression && \in_array($node->getNode('filter')->getAttribute('value'), array('trans', 'transchoice'))) { $arguments = $node->getNode('arguments'); $ind = 'trans' === $node->getNode('filter')->getAttribute('value') ? 1 : 2; if ($this->isNamedArguments($arguments)) { @@ -119,7 +119,7 @@ public function getPriority() private function isNamedArguments($arguments) { foreach ($arguments as $name => $node) { - if (!is_int($name)) { + if (!\is_int($name)) { return true; } } diff --git a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php index 77d522f5230a..39b0d0df5a2b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/DebugCommandTest.php @@ -15,8 +15,8 @@ use Symfony\Bridge\Twig\Command\DebugCommand; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -use Twig\Loader\FilesystemLoader; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class DebugCommandTest extends TestCase { @@ -39,7 +39,7 @@ public function testLineSeparatorInLoaderPaths() FilesystemLoader::MAIN_NAMESPACE => array('extractor', 'extractor'), )); $ret = $tester->execute(array(), array('decorated' => false)); - $ds = DIRECTORY_SEPARATOR; + $ds = \DIRECTORY_SEPARATOR; $loaderPaths = << $relDirs) { foreach ($relDirs as $relDir) { $filesystemLoader->addPath($relDir, $namespace); diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index ce7175ab1adf..535a12f3576f 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -16,8 +16,8 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; -use Twig\Loader\FilesystemLoader; use Twig\Environment; +use Twig\Loader\FilesystemLoader; class LintCommandTest extends TestCase { diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index ce80418c83ba..1522928a6c41 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -13,9 +13,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\DumpExtension; +use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Symfony\Component\VarDumper\VarDumper; -use Symfony\Component\VarDumper\Cloner\VarCloner; use Twig\Environment; use Twig\Loader\ArrayLoader; @@ -76,7 +76,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) array_unshift($args, $context); array_unshift($args, $twig); - $dump = call_user_func_array(array($extension, 'dump'), $args); + $dump = \call_user_func_array(array($extension, 'dump'), $args); if ($debug) { $this->assertStringStartsWith('