Skip to content

Commit 447e284

Browse files
Partially revert "DX: PHP CS Fixer - update excluded paths and apply some minor CS"
This partially reverts commit 749ba568b14ec81997f3e284bfe1ff3be352ab88.
1 parent e9c9f0e commit 447e284

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

Diff for: DeprecationErrorHandler.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function collectDeprecations($outputFile)
9696
{
9797
$deprecations = [];
9898
$previousErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations, &$previousErrorHandler) {
99-
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || !str_contains($msg, '" targeting switch is equivalent to "break'))) {
99+
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) {
100100
if ($previousErrorHandler) {
101101
return $previousErrorHandler($type, $msg, $file, $line, $context);
102102
}
@@ -128,7 +128,7 @@ public static function collectDeprecations($outputFile)
128128
*/
129129
public function handleError($type, $msg, $file, $line, $context = [])
130130
{
131-
if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || !str_contains($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
131+
if ((\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type && (\E_WARNING !== $type || false === strpos($msg, '" targeting switch is equivalent to "break'))) || !$this->getConfiguration()->isEnabled()) {
132132
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
133133
}
134134

Diff for: DeprecationErrorHandler/Deprecation.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct($message, array $trace, $file, $languageDeprecation
104104
$this->getOriginalFilesStack();
105105
array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]);
106106

107-
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || (!str_contains($message, '()" will return') && !str_contains($message, 'native return type declaration') && preg_match('/^(?:The|Method) "([^":]++)/', $message, $m))) {
107+
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || (false === strpos($message, '()" will return') && false === strpos($message, 'native return type declaration') && preg_match('/^(?:The|Method) "([^":]++)/', $message, $m))) {
108108
$this->triggeringFile = (new \ReflectionClass($m[1]))->getFileName();
109109
array_unshift($this->originalFilesStack, $this->triggeringFile);
110110
}
@@ -142,7 +142,7 @@ public function __construct($message, array $trace, $file, $languageDeprecation
142142
return;
143143
}
144144

145-
if (!isset($line['class'], $trace[$i - 2]['function']) || !str_starts_with($line['class'], SymfonyTestsListenerFor::class)) {
145+
if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) {
146146
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
147147
$this->originMethod = $line['function'];
148148

@@ -169,7 +169,7 @@ private function lineShouldBeSkipped(array $line)
169169
}
170170
$class = $line['class'];
171171

172-
return 'ReflectionMethod' === $class || str_starts_with($class, 'PHPUnit\\');
172+
return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit\\');
173173
}
174174

175175
/**
@@ -211,7 +211,7 @@ public function originatingClass()
211211

212212
$class = $this->originClass;
213213

214-
return str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class;
214+
return false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class;
215215
}
216216

217217
/**
@@ -246,9 +246,9 @@ public function isLegacy()
246246
$method = $this->originatingMethod();
247247
$groups = class_exists(Groups::class, false) ? [new Groups(), 'groups'] : [Test::class, 'getGroups'];
248248

249-
return str_starts_with($method, 'testLegacy')
250-
|| str_starts_with($method, 'provideLegacy')
251-
|| str_starts_with($method, 'getLegacy')
249+
return 0 === strpos($method, 'testLegacy')
250+
|| 0 === strpos($method, 'provideLegacy')
251+
|| 0 === strpos($method, 'getLegacy')
252252
|| strpos($this->originClass, '\Legacy')
253253
|| \in_array('legacy', $groups($this->originClass, $method), true);
254254
}
@@ -262,10 +262,10 @@ public function isMuted()
262262
return false;
263263
}
264264
if (isset($this->trace[1]['class'])) {
265-
return str_starts_with($this->trace[1]['class'], 'PHPUnit\\');
265+
return 0 === strpos($this->trace[1]['class'], 'PHPUnit\\');
266266
}
267267

268-
return str_contains($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR);
268+
return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR);
269269
}
270270

271271
/**
@@ -340,7 +340,7 @@ private function getPackage($path)
340340
{
341341
$path = realpath($path) ?: $path;
342342
foreach (self::getVendors() as $vendorRoot) {
343-
if (str_starts_with($path, $vendorRoot)) {
343+
if (0 === strpos($path, $vendorRoot)) {
344344
$relativePath = substr($path, \strlen($vendorRoot) + 1);
345345
$vendor = strstr($relativePath, \DIRECTORY_SEPARATOR, true);
346346
if (false === $vendor) {
@@ -366,7 +366,7 @@ private static function getVendors()
366366
self::$vendors[] = \dirname((new \ReflectionClass(DebugClassLoader::class))->getFileName());
367367
}
368368
foreach (get_declared_classes() as $class) {
369-
if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) {
369+
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
370370
$r = new \ReflectionClass($class);
371371
$v = \dirname($r->getFileName(), 2);
372372
if (file_exists($v.'/composer/installed.json')) {
@@ -381,7 +381,7 @@ private static function getVendors()
381381
}
382382
foreach ($paths as $path) {
383383
foreach (self::$vendors as $vendor) {
384-
if (!str_starts_with($path, $vendor)) {
384+
if (0 !== strpos($path, $vendor)) {
385385
self::$internalPaths[] = $path;
386386
}
387387
}
@@ -416,13 +416,13 @@ private function getPathType($path)
416416
return self::PATH_TYPE_UNDETERMINED;
417417
}
418418
foreach (self::getVendors() as $vendor) {
419-
if (str_starts_with($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) {
419+
if (0 === strpos($realPath, $vendor) && false !== strpbrk(substr($realPath, \strlen($vendor), 1), '/'.\DIRECTORY_SEPARATOR)) {
420420
return self::PATH_TYPE_VENDOR;
421421
}
422422
}
423423

424424
foreach (self::$internalPaths as $internalPath) {
425-
if (str_starts_with($realPath, $internalPath)) {
425+
if (0 === strpos($realPath, $internalPath)) {
426426
return self::PATH_TYPE_SELF;
427427
}
428428
}

Diff for: Tests/CoverageListenerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function test()
4343
exec("$php $phpunit -c $dir/phpunit-with-listener.xml.dist $dir/tests/ --coverage-text --colors=never 2> /dev/null", $output);
4444
$output = implode("\n", $output);
4545

46-
if (!str_contains($output, 'FooCov')) {
46+
if (false === strpos($output, 'FooCov')) {
4747
$this->addToAssertionCount(1);
4848
} else {
4949
$this->assertMatchesRegularExpression('/FooCov\n\s*Methods:\s+0.00%[^\n]+Lines:\s+0.00%/', $output);

Diff for: bin/simple-phpunit.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
break;
5858
}
5959
// short option
60-
if (str_starts_with($cliArgument, '-c')) {
60+
if (0 === strpos($cliArgument, '-c')) {
6161
if ('-c' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
6262
$phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
6363
} else {

Diff for: composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"require-dev": {
2424
"symfony/deprecation-contracts": "^2.5|^3.0",
2525
"symfony/error-handler": "^5.4|^6.0|^7.0",
26-
"symfony/polyfill-php80": "^1.27",
2726
"symfony/polyfill-php81": "^1.27"
2827
},
2928
"conflict": {

0 commit comments

Comments
 (0)