diff --git a/src/Symfony/Bridge/PhpUnit/CHANGELOG.md b/src/Symfony/Bridge/PhpUnit/CHANGELOG.md index 2808ad0c5090..a8a4e2df4340 100644 --- a/src/Symfony/Bridge/PhpUnit/CHANGELOG.md +++ b/src/Symfony/Bridge/PhpUnit/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +5.3.0 +----- + + * bumped the minimum PHP version to 7.1.3 + * bumped the minimum PHPUnit version to 7.5 + 5.1.0 ----- diff --git a/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php b/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php index e8ca4ac9402a..824ef33688d8 100644 --- a/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClassExistsMock.php @@ -45,7 +45,7 @@ public static function trait_exists($name, $autoload = true) public static function register($class) { - $self = \get_called_class(); + $self = static::class; $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { diff --git a/src/Symfony/Bridge/PhpUnit/ClockMock.php b/src/Symfony/Bridge/PhpUnit/ClockMock.php index 2cc834cd4f67..7280d44dc16f 100644 --- a/src/Symfony/Bridge/PhpUnit/ClockMock.php +++ b/src/Symfony/Bridge/PhpUnit/ClockMock.php @@ -92,7 +92,7 @@ public static function gmdate($format, $timestamp = null) public static function register($class) { - $self = \get_called_class(); + $self = static::class; $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { diff --git a/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php b/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php index 446dbf2f4fe0..478eee187c67 100644 --- a/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php +++ b/src/Symfony/Bridge/PhpUnit/ConstraintTrait.php @@ -15,12 +15,7 @@ use ReflectionClass; $r = new ReflectionClass(Constraint::class); -if (\PHP_VERSION_ID < 70000 || !$r->getMethod('matches')->hasReturnType()) { - trait ConstraintTrait - { - use Legacy\ConstraintTraitForV6; - } -} elseif ($r->getProperty('exporter')->isProtected()) { +if ($r->getProperty('exporter')->isProtected()) { trait ConstraintTrait { use Legacy\ConstraintTraitForV7; diff --git a/src/Symfony/Bridge/PhpUnit/CoverageListener.php b/src/Symfony/Bridge/PhpUnit/CoverageListener.php index 805f9222a50d..5dd29a9cbb71 100644 --- a/src/Symfony/Bridge/PhpUnit/CoverageListener.php +++ b/src/Symfony/Bridge/PhpUnit/CoverageListener.php @@ -11,13 +11,7 @@ namespace Symfony\Bridge\PhpUnit; -if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV5', 'Symfony\Bridge\PhpUnit\CoverageListener'); -} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV6', 'Symfony\Bridge\PhpUnit\CoverageListener'); -} else { - class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV7', 'Symfony\Bridge\PhpUnit\CoverageListener'); -} +class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV7', 'Symfony\Bridge\PhpUnit\CoverageListener'); if (false) { class CoverageListener diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 66378170903c..7b7b038fc5dc 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -25,9 +25,9 @@ */ class DeprecationErrorHandler { - const MODE_DISABLED = 'disabled'; - const MODE_WEAK = 'max[total]=999999&verbose=0'; - const MODE_STRICT = 'max[total]=0'; + public const MODE_DISABLED = 'disabled'; + public const MODE_WEAK = 'max[total]=999999&verbose=0'; + public const MODE_STRICT = 'max[total]=0'; private $mode; private $configuration; @@ -238,13 +238,7 @@ private function getConfiguration() return $this->configuration; } if (false === $mode = $this->mode) { - if (isset($_SERVER['SYMFONY_DEPRECATIONS_HELPER'])) { - $mode = $_SERVER['SYMFONY_DEPRECATIONS_HELPER']; - } elseif (isset($_ENV['SYMFONY_DEPRECATIONS_HELPER'])) { - $mode = $_ENV['SYMFONY_DEPRECATIONS_HELPER']; - } else { - $mode = getenv('SYMFONY_DEPRECATIONS_HELPER'); - } + $mode = $_SERVER['SYMFONY_DEPRECATIONS_HELPER'] ?? $_ENV['SYMFONY_DEPRECATIONS_HELPER'] ?? getenv('SYMFONY_DEPRECATIONS_HELPER'); } if ('strict' === $mode) { return $this->configuration = Configuration::inStrictMode(); diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php index 20ffd9651b8e..95b64369714b 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Configuration.php @@ -278,7 +278,7 @@ public static function fromUrlEncodedString($serializedConfiguration) } return new self( - isset($normalizedConfiguration['max']) ? $normalizedConfiguration['max'] : [], + $normalizedConfiguration['max'] ?? [], '', $verboseOutput, filter_var($normalizedConfiguration['generateBaseline'], \FILTER_VALIDATE_BOOLEAN), diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index 72991c75ea50..2eed1c330541 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -21,14 +21,14 @@ */ class Deprecation { - const PATH_TYPE_VENDOR = 'path_type_vendor'; - const PATH_TYPE_SELF = 'path_type_internal'; - const PATH_TYPE_UNDETERMINED = 'path_type_undetermined'; + public const PATH_TYPE_VENDOR = 'path_type_vendor'; + public const PATH_TYPE_SELF = 'path_type_internal'; + public const PATH_TYPE_UNDETERMINED = 'path_type_undetermined'; - const TYPE_SELF = 'type_self'; - const TYPE_DIRECT = 'type_direct'; - const TYPE_INDIRECT = 'type_indirect'; - const TYPE_UNDETERMINED = 'type_undetermined'; + public const TYPE_SELF = 'type_self'; + public const TYPE_DIRECT = 'type_direct'; + public const TYPE_INDIRECT = 'type_indirect'; + public const TYPE_UNDETERMINED = 'type_undetermined'; private $trace = []; private $message; @@ -61,10 +61,10 @@ public function __construct($message, array $trace, $file) $this->trace = $trace; - if ('trigger_error' === (isset($trace[1]['function']) ? $trace[1]['function'] : null) - && (DebugClassLoader::class === ($class = (isset($trace[2]['class']) ? $trace[2]['class'] : null)) || LegacyDebugClassLoader::class === $class) - && 'checkClass' === (isset($trace[2]['function']) ? $trace[2]['function'] : null) - && null !== ($extraFile = (isset($trace[2]['args'][1]) ? $trace[2]['args'][1] : null)) + if ('trigger_error' === ($trace[1]['function'] ?? null) + && (DebugClassLoader::class === ($class = $trace[2]['class'] ?? null) || LegacyDebugClassLoader::class === $class) + && 'checkClass' === ($trace[2]['function'] ?? null) + && null !== ($extraFile = $trace[2]['args'][1] ?? null) && '' !== $extraFile && false !== $extraFile = realpath($extraFile) ) { @@ -118,7 +118,7 @@ private function lineShouldBeSkipped(array $line) } $class = $line['class']; - return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit_') || 0 === strpos($class, 'PHPUnit\\'); + return 'ReflectionMethod' === $class || 0 === strpos($class, 'PHPUnit\\'); } /** @@ -290,7 +290,7 @@ private static function getVendors() foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { self::$vendors[] = $v; $loader = require $v.'/autoload.php'; diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/DeprecationGroup.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/DeprecationGroup.php index f2b0323135dd..6ad2b84ea3fd 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/DeprecationGroup.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/DeprecationGroup.php @@ -55,11 +55,7 @@ public function addNotice() */ private function deprecationNotice($message) { - if (!isset($this->deprecationNotices[$message])) { - $this->deprecationNotices[$message] = new DeprecationNotice(); - } - - return $this->deprecationNotices[$message]; + return $this->deprecationNotices[$message] ?? $this->deprecationNotices[$message] = new DeprecationNotice(); } public function count() diff --git a/src/Symfony/Bridge/PhpUnit/DnsMock.php b/src/Symfony/Bridge/PhpUnit/DnsMock.php index 1e2f55b371be..642da0a6dfcd 100644 --- a/src/Symfony/Bridge/PhpUnit/DnsMock.php +++ b/src/Symfony/Bridge/PhpUnit/DnsMock.php @@ -152,7 +152,7 @@ public static function dns_get_record($hostname, $type = \DNS_ANY, &$authns = nu $records = []; foreach (self::$hosts[$hostname] as $record) { - if (isset(self::$dnsTypes[$record['type']]) && (self::$dnsTypes[$record['type']] & $type)) { + if ((self::$dnsTypes[$record['type']] ?? 0) & $type) { $records[] = array_merge(['host' => $hostname, 'class' => 'IN', 'ttl' => 1, 'type' => $record['type']], $record); } } @@ -163,7 +163,7 @@ public static function dns_get_record($hostname, $type = \DNS_ANY, &$authns = nu public static function register($class) { - $self = \get_called_class(); + $self = static::class; $mockedNs = [substr($class, 0, strrpos($class, '\\'))]; if (0 < strpos($class, '\\Tests\\')) { diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php deleted file mode 100644 index 2ce390df3860..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -/** - * {@inheritdoc} - * - * @internal - */ -class CommandForV5 extends \PHPUnit_TextUI_Command -{ - /** - * {@inheritdoc} - */ - protected function createRunner() - { - $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : []; - - $registeredLocally = false; - - foreach ($this->arguments['listeners'] as $registeredListener) { - if ($registeredListener instanceof SymfonyTestsListenerForV5) { - $registeredListener->globalListenerDisabled(); - $registeredLocally = true; - break; - } - } - - if (isset($this->arguments['configuration'])) { - $configuration = $this->arguments['configuration']; - if (!$configuration instanceof \PHPUnit_Util_Configuration) { - $configuration = \PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']); - } - foreach ($configuration->getListenerConfiguration() as $registeredListener) { - if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener' === ltrim($registeredListener['class'], '\\')) { - $registeredLocally = true; - break; - } - } - } - - if (!$registeredLocally) { - $this->arguments['listeners'][] = new SymfonyTestsListenerForV5(); - } - - return parent::createRunner(); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV7.php similarity index 91% rename from src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php rename to src/Symfony/Bridge/PhpUnit/Legacy/CommandForV7.php index 93e1ad975b7e..fcf5c4505d3d 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV7.php @@ -21,14 +21,14 @@ * * @internal */ -class CommandForV6 extends BaseCommand +class CommandForV7 extends BaseCommand { /** * {@inheritdoc} */ protected function createRunner(): BaseRunner { - $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : []; + $this->arguments['listeners'] ?? $this->arguments['listeners'] = []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV9.php b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV9.php index 2511380257fd..351f02f2230e 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV9.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/CommandForV9.php @@ -31,7 +31,7 @@ class CommandForV9 extends BaseCommand */ protected function createRunner(): BaseRunner { - $this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : []; + $this->arguments['listeners'] ?? $this->arguments['listeners'] = []; $registeredLocally = false; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/ConstraintTraitForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/ConstraintTraitForV6.php deleted file mode 100644 index 53819e4b3c4d..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/ConstraintTraitForV6.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -use SebastianBergmann\Exporter\Exporter; - -/** - * @internal - */ -trait ConstraintTraitForV6 -{ - /** - * @return bool|null - */ - public function evaluate($other, $description = '', $returnResult = false) - { - return $this->doEvaluate($other, $description, $returnResult); - } - - /** - * @return int - */ - public function count() - { - return $this->doCount(); - } - - /** - * @return string - */ - public function toString() - { - return $this->doToString(); - } - - /** - * @param mixed $other - * - * @return string - */ - protected function additionalFailureDescription($other) - { - return $this->doAdditionalFailureDescription($other); - } - - /** - * @return Exporter - */ - protected function exporter() - { - if (null === $this->exporter) { - $this->exporter = new Exporter(); - } - - return $this->exporter; - } - - /** - * @param mixed $other - * - * @return string - */ - protected function failureDescription($other) - { - return $this->doFailureDescription($other); - } - - /** - * @param mixed $other - * - * @return bool - */ - protected function matches($other) - { - return $this->doMatches($other); - } - - private function doAdditionalFailureDescription($other) - { - return ''; - } - - private function doCount() - { - return 1; - } - - private function doEvaluate($other, $description, $returnResult) - { - $success = false; - - if ($this->matches($other)) { - $success = true; - } - - if ($returnResult) { - return $success; - } - - if (!$success) { - $this->fail($other, $description); - } - - return null; - } - - private function doFailureDescription($other) - { - return $this->exporter()->export($other).' '.$this->toString(); - } - - private function doMatches($other) - { - return false; - } - - private function doToString() - { - return ''; - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php deleted file mode 100644 index 9d754eebc85d..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV5.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -/** - * CoverageListener adds `@covers ` on each test when possible to - * make the code coverage more accurate. - * - * @author Grégoire Pineau - * - * @internal - */ -class CoverageListenerForV5 extends \PHPUnit_Framework_BaseTestListener -{ - private $trait; - - public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) - { - $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); - } - - public function startTest(\PHPUnit_Framework_Test $test) - { - $this->trait->startTest($test); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php deleted file mode 100644 index 1b3ceec161f8..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/CoverageListenerForV6.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -use PHPUnit\Framework\Test; -use PHPUnit\Framework\TestListener; -use PHPUnit\Framework\TestListenerDefaultImplementation; - -/** - * CoverageListener adds `@covers ` on each test when possible to - * make the code coverage more accurate. - * - * @author Grégoire Pineau - * - * @internal - */ -class CoverageListenerForV6 implements TestListener -{ - use TestListenerDefaultImplementation; - - private $trait; - - public function __construct(callable $sutFqcnResolver = null, $warningOnSutNotFound = false) - { - $this->trait = new CoverageListenerTrait($sutFqcnResolver, $warningOnSutNotFound); - } - - public function startTest(Test $test) - { - $this->trait->startTest($test); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SetUpTearDownTraitForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/SetUpTearDownTraitForV5.php deleted file mode 100644 index ca29c2ae49ab..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SetUpTearDownTraitForV5.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -/** - * @internal - */ -trait SetUpTearDownTraitForV5 -{ - /** - * @return void - */ - public static function setUpBeforeClass() - { - self::doSetUpBeforeClass(); - } - - /** - * @return void - */ - public static function tearDownAfterClass() - { - self::doTearDownAfterClass(); - } - - /** - * @return void - */ - protected function setUp() - { - self::doSetUp(); - } - - /** - * @return void - */ - protected function tearDown() - { - self::doTearDown(); - } - - private static function doSetUpBeforeClass() - { - parent::setUpBeforeClass(); - } - - private static function doTearDownAfterClass() - { - parent::tearDownAfterClass(); - } - - private function doSetUp() - { - parent::setUp(); - } - - private function doTearDown() - { - parent::tearDown(); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php deleted file mode 100644 index 9b646dca8dfa..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -/** - * Collects and replays skipped tests. - * - * @author Nicolas Grekas - * - * @internal - */ -class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener -{ - private $trait; - - public function __construct(array $mockedNamespaces = []) - { - $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); - } - - public function globalListenerDisabled() - { - $this->trait->globalListenerDisabled(); - } - - public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) - { - $this->trait->startTestSuite($suite); - } - - public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) - { - $this->trait->addSkippedTest($test, $e, $time); - } - - public function startTest(\PHPUnit_Framework_Test $test) - { - $this->trait->startTest($test); - } - - public function endTest(\PHPUnit_Framework_Test $test, $time) - { - $this->trait->endTest($test, $time); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php deleted file mode 100644 index 8f2f6b5a7ed5..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Legacy; - -use PHPUnit\Framework\BaseTestListener; -use PHPUnit\Framework\Test; -use PHPUnit\Framework\TestSuite; - -/** - * Collects and replays skipped tests. - * - * @author Nicolas Grekas - * - * @internal - */ -class SymfonyTestsListenerForV6 extends BaseTestListener -{ - private $trait; - - public function __construct(array $mockedNamespaces = []) - { - $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); - } - - public function globalListenerDisabled() - { - $this->trait->globalListenerDisabled(); - } - - public function startTestSuite(TestSuite $suite) - { - $this->trait->startTestSuite($suite); - } - - public function addSkippedTest(Test $test, \Exception $e, $time) - { - $this->trait->addSkippedTest($test, $e, $time); - } - - public function startTest(Test $test) - { - $this->trait->startTest($test); - } - - public function endTest(Test $test, $time) - { - $this->trait->endTest($test, $time); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 07046cb9fe45..6c2dcb9b1ef3 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -123,7 +123,7 @@ public function startTestSuite($suite) $suiteName = $suite->getName(); foreach ($suite->tests() as $test) { - if (!($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { + if (!$test instanceof TestCase) { continue; } if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) { @@ -158,7 +158,7 @@ public function startTestSuite($suite) $testSuites = [$suite]; for ($i = 0; isset($testSuites[$i]); ++$i) { foreach ($testSuites[$i]->tests() as $test) { - if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) { + if ($test instanceof TestSuite) { if (!class_exists($test->getName(), false)) { $testSuites[] = $test; continue; @@ -178,11 +178,11 @@ public function startTestSuite($suite) $skipped = []; while ($s = array_shift($suites)) { foreach ($s->tests() as $test) { - if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) { + if ($test instanceof TestSuite) { $suites[] = $test; continue; } - if (($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) + if ($test instanceof TestCase && isset($this->wasSkipped[\get_class($test)][$test->getName()]) ) { $skipped[] = $test; @@ -202,7 +202,7 @@ public function addSkippedTest($test, \Exception $e, $time) public function startTest($test) { - if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { + if (-2 < $this->state && $test instanceof TestCase) { // This event is triggered before the test is re-run in isolation if ($this->willBeIsolated($test)) { $this->runsInSeparateProcess = tempnam(sys_get_temp_dir(), 'deprec'); @@ -280,7 +280,7 @@ public function endTest($test, $time) unlink($this->runsInSeparateProcess); putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); 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]); + $error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => $deprecation[2] ?? null]); if ($deprecation[0]) { // unsilenced on purpose trigger_error($error, \E_USER_DEPRECATED); @@ -312,7 +312,7 @@ public function endTest($test, $time) self::$expectedDeprecations = self::$gatheredDeprecations = []; self::$previousErrorHandler = null; } - if (!$this->runsInSeparateProcess && -2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) { + if (!$this->runsInSeparateProcess && -2 < $this->state && $test instanceof TestCase) { if (\in_array('time-sensitive', $groups, true)) { ClockMock::withClockMock(false); } diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php index d3cd7563bd41..47f0f42afc8f 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php +++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php @@ -11,13 +11,7 @@ namespace Symfony\Bridge\PhpUnit; -if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); -} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); -} else { - class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); -} +class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); if (false) { class SymfonyTestsListener diff --git a/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php b/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php deleted file mode 100644 index d1811575087d..000000000000 --- a/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\PhpUnit\Tests; - -use PHPUnit\Framework\TestCase; - -class BootstrapTest extends TestCase -{ - /** - * @requires PHPUnit < 6.0 - */ - public function testAliasingOfErrorClasses() - { - $this->assertInstanceOf( - \PHPUnit_Framework_Error::class, - new \PHPUnit\Framework\Error\Error('message', 0, __FILE__, __LINE__) - ); - $this->assertInstanceOf( - \PHPUnit_Framework_Error_Deprecated::class, - new \PHPUnit\Framework\Error\Deprecated('message', 0, __FILE__, __LINE__) - ); - $this->assertInstanceOf( - \PHPUnit_Framework_Error_Notice::class, - new \PHPUnit\Framework\Error\Notice('message', 0, __FILE__, __LINE__) - ); - $this->assertInstanceOf( - \PHPUnit_Framework_Error_Warning::class, - new \PHPUnit\Framework\Error\Warning('message', 0, __FILE__, __LINE__) - ); - } -} diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php index 5c2f28264037..c78b821e6d9b 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php @@ -33,7 +33,7 @@ private static function getVendorDir() foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $vendorDir = \dirname(\dirname($r->getFileName())); + $vendorDir = \dirname($r->getFileName(), 2); if (file_exists($vendorDir.'/composer/installed.json') && @mkdir($vendorDir.'/myfakevendor/myfakepackage1', 0777, true)) { break; } @@ -61,7 +61,7 @@ public function testItCanTellWhetherItIsInternal() { $r = new \ReflectionClass(Deprecation::class); - if (\dirname(\dirname($r->getFileName())) !== \dirname(\dirname(__DIR__))) { + if (\dirname($r->getFileName(), 2) !== \dirname(__DIR__, 2)) { $this->markTestSkipped('Test case is not compatible with having the bridge in vendor/'); } @@ -266,7 +266,7 @@ private static function doSetupBeforeClass() foreach (get_declared_classes() as $class) { if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); - $v = \dirname(\dirname($r->getFileName())); + $v = \dirname($r->getFileName(), 2); if (file_exists($v.'/composer/installed.json')) { $loader = require $v.'/autoload.php'; $reflection = new \ReflectionClass($loader); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/bootstrap.php b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/bootstrap.php index 3e45381dce2a..6d78d06f6b3a 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/Fixtures/coverage/tests/bootstrap.php @@ -13,13 +13,5 @@ require __DIR__.'/../src/FooCov.php'; require __DIR__.'/../../../../Legacy/CoverageListenerTrait.php'; - -if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) { - require_once __DIR__.'/../../../../Legacy/CoverageListenerForV5.php'; -} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { - require_once __DIR__.'/../../../../Legacy/CoverageListenerForV6.php'; -} else { - require_once __DIR__.'/../../../../Legacy/CoverageListenerForV7.php'; -} - +require_once __DIR__.'/../../../../Legacy/CoverageListenerForV7.php'; require __DIR__.'/../../../../CoverageListener.php'; diff --git a/src/Symfony/Bridge/PhpUnit/TextUI/Command.php b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php index 8690812b56b5..3cc158f6b8e7 100644 --- a/src/Symfony/Bridge/PhpUnit/TextUI/Command.php +++ b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php @@ -11,10 +11,8 @@ namespace Symfony\Bridge\PhpUnit\TextUI; -if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command'); -} elseif (version_compare(\PHPUnit\Runner\Version::id(), '9.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command'); +if (version_compare(\PHPUnit\Runner\Version::id(), '9.0.0', '<')) { + class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV7', 'Symfony\Bridge\PhpUnit\TextUI\Command'); } else { class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV9', 'Symfony\Bridge\PhpUnit\TextUI\Command'); } diff --git a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php index b8940368308a..76c1291fe7a8 100644 --- a/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php +++ b/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php @@ -15,8 +15,8 @@ error_reporting(-1); global $argv, $argc; -$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : []; -$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0; +$argv = $_SERVER['argv'] ?? []; +$argc = $_SERVER['argc'] ?? 0; $getEnvVar = function ($name, $default = false) use ($argv) { if (false !== $value = getenv($name)) { return $value; @@ -98,19 +98,9 @@ $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.4'); } elseif (\PHP_VERSION_ID >= 70200) { // PHPUnit 8 requires PHP 7.2+ - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3'); -} elseif (\PHP_VERSION_ID >= 70100) { - // PHPUnit 7 requires PHP 7.1+ - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5'); -} elseif (\PHP_VERSION_ID >= 70000) { - // PHPUnit 6 requires PHP 7.0+ - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5'); -} elseif (\PHP_VERSION_ID >= 50600) { - // PHPUnit 4 does not support PHP 7 - $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7'); + $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.5'); } else { - // PHPUnit 5.1 requires PHP 5.6+ - $PHPUNIT_VERSION = '4.8'; + $PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5'); } $MAX_PHPUNIT_VERSION = $getEnvVar('SYMFONY_MAX_PHPUNIT_VERSION', false); @@ -255,12 +245,12 @@ if ($PHPUNIT_REMOVE_RETURN_TYPEHINT) { $alteredCode = preg_replace('/^ ((?:protected|public)(?: static)? function \w+\(\)): void/m', ' $1', $alteredCode); } - $alteredCode = preg_replace('/abstract class (?:TestCase|PHPUnit_Framework_TestCase)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); + $alteredCode = preg_replace('/abstract class TestCase[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillTestCaseTrait;", $alteredCode, 1); file_put_contents($alteredFile, $alteredCode); // Mutate Assert code $alteredCode = file_get_contents($alteredFile = './src/Framework/Assert.php'); - $alteredCode = preg_replace('/abstract class (?:Assert|PHPUnit_Framework_Assert)[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); + $alteredCode = preg_replace('/abstract class Assert[^\{]+\{/', '$0 '.\PHP_EOL." use \Symfony\Bridge\PhpUnit\Legacy\PolyfillAssertTrait;", $alteredCode, 1); file_put_contents($alteredFile, $alteredCode); file_put_contents('phpunit', <<<'EOPHP' @@ -352,7 +342,7 @@ class_exists('SymfonyExcludeListSimplePhpunit', false) && PHPUnit\Util\Blacklist } if ($components) { - $skippedTests = isset($_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS']) ? $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] : false; + $skippedTests = $_SERVER['SYMFONY_PHPUNIT_SKIPPED_TESTS'] ?? false; $runningProcs = []; foreach ($components as $component) { diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 2b6f2bac6cdf..9d425b741a5a 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -12,96 +12,6 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; -if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { - $classes = [ - 'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class - 'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class - 'PHPUnit_Framework_BaseTestListener', // override PhpUnit's ForwardCompat child class - - 'PHPUnit_Framework_Constraint', - 'PHPUnit_Framework_Constraint_ArrayHasKey', - 'PHPUnit_Framework_Constraint_ArraySubset', - 'PHPUnit_Framework_Constraint_Attribute', - 'PHPUnit_Framework_Constraint_Callback', - 'PHPUnit_Framework_Constraint_ClassHasAttribute', - 'PHPUnit_Framework_Constraint_ClassHasStaticAttribute', - 'PHPUnit_Framework_Constraint_Composite', - 'PHPUnit_Framework_Constraint_Count', - 'PHPUnit_Framework_Constraint_Exception', - 'PHPUnit_Framework_Constraint_ExceptionCode', - 'PHPUnit_Framework_Constraint_ExceptionMessage', - 'PHPUnit_Framework_Constraint_ExceptionMessageRegExp', - 'PHPUnit_Framework_Constraint_FileExists', - 'PHPUnit_Framework_Constraint_GreaterThan', - 'PHPUnit_Framework_Constraint_IsAnything', - 'PHPUnit_Framework_Constraint_IsEmpty', - 'PHPUnit_Framework_Constraint_IsEqual', - 'PHPUnit_Framework_Constraint_IsFalse', - 'PHPUnit_Framework_Constraint_IsIdentical', - 'PHPUnit_Framework_Constraint_IsInstanceOf', - 'PHPUnit_Framework_Constraint_IsJson', - 'PHPUnit_Framework_Constraint_IsNull', - 'PHPUnit_Framework_Constraint_IsTrue', - 'PHPUnit_Framework_Constraint_IsType', - 'PHPUnit_Framework_Constraint_JsonMatches', - 'PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider', - 'PHPUnit_Framework_Constraint_LessThan', - 'PHPUnit_Framework_Constraint_ObjectHasAttribute', - 'PHPUnit_Framework_Constraint_PCREMatch', - 'PHPUnit_Framework_Constraint_SameSize', - 'PHPUnit_Framework_Constraint_StringContains', - 'PHPUnit_Framework_Constraint_StringEndsWith', - 'PHPUnit_Framework_Constraint_StringMatches', - 'PHPUnit_Framework_Constraint_StringStartsWith', - 'PHPUnit_Framework_Constraint_TraversableContains', - 'PHPUnit_Framework_Constraint_TraversableContainsOnly', - - 'PHPUnit_Framework_Error_Deprecated', - 'PHPUnit_Framework_Error_Notice', - 'PHPUnit_Framework_Error_Warning', - 'PHPUnit_Framework_Exception', - 'PHPUnit_Framework_ExpectationFailedException', - - 'PHPUnit_Framework_MockObject_MockObject', - - 'PHPUnit_Framework_IncompleteTest', - 'PHPUnit_Framework_IncompleteTestCase', - 'PHPUnit_Framework_IncompleteTestError', - 'PHPUnit_Framework_RiskyTest', - 'PHPUnit_Framework_RiskyTestError', - 'PHPUnit_Framework_SkippedTest', - 'PHPUnit_Framework_SkippedTestCase', - 'PHPUnit_Framework_SkippedTestError', - 'PHPUnit_Framework_SkippedTestSuiteError', - - 'PHPUnit_Framework_SyntheticError', - - 'PHPUnit_Framework_Test', - 'PHPUnit_Framework_TestCase', // override PhpUnit's ForwardCompat child class - 'PHPUnit_Framework_TestFailure', - 'PHPUnit_Framework_TestListener', - 'PHPUnit_Framework_TestResult', - 'PHPUnit_Framework_TestSuite', // override PhpUnit's ForwardCompat child class - - 'PHPUnit_Runner_BaseTestRunner', - 'PHPUnit_Runner_Version', - - 'PHPUnit_Util_Blacklist', - 'PHPUnit_Util_ErrorHandler', - 'PHPUnit_Util_Test', - 'PHPUnit_Util_XML', - ]; - foreach ($classes as $class) { - class_alias($class, '\\'.strtr($class, '_', '\\')); - } - - class_alias('PHPUnit_Framework_Constraint_And', 'PHPUnit\Framework\Constraint\LogicalAnd'); - class_alias('PHPUnit_Framework_Constraint_Not', 'PHPUnit\Framework\Constraint\LogicalNot'); - class_alias('PHPUnit_Framework_Constraint_Or', 'PHPUnit\Framework\Constraint\LogicalOr'); - class_alias('PHPUnit_Framework_Constraint_Xor', 'PHPUnit\Framework\Constraint\LogicalXor'); - class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error'); -} - // Detect if we need to serialize deprecations to a file. if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { DeprecationErrorHandler::collectDeprecations($file); @@ -110,7 +20,7 @@ class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error'); } // Detect if we're loaded by an actual run of phpunit -if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { +if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit\TextUI\Command', false)) { return; } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 9f710b2dddf2..9095e1a46cba 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -16,9 +16,9 @@ } ], "require": { - "php": ">=5.5.9 EVEN ON LATEST SYMFONY VERSIONS TO ALLOW USING", + "php": ">=7.1.3 EVEN ON LATEST SYMFONY VERSIONS TO ALLOW USING", "php": "THIS BRIDGE WHEN TESTING LOWEST SYMFONY VERSIONS.", - "php": ">=5.5.9" + "php": ">=7.1.3" }, "require-dev": { "symfony/deprecation-contracts": "^2.1", @@ -28,7 +28,7 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0|<6.4,>=6.0|9.1.2" + "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { "files": [ "bootstrap.php" ], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy