diff --git a/.php_cs.dist b/.php_cs.dist index 2731440d1933..7138413855ef 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,6 +15,10 @@ return PhpCsFixer\Config::create() // rule disabled due to https://bugs.php.net/bug.php?id=60573 bug; // to be re-enabled (by dropping next line, rule is part of @Symfony already) on branch that requires PHP 5.4+ 'self_accessor' => false, + // TODO remove the disabling once https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876 is merged and released + 'native_constant_invocation' => 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( @@ -32,7 +36,11 @@ return PhpCsFixer\Config::create() '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 @@ -40,8 +48,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/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index 895ade5fe740..baa99fac5d3d 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 a57b9ae6ea15..2580c1b88dc9 100644 --- a/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php +++ b/src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php @@ -120,14 +120,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) { @@ -158,11 +158,11 @@ private function sanitizeQuery($connectionName, $query) */ private function sanitizeParam($var) { - if (is_object($var)) { - return array(sprintf('Object(%s)', get_class($var)), false); + if (\is_object($var)) { + return array(sprintf('Object(%s)', \get_class($var)), false); } - if (is_array($var)) { + if (\is_array($var)) { $a = array(); $original = true; foreach ($var as $k => $v) { @@ -174,7 +174,7 @@ private function sanitizeParam($var) 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 8426d307da5d..ac79c576afea 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -142,7 +142,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); @@ -154,7 +154,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(); @@ -241,7 +241,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 '. @@ -264,17 +264,17 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container) $configPath = $this->getMappingResourceConfigDirectory(); $resource = $dir.'/'.$configPath; while (!is_dir($resource)) { - $resource = dirname($resource); + $resource = \dirname($resource); } $container->addResource(new FileResource($resource)); $extension = $this->getMappingResourceExtension(); - if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && count($files)) { + if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && \count($files)) { return 'xml'; - } elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && count($files)) { + } elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && \count($files)) { return 'yml'; - } elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && count($files)) { + } elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && \count($files)) { return 'php'; } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php index 82c1b7c81138..4b030955a98f 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php @@ -60,7 +60,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflection = new \ReflectionClass($bundle); - if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) { + if (is_file($file = \dirname($reflection->getFileName()).'/'.$validationPath)) { $files[] = $file; $container->addResource(new FileResource($file)); } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php index f7d513a14e09..2ba7747e3881 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php @@ -153,7 +153,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 6ec2407d9073..ac3a55e481d9 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php @@ -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/Form/ChoiceList/DoctrineChoiceLoader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php index bf5890c1e69f..43120c625857 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php @@ -88,7 +88,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()) { @@ -125,7 +125,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) && $value[0] === $this->idReader; + $optimize = null === $value || \is_array($value) && $value[0] === $this->idReader; 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/EntityChoiceList.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php index 2c226f50a0ad..b196e8918344 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php @@ -117,7 +117,7 @@ public function __construct(ObjectManager $manager, $class, $labelPath = null, E $this->entityLoader = $entityLoader; $this->classMetadata = $manager->getClassMetadata($class); $this->class = $this->classMetadata->getName(); - $this->loaded = is_array($entities) || $entities instanceof \Traversable; + $this->loaded = \is_array($entities) || $entities instanceof \Traversable; $this->preferredEntities = $preferredEntities; list( $this->idAsIndex, @@ -449,13 +449,13 @@ private function getIdentifierInfoForClass(ClassMetadata $classMetadata) $identifiers = $classMetadata->getIdentifierFieldNames(); - if (1 === count($identifiers)) { + if (1 === \count($identifiers)) { $identifier = $identifiers[0]; if (!$classMetadata->hasAssociation($identifier)) { $idAsValue = true; - if (in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) { + if (\in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) { $idAsIndex = true; } } diff --git a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php index 1d881849267d..9c632330354b 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 c9a02fb38d76..0a0de20c573c 100644 --- a/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php +++ b/src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php @@ -98,7 +98,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 @@ -106,7 +106,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..63c8f2439b9a 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php @@ -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 645e2fda4cc6..a1b614944e2f 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php @@ -131,7 +131,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); } } @@ -144,7 +144,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 bb4cfa5087c4..8f96f3677c8b 100644 --- a/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php +++ b/src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php @@ -41,7 +41,7 @@ public function onBind(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 2acf7176f1ea..f76872a5818c 100644 --- a/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php +++ b/src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php @@ -259,8 +259,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 7ec1ea3d4334..99ce535e23c0 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..9099fe06765d 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -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/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 7356ff2998cf..18d3e690a72b 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -52,7 +52,7 @@ public function loadUserByUsername($username) } else { if (!$repository instanceof UserLoaderInterface) { if (!$repository instanceof UserProviderInterface) { - 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))); } @trigger_error('Implementing Symfony\Component\Security\Core\User\UserProviderInterface in a Doctrine repository when using the entity provider is deprecated since Symfony 2.8 and will not be supported in 3.0. Make the repository implement Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface instead.', E_USER_DEPRECATED); @@ -75,7 +75,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 1a97922b05f8..9fa7c777a533 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -30,7 +30,7 @@ class DoctrineTestHelper */ public static function createTestEntityManager() { - 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/DoctrineExtensionTest.php b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php index 0a9dae3b200f..63109fab99e2 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php @@ -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/Form/Type/EntityTypePerformanceTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php index ac96ea21c531..048747c93794 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypePerformanceTest.php @@ -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/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/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/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php index 299138cf795d..7779acaa801c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php @@ -176,7 +176,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/Validator/Constraints/UniqueEntityValidator.php b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php index f000cae75ebe..cb0879613161 100644 --- a/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php +++ b/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php @@ -45,17 +45,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.'); } @@ -70,14 +70,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(); @@ -120,7 +120,7 @@ public function validate($entity, Constraint $constraint) return; } - $repository = $em->getRepository(get_class($entity)); + $repository = $em->getRepository(\get_class($entity)); $result = $repository->{$constraint->repositoryMethod}($criteria); if ($result instanceof \IteratorAggregate) { 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/DebugHandler.php b/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php index f1046c96a6ad..4c124709eaec 100644 --- a/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/DebugHandler.php @@ -51,7 +51,7 @@ public function countErrors() $levels = array(Logger::ERROR, Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY); foreach ($levels as $level) { if (isset($this->recordsByLevel[$level])) { - $cnt += count($this->recordsByLevel[$level]); + $cnt += \count($this->recordsByLevel[$level]); } } diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 8bfb9a621118..5cd3531d6b67 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 (strpos($class, '\\Tests\\')) { @@ -79,7 +79,7 @@ public static function register($class) $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); } foreach ($mockedNs as $ns) { - if (function_exists($ns.'\time')) { + if (\function_exists($ns.'\time')) { continue; } eval(<<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; @@ -193,12 +193,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; } @@ -222,7 +222,7 @@ public static function register($mode = 0) */ private static function hasColorSupport() { - if (!defined('STDOUT')) { + if (!\defined('STDOUT')) { return false; } @@ -231,18 +231,18 @@ private static function hasColorSupport() } if (DIRECTORY_SEPARATOR === '\\') { - return (function_exists('sapi_windows_vt100_support') + 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/TextUI/Command.php b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php index 7f218af9a39f..82d6ab32e03c 100644 --- a/src/Symfony/Bridge/PhpUnit/TextUI/Command.php +++ b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php @@ -38,7 +38,7 @@ protected function handleBootstrap($filename) // By default, we want PHPUnit's autoloader before Symfony's one if (!getenv('SYMFONY_PHPUNIT_OVERLOAD')) { $filename = realpath(stream_resolve_include_path($filename)); - $symfonyLoader = realpath(dirname(PHPUNIT_COMPOSER_INSTALL).'/../../../vendor/autoload.php'); + $symfonyLoader = realpath(\dirname(PHPUNIT_COMPOSER_INSTALL).'/../../../vendor/autoload.php'); if ($filename === $symfonyLoader) { $symfonyLoader = require $symfonyLoader; 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 e749ad40e074..662c274f783f 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -57,7 +57,7 @@ public function getProxyFactoryCode(Definition $definition, $id) if ($definition->isShared()) { $instantiation .= " \$this->services['$id'] ="; - if (defined('Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) { + if (\defined('Symfony\Component\DependencyInjection\ContainerInterface::SCOPE_CONTAINER') && ContainerInterface::SCOPE_CONTAINER !== $scope = $definition->getScope(false)) { $instantiation .= " \$this->scopedServices['$scope']['$id'] ="; } } diff --git a/src/Symfony/Bridge/Twig/AppVariable.php b/src/Symfony/Bridge/Twig/AppVariable.php index dbbee30a471f..cdad4b8ee0f8 100644 --- a/src/Symfony/Bridge/Twig/AppVariable.php +++ b/src/Symfony/Bridge/Twig/AppVariable.php @@ -103,7 +103,7 @@ public function getUser() } $user = $token->getUser(); - if (is_object($user)) { + if (\is_object($user)) { return $user; } } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index b7ba43fa3d34..a9c50db50a7c 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -139,16 +139,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'); @@ -198,8 +198,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 2c312c58e53e..3a0fffca6f27 100644 --- a/src/Symfony/Bridge/Twig/Command/LintCommand.php +++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $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.'); } @@ -184,9 +184,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); @@ -206,7 +206,7 @@ private function displayJson(OutputInterface $output, $filesInfo) } }); - $output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); + $output->writeln(json_encode($filesInfo, \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0)); return min($errors, 1); } @@ -239,7 +239,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/Extension/AssetExtension.php b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php index 40974686adda..271d71ad2bbe 100644 --- a/src/Symfony/Bridge/Twig/Extension/AssetExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/AssetExtension.php @@ -62,13 +62,13 @@ public function getFunctions() public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null) { // BC layer to be removed in 3.0 - if (2 < $count = func_num_args()) { + if (2 < $count = \func_num_args()) { @trigger_error('Generating absolute URLs with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0. Please use absolute_url() instead.', E_USER_DEPRECATED); if (4 === $count) { @trigger_error('Forcing a version with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED); } - $args = func_get_args(); + $args = \func_get_args(); return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null); } diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index e6fc9298fa7d..865befd3ba85 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -33,7 +33,7 @@ class CodeExtension extends AbstractExtension public function __construct($fileLinkFormat, $rootDir, $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; } @@ -92,7 +92,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 ('string' === $item[0]) { $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->charset)); } elseif ('null' === $item[0]) { @@ -105,7 +105,7 @@ public function formatArgs($args) $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->charset), true)); } - $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); + $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); } return implode(', ', $result); @@ -142,7 +142,7 @@ public function fileExcerpt($file, $line) $content = explode('
', $code); $lines = array(); - for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) { + for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) { $lines[] = ''.self::fixCodeMarkup($content[$i - 1]).''; } @@ -166,7 +166,7 @@ public function formatFile($file, $line, $text = null) if (null === $text) { $text = str_replace('/', DIRECTORY_SEPARATOR, $file); if (0 === strpos($text, $this->rootDir)) { - $text = substr($text, strlen($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] : ''); } diff --git a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php index eddd4d7f2afa..70be3e9127d9 100644 --- a/src/Symfony/Bridge/Twig/Extension/DumpExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/DumpExtension.php @@ -56,7 +56,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) { @@ -66,7 +66,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 ab7c6ab626d8..552b39c2b93f 100644 --- a/src/Symfony/Bridge/Twig/Extension/FormExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/FormExtension.php @@ -152,8 +152,8 @@ public function humanize($text) */ public function isSelectedChoice(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..1c1b47bb2be2 100644 --- a/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/HttpFoundationExtension.php @@ -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/RoutingExtension.php b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php index 97b1ea31360c..f347239d0aca 100644 --- a/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/RoutingExtension.php @@ -100,7 +100,7 @@ public function isUrlGenerationSafe(\Twig_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/YamlExtension.php b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php index 894a2fd18901..cb0f9e0fd33e 100644 --- a/src/Symfony/Bridge/Twig/Extension/YamlExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/YamlExtension.php @@ -42,8 +42,8 @@ public function encode($input, $inline = 0, $dumpObjects = false) $dumper = new YamlDumper(); } - if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { - return $dumper->dump($input, $inline, 0, is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0); + if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { + return $dumper->dump($input, $inline, 0, \is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0); } return $dumper->dump($input, $inline, 0, false, $dumpObjects); @@ -51,12 +51,12 @@ public function encode($input, $inline = 0, $dumpObjects = false) 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 d83124e72136..74b2e51b76ad 100644 --- a/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php +++ b/src/Symfony/Bridge/Twig/Form/TwigRendererEngine.php @@ -100,7 +100,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) } @@ -108,7 +108,7 @@ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockNam // Check the default themes once we reach the root view without success if (!$view->parent) { - 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..7b443ffe5fd2 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php @@ -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/Extension/DumpExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php index 36e0e6a08d99..3b6fbfbe3d76 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/DumpExtensionTest.php @@ -75,7 +75,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('