Skip to content

Commit e812852

Browse files
Merge branch '4.1'
* 4.1: Fix Clidumper tests Enable the fixer enforcing fully-qualified calls for compiler-optimized functions Apply fixers Disable the native_constant_invocation fixer until it can be scoped Update the list of excluded files for the CS fixer
2 parents 1730b7d + 933b774 commit e812852

File tree

792 files changed

+2510
-2507
lines changed

Some content is hidden

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

792 files changed

+2510
-2507
lines changed

.php_cs.dist

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ return PhpCsFixer\Config::create()
1212
'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
1313
'array_syntax' => array('syntax' => 'long'),
1414
'protected_to_private' => false,
15+
// TODO remove the disabling once https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3876 is merged and released
16+
'native_constant_invocation' => false,
17+
// Part of @Symfony:risky in PHP-CS-Fixer 2.13.0. To be removed from the config file once upgrading
18+
'native_function_invocation' => array('include' => array('@compiler_optimized'), 'scope' => 'namespaced'),
1519
))
1620
->setRiskyAllowed(true)
1721
->setFinder(
@@ -26,21 +30,24 @@ return PhpCsFixer\Config::create()
2630
'Symfony/Component/Routing/Tests/Fixtures/dumper',
2731
// fixture templates
2832
'Symfony/Component/Templating/Tests/Fixtures/templates',
33+
'Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache',
2934
'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom',
3035
// generated fixtures
3136
'Symfony/Component/VarDumper/Tests/Fixtures',
3237
// resource templates
3338
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
39+
// explicit trigger_error tests
40+
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
3441
))
42+
// Support for older PHPunit version
43+
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
3544
// file content autogenerated by `var_export`
3645
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
3746
// test template
3847
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
3948
// explicit heredoc test
4049
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
4150
// explicit trigger_error tests
42-
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt')
43-
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt')
4451
->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
4552
// invalid annotations on purpose
4653
->notPath('Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php')

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
@@ -134,14 +134,14 @@ private function sanitizeQuery($connectionName, $query)
134134
if (null === $query['params']) {
135135
$query['params'] = array();
136136
}
137-
if (!is_array($query['params'])) {
137+
if (!\is_array($query['params'])) {
138138
$query['params'] = array($query['params']);
139139
}
140140
foreach ($query['params'] as $j => $param) {
141141
if (isset($query['types'][$j])) {
142142
// Transform the param according to the type
143143
$type = $query['types'][$j];
144-
if (is_string($type)) {
144+
if (\is_string($type)) {
145145
$type = Type::getType($type);
146146
}
147147
if ($type instanceof Type) {
@@ -168,15 +168,15 @@ private function sanitizeQuery($connectionName, $query)
168168
*/
169169
private function sanitizeParam($var): array
170170
{
171-
if (is_object($var)) {
172-
$className = get_class($var);
171+
if (\is_object($var)) {
172+
$className = \get_class($var);
173173

174174
return method_exists($var, '__toString') ?
175175
array(sprintf('/* Object(%s): */"%s"', $className, $var->__toString()), false) :
176176
array(sprintf('/* Object(%s) */', $className), false);
177177
}
178178

179-
if (is_array($var)) {
179+
if (\is_array($var)) {
180180
$a = array();
181181
$original = true;
182182
foreach ($var as $k => $v) {
@@ -188,7 +188,7 @@ private function sanitizeParam($var): array
188188
return array($a, $original);
189189
}
190190

191-
if (is_resource($var)) {
191+
if (\is_resource($var)) {
192192
return array(sprintf('/* Resource(%s) */', get_resource_type($var)), false);
193193
}
194194

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

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

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

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

243-
if (!in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
243+
if (!\in_array($mappingConfig['type'], array('xml', 'yml', 'annotation', 'php', 'staticphp'))) {
244244
throw new \InvalidArgumentException(sprintf('Can only configure "xml", "yml", "annotation", "php" or '.
245245
'"staticphp" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. '.
246246
'You can register them by adding a new driver to the '.
@@ -272,7 +272,7 @@ protected function detectMetadataDriver($dir, ContainerBuilder $container)
272272
// add the closest existing directory as a resource
273273
$resource = $dir.'/'.$configPath;
274274
while (!is_dir($resource)) {
275-
$resource = dirname($resource);
275+
$resource = \dirname($resource);
276276
}
277277
$container->fileExists($resource, false);
278278

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

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

5353
foreach ($container->getParameter('kernel.bundles') as $bundle) {
5454
$reflection = new \ReflectionClass($bundle);
55-
if ($container->fileExists($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
55+
if ($container->fileExists($file = \dirname($reflection->getFileName()).'/'.$validationPath)) {
5656
$files[] = $file;
5757
}
5858
}

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

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

147147
if ($sortedTags) {
148148
krsort($sortedTags);
149-
$sortedTags = call_user_func_array('array_merge', $sortedTags);
149+
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
150150
}
151151

152152
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
@@ -83,7 +83,7 @@ public function loadValuesForChoices(array $choices, $value = null)
8383

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

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

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

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

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);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ public function getEntitiesByIds($identifier, array $values)
6464
// Guess type
6565
$entity = current($qb->getRootEntities());
6666
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
67-
if (in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
67+
if (\in_array($metadata->getTypeOfField($identifier), array('integer', 'bigint', 'smallint'))) {
6868
$parameterType = Connection::PARAM_INT_ARRAY;
6969

7070
// Filter out non-integer values (e.g. ""). If we don't, some
7171
// databases such as PostgreSQL fail.
7272
$values = array_values(array_filter($values, function ($v) {
7373
return (string) $v === (string) (int) $v || ctype_digit($v);
7474
}));
75-
} elseif (in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
75+
} elseif (\in_array($metadata->getTypeOfField($identifier), array('uuid', 'guid'))) {
7676
$parameterType = Connection::PARAM_STR_ARRAY;
7777

7878
// Like above, but we just filter out empty strings.

0 commit comments

Comments
 (0)