Skip to content

Commit 04654cf

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent f00b327 commit 04654cf

File tree

719 files changed

+2258
-2256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

719 files changed

+2258
-2256
lines changed

.php_cs.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ return PhpCsFixer\Config::create()
1717
'self_accessor' => false,
1818
// TODO remove the disabling once https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876 is merged and released
1919
'native_constant_invocation' => false,
20+
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
21+
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
2022
))
2123
->setRiskyAllowed(true)
2224
->setFinder(

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null)
5454
$initialized = isset($this->initialized[$eventName]);
5555

5656
foreach ($this->listeners[$eventName] as $hash => $listener) {
57-
if (!$initialized && is_string($listener)) {
57+
if (!$initialized && \is_string($listener)) {
5858
$this->listeners[$eventName][$hash] = $listener = $this->container->get($listener);
5959
}
6060

@@ -98,7 +98,7 @@ public function hasListeners($event)
9898
*/
9999
public function addEventListener($events, $listener)
100100
{
101-
if (is_string($listener)) {
101+
if (\is_string($listener)) {
102102
if ($this->initialized) {
103103
throw new \RuntimeException('Adding lazy-loading listeners after construction is not supported.');
104104
}
@@ -124,7 +124,7 @@ public function addEventListener($events, $listener)
124124
*/
125125
public function removeEventListener($events, $listener)
126126
{
127-
if (is_string($listener)) {
127+
if (\is_string($listener)) {
128128
$hash = '_service_'.$listener;
129129
} else {
130130
// Picks the hash code related to that listener

src/Symfony/Bridge/Doctrine/DataCollector/DoctrineDataCollector.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ private function sanitizeQuery($connectionName, $query)
120120
if (null === $query['params']) {
121121
$query['params'] = array();
122122
}
123-
if (!is_array($query['params'])) {
123+
if (!\is_array($query['params'])) {
124124
$query['params'] = array($query['params']);
125125
}
126126
foreach ($query['params'] as $j => $param) {
127127
if (isset($query['types'][$j])) {
128128
// Transform the param according to the type
129129
$type = $query['types'][$j];
130-
if (is_string($type)) {
130+
if (\is_string($type)) {
131131
$type = Type::getType($type);
132132
}
133133
if ($type instanceof Type) {
@@ -158,11 +158,11 @@ private function sanitizeQuery($connectionName, $query)
158158
*/
159159
private function sanitizeParam($var)
160160
{
161-
if (is_object($var)) {
162-
return array(sprintf('Object(%s)', get_class($var)), false);
161+
if (\is_object($var)) {
162+
return array(sprintf('Object(%s)', \get_class($var)), false);
163163
}
164164

165-
if (is_array($var)) {
165+
if (\is_array($var)) {
166166
$a = array();
167167
$original = true;
168168
foreach ($var as $k => $v) {
@@ -174,7 +174,7 @@ private function sanitizeParam($var)
174174
return array($a, $original);
175175
}
176176

177-
if (is_resource($var)) {
177+
if (\is_resource($var)) {
178178
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
179179
}
180180

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function setMappingDriverConfig(array $mappingConfig, $mappingName)
142142
*/
143143
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container)
144144
{
145-
$bundleDir = dirname($bundle->getFileName());
145+
$bundleDir = \dirname($bundle->getFileName());
146146

147147
if (!$bundleConfig['type']) {
148148
$bundleConfig['type'] = $this->detectMetadataDriver($bundleDir, $container);
@@ -154,7 +154,7 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re
154154
}
155155

156156
if (!$bundleConfig['dir']) {
157-
if (in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
157+
if (\in_array($bundleConfig['type'], array('annotation', 'staticphp'))) {
158158
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingObjectDefaultName();
159159
} else {
160160
$bundleConfig['dir'] = $bundleDir.'/'.$this->getMappingResourceConfigDirectory();
@@ -241,7 +241,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, $object
241241
throw new \InvalidArgumentException(sprintf('Specified non-existing directory "%s" as Doctrine mapping source.', $mappingConfig['dir']));
242242
}
243243

244-
if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
244+
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
245245
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
246246
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
247247
'You can register them by adding a new driver to the '.
@@ -264,17 +264,17 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container)
264264
$configPath = $this->getMappingResourceConfigDirectory();
265265
$resource = $dir.'/'.$configPath;
266266
while (!is_dir($resource)) {
267-
$resource = dirname($resource);
267+
$resource = \dirname($resource);
268268
}
269269

270270
$container->addResource(new FileResource($resource));
271271

272272
$extension = $this->getMappingResourceExtension();
273-
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && count($files)) {
273+
if (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.xml')) && \count($files)) {
274274
return 'xml';
275-
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && count($files)) {
275+
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.yml')) && \count($files)) {
276276
return 'yml';
277-
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && count($files)) {
277+
} elseif (($files = glob($dir.'/'.$configPath.'/*.'.$extension.'.php')) && \count($files)) {
278278
return 'php';
279279
}
280280

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi
6060

6161
foreach ($container->getParameter('kernel.bundles') as $bundle) {
6262
$reflection = new \ReflectionClass($bundle);
63-
if (is_file($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
63+
if (is_file($file = \dirname($reflection->getFileName()).'/'.$validationPath)) {
6464
$files[] = $file;
6565
$container->addResource(new FileResource($file));
6666
}

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private function findAndSortTags($tagName, ContainerBuilder $container)
153153

154154
if ($sortedTags) {
155155
krsort($sortedTags);
156-
$sortedTags = call_user_func_array('array_merge', $sortedTags);
156+
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
157157
}
158158

159159
return $sortedTags;

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function __construct($driver, array $namespaces, array $managerParameters
124124
$this->managerParameters = $managerParameters;
125125
$this->driverPattern = $driverPattern;
126126
$this->enabledParameter = $enabledParameter;
127-
if (count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
127+
if (\count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
128128
throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias');
129129
}
130130
$this->configurationPattern = $configurationPattern;
@@ -149,7 +149,7 @@ public function process(ContainerBuilder $container)
149149
$chainDriverDef->addMethodCall('addDriver', array($mappingDriverDef, $namespace));
150150
}
151151

152-
if (!count($this->aliasMap)) {
152+
if (!\count($this->aliasMap)) {
153153
return;
154154
}
155155

src/Symfony/Bridge/Doctrine/Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function loadValuesForChoices(array $choices, $value = null)
8888

8989
// Optimize performance for single-field identifiers. We already
9090
// know that the IDs are used as values
91-
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
91+
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;
9292

9393
// Attention: This optimization does not check choices for existence
9494
if ($optimize && !$this->choiceList && $this->idReader->isSingleId()) {
@@ -125,7 +125,7 @@ public function loadChoicesForValues(array $values, $value = null)
125125

126126
// Optimize performance in case we have an object loader and
127127
// a single-field identifier
128-
$optimize = null === $value || is_array($value) && $value[0] === $this->idReader;
128+
$optimize = null === $value || \is_array($value) && $value[0] === $this->idReader;
129129

130130
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
131131
$unorderedObjects = $this->objectLoader->getEntitiesByIds($this->idReader->getIdField(), $values);

src/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function __construct(ObjectManager $manager, $class, $labelPath = null, E
117117
$this->entityLoader = $entityLoader;
118118
$this->classMetadata = $manager->getClassMetadata($class);
119119
$this->class = $this->classMetadata->getName();
120-
$this->loaded = is_array($entities) || $entities instanceof \Traversable;
120+
$this->loaded = \is_array($entities) || $entities instanceof \Traversable;
121121
$this->preferredEntities = $preferredEntities;
122122
list(
123123
$this->idAsIndex,
@@ -449,13 +449,13 @@ private function getIdentifierInfoForClass(ClassMetadata $classMetadata)
449449

450450
$identifiers = $classMetadata->getIdentifierFieldNames();
451451

452-
if (1 === count($identifiers)) {
452+
if (1 === \count($identifiers)) {
453453
$identifier = $identifiers[0];
454454

455455
if (!$classMetadata->hasAssociation($identifier)) {
456456
$idAsValue = true;
457457

458-
if (in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
458+
if (\in_array($classMetadata->getTypeOfField($identifier), array('integer', 'smallint', 'bigint'))) {
459459
$idAsIndex = true;
460460
}
461461
}

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
4242

4343
$this->om = $om;
4444
$this->classMetadata = $classMetadata;
45-
$this->singleId = 1 === count($ids);
46-
$this->intId = $this->singleId && in_array($idType, array('integer', 'smallint', 'bigint'));
45+
$this->singleId = 1 === \count($ids);
46+
$this->intId = $this->singleId && \in_array($idType, array('integer', 'smallint', 'bigint'));
4747
$this->idField = current($ids);
4848

4949
// single field association are resolved, since the schema column could be an int
@@ -95,7 +95,7 @@ public function getIdValue($object)
9595
}
9696

9797
if (!$this->om->contains($object)) {
98-
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)));
98+
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)));
9999
}
100100

101101
$this->om->initializeObject($object);

0 commit comments

Comments
 (0)