diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 6876e3389f..2cc834cd4f 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -94,7 +94,7 @@ class ClockMock { $self = \get_called_class(); - $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); + $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); diff --git a/src/Symfony/Bridge/PhpUnit/DnsMock.php b/src/Symfony/Bridge/PhpUnit/DnsMock.php index 790cfa91af..a58bf2efcd 100644 --- a/src/Symfony/Bridge/PhpUnit/DnsMock.php +++ b/src/Symfony/Bridge/PhpUnit/DnsMock.php @@ -16,8 +16,8 @@ namespace Symfony\Bridge\PhpUnit; */ class DnsMock { - private static $hosts = array(); - private static $dnsTypes = array( + private static $hosts = []; + private static $dnsTypes = [ 'A' => DNS_A, 'MX' => DNS_MX, 'NS' => DNS_NS, @@ -30,7 +30,7 @@ class DnsMock 'NAPTR' => DNS_NAPTR, 'TXT' => DNS_TXT, 'HINFO' => DNS_HINFO, - ); + ]; /** * Configures the mock values for DNS queries. @@ -68,7 +68,7 @@ class DnsMock if (!self::$hosts) { return \getmxrr($hostname, $mxhosts, $weight); } - $mxhosts = $weight = array(); + $mxhosts = $weight = []; if (isset(self::$hosts[$hostname])) { foreach (self::$hosts[$hostname] as $record) { @@ -125,7 +125,7 @@ class DnsMock $ips = false; if (isset(self::$hosts[$hostname])) { - $ips = array(); + $ips = []; foreach (self::$hosts[$hostname] as $record) { if ('A' === $record['type']) { @@ -149,11 +149,11 @@ class DnsMock if (DNS_ANY === $type) { $type = DNS_ALL; } - $records = array(); + $records = []; foreach (self::$hosts[$hostname] as $record) { if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) { - $records[] = array_merge(array('host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']), $record); + $records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record); } } } @@ -165,7 +165,7 @@ class DnsMock { $self = \get_called_class(); - $mockedNs = array(substr($class, 0, strrpos($class, '\\'))); + $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { $ns = str_replace('\\Tests\\', '\\', $class); $mockedNs[] = substr($ns, 0, strrpos($ns, '\\')); diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php index ed4128482f..2ce390df38 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php @@ -23,7 +23,7 @@ class CommandForV5 extends \PHPUnit_TextUI_Command */ protected function createRunner() { - $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : array(); + $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php index 6c42d3bf26..7a64ed0d91 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerTrait.php @@ -32,7 +32,7 @@ class CoverageListenerTrait { $this->sutFqcnResolver = $sutFqcnResolver; $this->warningOnSutNotFound = $warningOnSutNotFound; - $this->warnings = array(); + $this->warnings = []; } public function startTest($test) @@ -43,7 +43,7 @@ class CoverageListenerTrait $annotations = $test->getAnnotations(); - $ignoredAnnotations = array('covers', 'coversDefaultClass', 'coversNothing'); + $ignoredAnnotations = ['covers', 'coversDefaultClass', 'coversNothing']; foreach ($ignoredAnnotations as $annotation) { if (isset($annotations['class'][$annotation]) || isset($annotations['method'][$annotation])) { @@ -70,11 +70,11 @@ class CoverageListenerTrait $r->setAccessible(true); $cache = $r->getValue(); - $cache = array_replace_recursive($cache, array( - \get_class($test) => array( - 'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn), - ), - )); + $cache = array_replace_recursive($cache, [ + \get_class($test) => [ + 'covers' => \is_array($sutFqcn) ? $sutFqcn : [$sutFqcn], + ], + ]); $r->setValue(Test::class, $cache); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php index a760d126ca..9b646dca8d 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php @@ -22,7 +22,7 @@ class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener { private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php index bcab4be4ee..8f2f6b5a7e 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php @@ -14,7 +14,6 @@ namespace Symfony\Bridge\PhpUnit\Legacy; use PHPUnit\Framework\BaseTestListener; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestSuite; -use PHPUnit\Framework\Warning; /** * Collects and replays skipped tests. @@ -27,7 +26,7 @@ class SymfonyTestsListenerForV6 extends BaseTestListener { private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php index 0c2069c66b..15f60a453f 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php @@ -15,7 +15,6 @@ use PHPUnit\Framework\Test; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; use PHPUnit\Framework\TestSuite; -use PHPUnit\Framework\Warning; /** * Collects and replays skipped tests. @@ -30,7 +29,7 @@ class SymfonyTestsListenerForV7 implements TestListener private $trait; - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 05e886506d..1e030825e6 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -35,10 +35,10 @@ class SymfonyTestsListenerTrait private static $globallyEnabled = false; private $state = -1; private $skippedFile = false; - private $wasSkipped = array(); - private $isSkipped = array(); - private $expectedDeprecations = array(); - private $gatheredDeprecations = array(); + private $wasSkipped = []; + private $isSkipped = []; + private $expectedDeprecations = []; + private $gatheredDeprecations = []; private $previousErrorHandler; private $error; private $runsInSeparateProcess = false; @@ -46,7 +46,7 @@ class SymfonyTestsListenerTrait /** * @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive or dns-sensitive) */ - public function __construct(array $mockedNamespaces = array()) + public function __construct(array $mockedNamespaces = []) { Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2; @@ -54,7 +54,7 @@ class SymfonyTestsListenerTrait foreach ($mockedNamespaces as $type => $namespaces) { if (!\is_array($namespaces)) { - $namespaces = array($namespaces); + $namespaces = [$namespaces]; } if ('time-sensitive' === $type) { foreach ($namespaces as $ns) { @@ -140,11 +140,11 @@ class SymfonyTestsListenerTrait if (!$this->wasSkipped = require $this->skippedFile) { echo "All tests already ran successfully.\n"; - $suite->setTests(array()); + $suite->setTests([]); } } } - $testSuites = array($suite); + $testSuites = [$suite]; for ($i = 0; isset($testSuites[$i]); ++$i) { foreach ($testSuites[$i]->tests() as $test) { if ($test instanceof TestSuite) { @@ -163,7 +163,7 @@ class SymfonyTestsListenerTrait } } } elseif (2 === $this->state) { - $skipped = array(); + $skipped = []; foreach ($suite->tests() as $test) { if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase) || isset($this->wasSkipped[$suiteName]['*']) @@ -228,7 +228,7 @@ class SymfonyTestsListenerTrait $test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false); $this->expectedDeprecations = $annotations['method']['expectedDeprecation']; - $this->previousErrorHandler = set_error_handler(array($this, 'handleError')); + $this->previousErrorHandler = set_error_handler([$this, 'handleError']); } } } @@ -251,8 +251,8 @@ class SymfonyTestsListenerTrait $deprecations = file_get_contents($this->runsInSeparateProcess); unlink($this->runsInSeparateProcess); putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); - foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { - $error = serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null)); + foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { + $error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]); if ($deprecation[0]) { // unsilenced on purpose trigger_error($error, E_USER_DEPRECATED); @@ -264,13 +264,13 @@ class SymfonyTestsListenerTrait } if ($this->expectedDeprecations) { - if (!\in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE), true)) { + if (!\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE], true)) { $test->addToAssertionCount(\count($this->expectedDeprecations)); } restore_error_handler(); - if (!$errored && !\in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR), true)) { + if (!$errored && !\in_array($test->getStatus(), [BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR], true)) { try { $prefix = "@expectedDeprecation:\n"; $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); @@ -279,7 +279,7 @@ class SymfonyTestsListenerTrait } } - $this->expectedDeprecations = $this->gatheredDeprecations = array(); + $this->expectedDeprecations = $this->gatheredDeprecations = []; $this->previousErrorHandler = null; } if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) { @@ -287,12 +287,12 @@ class SymfonyTestsListenerTrait ClockMock::withClockMock(false); } if (\in_array('dns-sensitive', $groups, true)) { - DnsMock::withMockedHosts(array()); + DnsMock::withMockedHosts([]); } } } - public function handleError($type, $msg, $file, $line, $context = array()) + public function handleError($type, $msg, $file, $line, $context = []) { if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) { $h = $this->previousErrorHandler; diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index f4b418961c..fd6d059e44 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\PhpUnit\Tests\DeprecationErrorHandler; -use Composer\Autoload\ClassLoader; use PHPUnit\Framework\TestCase; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation; @@ -46,7 +45,6 @@ class DeprecationTest extends TestCase touch($vendorDir.'/myfakevendor/myfakepackage1/MyFakeFile2.php'); touch($vendorDir.'/myfakevendor/myfakepackage2/MyFakeFile.php'); - return self::$vendorDir; } @@ -106,12 +104,12 @@ class DeprecationTest extends TestCase yield 'not from phpunit, and not a whitelisted message' => [ false, \My\Source\Code::class, - 'Self deprecating humor is deprecated by itself' + 'Self deprecating humor is deprecated by itself', ]; yield 'from phpunit, but not a whitelisted message' => [ false, \PHPUnit\Random\Piece\Of\Code::class, - 'Self deprecating humor is deprecated by itself' + 'Self deprecating humor is deprecated by itself', ]; yield 'whitelisted message, but not from phpunit' => [ false, @@ -146,7 +144,7 @@ class DeprecationTest extends TestCase ['file' => 'should_not_matter.php'], ['file' => 'should_not_matter_either.php'], ], - 'random_path' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'phpunit' . \DIRECTORY_SEPARATOR . 'whatever.php' + 'random_path'.\DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR.'whatever.php' ); $this->assertTrue($deprecation->isMuted()); } diff --git a/src/Symfony/Component/Workflow/Event/Event.php b/src/Symfony/Component/Workflow/Event/Event.php index a0bb4c5176..cda6e170be 100644 --- a/src/Symfony/Component/Workflow/Event/Event.php +++ b/src/Symfony/Component/Workflow/Event/Event.php @@ -60,7 +60,7 @@ class Event extends BaseEvent return $this->workflow->getName(); } - public function getMetadata(string $key, object $subject) + public function getMetadata(string $key, $subject) { return $this->workflow->getMetadataStore()->getMetadata($key, $subject); }