Skip to content

Commit f5939a8

Browse files
Merge branch '2.8' into 3.4
* 2.8: 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 3349ec6 + 82d13da commit f5939a8

File tree

846 files changed

+2712
-2705
lines changed

Some content is hidden

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

846 files changed

+2712
-2705
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(
@@ -24,21 +28,24 @@ return PhpCsFixer\Config::create()
2428
'Symfony/Component/Routing/Tests/Fixtures/dumper',
2529
// fixture templates
2630
'Symfony/Component/Templating/Tests/Fixtures/templates',
31+
'Symfony/Bundle/FrameworkBundle/Tests/Fixtures/TemplatePathsCache',
2732
'Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom',
2833
// generated fixtures
2934
'Symfony/Component/VarDumper/Tests/Fixtures',
3035
// resource templates
3136
'Symfony/Bundle/FrameworkBundle/Resources/views/Form',
37+
// explicit trigger_error tests
38+
'Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/',
3239
))
40+
// Support for older PHPunit version
41+
->notPath('Symfony/Bridge/PhpUnit/SymfonyTestsListener.php')
3342
// file content autogenerated by `var_export`
3443
->notPath('Symfony/Component/Translation/Tests/fixtures/resources.php')
3544
// test template
3645
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/Resources/Custom/_name_entry_label.html.php')
3746
// explicit heredoc test
3847
->notPath('Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php')
3948
// explicit trigger_error tests
40-
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/default.phpt')
41-
->notPath('Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/weak.phpt')
4249
->notPath('Symfony/Component/Debug/Tests/DebugClassLoaderTest.php')
4350
)
4451
;

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) {
@@ -172,15 +172,15 @@ private function sanitizeQuery($connectionName, $query)
172172
*/
173173
private function sanitizeParam($var)
174174
{
175-
if (is_object($var)) {
176-
$className = get_class($var);
175+
if (\is_object($var)) {
176+
$className = \get_class($var);
177177

178178
return method_exists($var, '__toString') ?
179179
array(sprintf('Object(%s): "%s"', $className, $var->__toString()), false) :
180180
array(sprintf('Object(%s)', $className), false);
181181
}
182182

183-
if (is_array($var)) {
183+
if (\is_array($var)) {
184184
$a = array();
185185
$original = true;
186186
foreach ($var as $k => $v) {
@@ -192,7 +192,7 @@ private function sanitizeParam($var)
192192
return array($a, $original);
193193
}
194194

195-
if (is_resource($var)) {
195+
if (\is_resource($var)) {
196196
return array(sprintf('Resource(%s)', get_resource_type($var)), false);
197197
}
198198

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
@@ -59,7 +59,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, $mappi
5959

6060
foreach ($container->getParameter('kernel.bundles') as $bundle) {
6161
$reflection = new \ReflectionClass($bundle);
62-
if ($container->fileExists($file = dirname($reflection->getFileName()).'/'.$validationPath)) {
62+
if ($container->fileExists($file = \dirname($reflection->getFileName()).'/'.$validationPath)) {
6363
$files[] = $file;
6464
}
6565
}

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

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

142142
if ($sortedTags) {
143143
krsort($sortedTags);
144-
$sortedTags = call_user_func_array('array_merge', $sortedTags);
144+
$sortedTags = \call_user_func_array('array_merge', $sortedTags);
145145
}
146146

147147
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
@@ -97,7 +97,7 @@ public function loadValuesForChoices(array $choices, $value = null)
9797

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

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

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

139139
if ($optimize && !$this->choiceList && $this->objectLoader && $this->idReader->isSingleId()) {
140140
$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)