Update composer installed packages

This commit is contained in:
Clemens Schwaighofer
2022-09-06 11:16:33 +09:00
parent 4b3fbaa309
commit a8e75d158b
285 changed files with 1916 additions and 25069 deletions

View File

@@ -2,6 +2,23 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [9.2.17] - 2022-08-30
### Changed
* [#928](https://github.com/sebastianbergmann/php-code-coverage/pull/928): Avoid unnecessary `is_file()` calls
* [#931](https://github.com/sebastianbergmann/php-code-coverage/pull/931): Use MD5 instead of CRC32 for static analysis cache file identifier
### Fixed
* [#926](https://github.com/sebastianbergmann/php-code-coverage/pull/926): Static Analysis cache does not work with `open_basedir`
## [9.2.16] - 2022-08-20
### Fixed
* [#926](https://github.com/sebastianbergmann/php-code-coverage/issues/926): File view has wrong colouring for the first column
## [9.2.15] - 2022-03-07
### Fixed
@@ -398,6 +415,8 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 7.1
[9.2.17]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.16...9.2.17
[9.2.16]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.15...9.2.16
[9.2.15]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.14...9.2.15
[9.2.14]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.13...9.2.14
[9.2.13]: https://github.com/sebastianbergmann/php-code-coverage/compare/c011a0b6aaa4acd2f39b7f51fb4ad4442b6ec631...9.2.13

View File

@@ -32,7 +32,7 @@
"ext-dom": "*",
"ext-libxml": "*",
"ext-xmlwriter": "*",
"nikic/php-parser": "^4.13.0",
"nikic/php-parser": "^4.14",
"phpunit/php-file-iterator": "^3.0.3",
"phpunit/php-text-template": "^2.0.2",
"sebastian/code-unit-reverse-lookup": "^2.0.2",

View File

@@ -77,7 +77,7 @@ final class CodeCoverage
private $ignoreDeprecatedCode = false;
/**
* @var PhptTestCase|string|TestCase
* @var null|PhptTestCase|string|TestCase
*/
private $currentId;

View File

@@ -100,11 +100,7 @@ final class Filter
public function isExcluded(string $filename): bool
{
if (!$this->isFile($filename)) {
return true;
}
return !isset($this->files[$filename]);
return !isset($this->files[$filename]) || !$this->isFile($filename);
}
/**

View File

@@ -1,5 +1,5 @@
<tr>
<td class="{{classes_level}}">{{name}}</td>
<td class="{{lines_level}}">{{name}}</td>
<td class="{{lines_level}} big">{{lines_bar}}</td>
<td class="{{lines_level}} small"><div align="right">{{lines_executed_percent}}</div></td>
<td class="{{lines_level}} small"><div align="right">{{lines_number}}</div></td>

View File

@@ -1,5 +1,5 @@
<tr>
<td class="{{classes_level}}">{{name}}</td>
<td class="{{lines_level}}">{{name}}</td>
<td class="{{lines_level}} big">{{lines_bar}}</td>
<td class="{{lines_level}} small"><div align="right">{{lines_executed_percent}}</div></td>
<td class="{{lines_level}} small"><div align="right">{{lines_number}}</div></td>

View File

@@ -1,5 +1,5 @@
<tr>
<td class="{{methods_level}}">{{name}}</td>
<td class="{{lines_level}}">{{name}}</td>
<td class="{{lines_level}} big">{{lines_bar}}</td>
<td class="{{lines_level}} small"><div align="right">{{lines_executed_percent}}</div></td>
<td class="{{lines_level}} small"><div align="right">{{lines_number}}</div></td>

View File

@@ -1,5 +1,5 @@
<tr>
<td class="{{methods_level}}">{{name}}</td>
<td class="{{lines_level}}">{{name}}</td>
<td class="{{lines_level}} big">{{lines_bar}}</td>
<td class="{{lines_level}} small"><div align="right">{{lines_executed_percent}}</div></td>
<td class="{{lines_level}} small"><div align="right">{{lines_number}}</div></td>

View File

@@ -9,15 +9,14 @@
*/
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
use function assert;
use function crc32;
use function file_get_contents;
use function file_put_contents;
use function implode;
use function is_file;
use function md5;
use function serialize;
use GlobIterator;
use SebastianBergmann\CodeCoverage\Util\Filesystem;
use SplFileInfo;
use SebastianBergmann\FileIterator\Facade as FileIteratorFacade;
/**
* @internal This class is not covered by the backward compatibility promise for phpunit/php-code-coverage
@@ -50,10 +49,6 @@ final class CachingFileAnalyser implements FileAnalyser
$this->analyser = $analyser;
$this->directory = $directory;
if (self::$cacheVersion === null) {
$this->calculateCacheVersion();
}
}
public function classesIn(string $filename): array
@@ -165,19 +160,24 @@ final class CachingFileAnalyser implements FileAnalyser
private function cacheFile(string $filename): string
{
return $this->directory . DIRECTORY_SEPARATOR . hash('sha256', $filename . crc32(file_get_contents($filename)) . self::$cacheVersion);
return $this->directory . DIRECTORY_SEPARATOR . md5($filename . "\0" . file_get_contents($filename) . "\0" . self::cacheVersion());
}
private function calculateCacheVersion(): void
private static function cacheVersion(): string
{
$buffer = '';
foreach (new GlobIterator(__DIR__ . '/*.php') as $file) {
assert($file instanceof SplFileInfo);
$buffer .= file_get_contents($file->getPathname());
if (self::$cacheVersion !== null) {
return self::$cacheVersion;
}
self::$cacheVersion = (string) crc32($buffer);
$buffer = [];
foreach ((new FileIteratorFacade)->getFilesAsArray(__DIR__, '.php') as $file) {
$buffer[] = $file;
$buffer[] = file_get_contents($file);
}
self::$cacheVersion = md5(implode("\0", $buffer));
return self::$cacheVersion;
}
}

View File

@@ -22,7 +22,7 @@ final class Version
public static function id(): string
{
if (self::$version === null) {
self::$version = (new VersionId('9.2.15', dirname(__DIR__)))->getVersion();
self::$version = (new VersionId('9.2.17', dirname(__DIR__)))->getVersion();
}
return self::$version;

View File

@@ -2,6 +2,32 @@
All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [8.5.30] - 2022-MM-DD
### Fixed
* [#4913](https://github.com/sebastianbergmann/phpunit/issues/4913): Failed `assert()` should show a backtrace
## [8.5.29] - 2022-08-22
### Changed
* [#5033](https://github.com/sebastianbergmann/phpunit/issues/5033): Do not depend on phpspec/prophecy
## [8.5.28] - 2022-07-29
### Fixed
* [#5015](https://github.com/sebastianbergmann/phpunit/pull/5015): Ukraine banner unreadable on black background
* [#5016](https://github.com/sebastianbergmann/phpunit/issues/5016): PHPUnit 8.5.27 does not work on PHP 7.2.0-7.2.18 and PHP 7.3.0-7.3.5
## [8.5.27] - 2022-06-19
### Fixed
* [#4950](https://github.com/sebastianbergmann/phpunit/issues/4950): False error on `atMost()` invocation rule without call
* [#4962](https://github.com/sebastianbergmann/phpunit/issues/4962): Ukraine banner unreadable on white background
## [8.5.26] - 2022-04-01
### Fixed
@@ -219,6 +245,10 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil
* [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable`
* [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside
[8.5.30]: https://github.com/sebastianbergmann/phpunit/compare/8.5.29...8.5
[8.5.29]: https://github.com/sebastianbergmann/phpunit/compare/8.5.28...8.5.29
[8.5.28]: https://github.com/sebastianbergmann/phpunit/compare/8.5.27...8.5.28
[8.5.27]: https://github.com/sebastianbergmann/phpunit/compare/8.5.26...8.5.27
[8.5.26]: https://github.com/sebastianbergmann/phpunit/compare/8.5.25...8.5.26
[8.5.25]: https://github.com/sebastianbergmann/phpunit/compare/8.5.24...8.5.25
[8.5.24]: https://github.com/sebastianbergmann/phpunit/compare/8.5.23...8.5.24

View File

@@ -2,6 +2,39 @@
All notable changes of the PHPUnit 9.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [9.5.24] - 2022-08-30
### Added
* [#4931](https://github.com/sebastianbergmann/phpunit/issues/4931): Support `null` and `false` as stand-alone types
* [#4955](https://github.com/sebastianbergmann/phpunit/issues/4955): Support `true` as stand-alone type
### Fixed
* [#4913](https://github.com/sebastianbergmann/phpunit/issues/4913): Failed `assert()` should show a backtrace
* [#5012](https://github.com/sebastianbergmann/phpunit/pull/5012): Memory leak in `ExceptionWrapper`
## [9.5.23] - 2022-08-22
### Changed
* [#5033](https://github.com/sebastianbergmann/phpunit/issues/5033): Do not depend on phpspec/prophecy
## [9.5.22] - 2022-08-20
### Fixed
* [#5015](https://github.com/sebastianbergmann/phpunit/pull/5015): Ukraine banner unreadable on black background
* [#5020](https://github.com/sebastianbergmann/phpunit/issues/5020): PHPUnit 9 breaks loading of PSR-0/PEAR style classes
* [#5022](https://github.com/sebastianbergmann/phpunit/issues/5022): `ExcludeList::addDirectory()` does not work correctly
## [9.5.21] - 2022-06-19
### Fixed
* [#4950](https://github.com/sebastianbergmann/phpunit/issues/4950): False error on `atMost()` invocation rule without call
* [#4962](https://github.com/sebastianbergmann/phpunit/issues/4962): Ukraine banner unreadable on white background
## [9.5.20] - 2022-04-01
### Fixed
@@ -157,6 +190,10 @@ All notable changes of the PHPUnit 9.5 release series are documented in this fil
* [#4535](https://github.com/sebastianbergmann/phpunit/issues/4535): `getMockFromWsdl()` does not handle methods that do not have parameters correctly
[9.5.24]: https://github.com/sebastianbergmann/phpunit/compare/9.5.23...9.5.24
[9.5.23]: https://github.com/sebastianbergmann/phpunit/compare/9.5.22...9.5.23
[9.5.22]: https://github.com/sebastianbergmann/phpunit/compare/9.5.21...9.5.22
[9.5.21]: https://github.com/sebastianbergmann/phpunit/compare/9.5.20...9.5.21
[9.5.20]: https://github.com/sebastianbergmann/phpunit/compare/9.5.19...9.5.20
[9.5.19]: https://github.com/sebastianbergmann/phpunit/compare/9.5.18...9.5.19
[9.5.18]: https://github.com/sebastianbergmann/phpunit/compare/9.5.17...9.5.18

View File

@@ -32,7 +32,6 @@
"myclabs/deep-copy": "^1.10.1",
"phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2",
"phpspec/prophecy": "^1.12.1",
"phpunit/php-code-coverage": "^9.2.13",
"phpunit/php-file-iterator": "^3.0.5",
"phpunit/php-invoker": "^3.1.1",
@@ -47,13 +46,9 @@
"sebastian/global-state": "^5.0.1",
"sebastian/object-enumerator": "^4.0.3",
"sebastian/resource-operations": "^3.0.3",
"sebastian/type": "^3.0",
"sebastian/type": "^3.1",
"sebastian/version": "^3.0.2"
},
"require-dev": {
"ext-PDO": "*",
"phpspec/prophecy-phpunit": "^2.0.1"
},
"config": {
"platform": {
"php": "7.3.0"

View File

@@ -279,8 +279,10 @@
</xs:complexType>
<xs:complexType name="testSuiteType">
<xs:sequence>
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="pathGroup"/>
<xs:element name="exclude" type="xs:string"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>

View File

@@ -9,11 +9,13 @@
*/
namespace PHPUnit\Framework;
use const PHP_VERSION_ID;
use function array_keys;
use function get_class;
use function spl_object_hash;
use PHPUnit\Util\Filter;
use Throwable;
use WeakReference;
/**
* Wraps Exceptions thrown by code under test.
@@ -38,6 +40,11 @@ final class ExceptionWrapper extends Exception
*/
protected $previous;
/**
* @var null|WeakReference<Throwable>
*/
private $originalException;
public function __construct(Throwable $t)
{
// PDOException::getCode() is a string.
@@ -109,14 +116,23 @@ final class ExceptionWrapper extends Exception
*/
private function originalException(Throwable $exceptionToStore = null): ?Throwable
{
static $originalExceptions;
// drop once PHP 7.3 support is removed
if (PHP_VERSION_ID < 70400) {
static $originalExceptions;
$instanceId = spl_object_hash($this);
$instanceId = spl_object_hash($this);
if ($exceptionToStore) {
$originalExceptions[$instanceId] = $exceptionToStore;
if ($exceptionToStore) {
$originalExceptions[$instanceId] = $exceptionToStore;
}
return $originalExceptions[$instanceId] ?? null;
}
return $originalExceptions[$instanceId] ?? null;
if ($exceptionToStore) {
$this->originalException = WeakReference::create($exceptionToStore);
}
return $this->originalException !== null ? $this->originalException->get() : null;
}
}

View File

@@ -144,6 +144,10 @@ final class Invocation implements SelfDescribing
return null;
}
if (in_array('true', $types, true)) {
return true;
}
if (in_array('false', $types, true) ||
in_array('bool', $types, true)) {
return false;

View File

@@ -16,6 +16,7 @@ use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount;
use PHPUnit\Framework\MockObject\Rule\AnyParameters;
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
use PHPUnit\Framework\MockObject\Rule\InvokedAtMostCount;
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
use PHPUnit\Framework\MockObject\Rule\MethodName;
use PHPUnit\Framework\MockObject\Rule\ParametersRule;
@@ -225,10 +226,11 @@ final class Matcher
$this->parametersRule = new AnyParameters;
}
$invocationIsAny = $this->invocationRule instanceof AnyInvokedCount;
$invocationIsNever = $this->invocationRule instanceof InvokedCount && $this->invocationRule->isNever();
$invocationIsAny = $this->invocationRule instanceof AnyInvokedCount;
$invocationIsNever = $this->invocationRule instanceof InvokedCount && $this->invocationRule->isNever();
$invocationIsAtMost = $this->invocationRule instanceof InvokedAtMostCount;
if (!$invocationIsAny && !$invocationIsNever) {
if (!$invocationIsAny && !$invocationIsNever && !$invocationIsAtMost) {
$this->parametersRule->verify();
}
} catch (ExpectationFailedException $e) {

View File

@@ -309,7 +309,11 @@ final class MockMethod
}
if ($type !== null) {
if ($typeName !== 'mixed' && $parameter->allowsNull() && !$type instanceof ReflectionIntersectionType && !$type instanceof ReflectionUnionType) {
if ($typeName !== 'mixed' &&
$typeName !== 'null' &&
!$type instanceof ReflectionIntersectionType &&
!$type instanceof ReflectionUnionType &&
$parameter->allowsNull()) {
$nullable = '?';
}

View File

@@ -600,22 +600,22 @@ abstract class TestCase extends Assert implements Reorderable, SelfDescribing, T
case Deprecated::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Deprecated is deprecated and will be removed in PHPUnit 10. Use expectDeprecation() instead.');
break;
break;
case Error::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Error is deprecated and will be removed in PHPUnit 10. Use expectError() instead.');
break;
break;
case Notice::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Notice is deprecated and will be removed in PHPUnit 10. Use expectNotice() instead.');
break;
break;
case WarningError::class:
$this->addWarning('Support for using expectException() with PHPUnit\Framework\Error\Warning is deprecated and will be removed in PHPUnit 10. Use expectWarning() instead.');
break;
break;
}
// @codeCoverageIgnoreEnd
@@ -1954,6 +1954,10 @@ abstract class TestCase extends Assert implements Reorderable, SelfDescribing, T
*/
protected function prophesize(?string $classOrInterface = null): ObjectProphecy
{
if (!class_exists(Prophet::class)) {
throw new Exception('This test uses TestCase::prophesize(), but phpspec/prophecy is not installed. Please run "composer require --dev phpspec/prophecy".');
}
$this->addWarning('PHPUnit\Framework\TestCase::prophesize() is deprecated and will be removed in PHPUnit 10. Please use the trait provided by phpspec/prophecy-phpunit.');
if (is_string($classOrInterface)) {
@@ -2299,7 +2303,6 @@ abstract class TestCase extends Assert implements Reorderable, SelfDescribing, T
$excludeList->addClassNamePrefix('SebastianBergmann\Invoker');
$excludeList->addClassNamePrefix('SebastianBergmann\Template');
$excludeList->addClassNamePrefix('SebastianBergmann\Timer');
$excludeList->addClassNamePrefix('Symfony');
$excludeList->addClassNamePrefix('Doctrine\Instantiator');
$excludeList->addClassNamePrefix('Prophecy');
$excludeList->addStaticAttribute(ComparatorFactory::class, 'instance');

View File

@@ -757,7 +757,9 @@ final class TestResult implements Countable
$e->getMessage(),
$frame['file'] ?? $e->getFile(),
$frame['line'] ?? $e->getLine()
)
),
0,
$e
);
} catch (Warning $e) {
$warning = true;

View File

@@ -38,6 +38,7 @@ use PHPUnit\Runner\BaseTestRunner;
use PHPUnit\Runner\Filter\Factory;
use PHPUnit\Runner\PhptTestCase;
use PHPUnit\Util\FileLoader;
use PHPUnit\Util\Reflection;
use PHPUnit\Util\Test as TestUtil;
use ReflectionClass;
use ReflectionException;
@@ -219,15 +220,7 @@ class TestSuite implements IteratorAggregate, Reorderable, SelfDescribing, Test
return;
}
foreach ($theClass->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() === Assert::class) {
continue;
}
if ($method->getDeclaringClass()->getName() === TestCase::class) {
continue;
}
foreach ((new Reflection)->publicMethodsInTestClass($theClass) as $method) {
if (!TestUtil::isTestMethod($method)) {
continue;
}
@@ -480,7 +473,9 @@ class TestSuite implements IteratorAggregate, Reorderable, SelfDescribing, Test
$this->addTest($method->invoke(null, $className));
}
} elseif ($class->implementsInterface(Test::class)) {
$expectedClassName = $shortName;
// Do we have modern namespacing ('Foo\Bar\WhizBangTest') or old-school namespacing ('Foo_Bar_WhizBangTest')?
$isPsr0 = (!$class->inNamespace()) && (strpos($class->getName(), '_') !== false);
$expectedClassName = $isPsr0 ? $className : $shortName;
if (($pos = strpos($expectedClassName, '.')) !== false) {
$expectedClassName = substr(

View File

@@ -52,11 +52,12 @@ final class StandardTestSuiteLoader implements TestSuiteLoader
}
if (!class_exists($suiteClassName, false)) {
// this block will handle namespaced classes
$offset = 0 - strlen($suiteClassName);
foreach ($loadedClasses as $loadedClass) {
if (stripos(substr($loadedClass, $offset - 1), '\\' . $suiteClassName) === 0) {
// @see https://github.com/sebastianbergmann/phpunit/issues/5020
if (stripos(substr($loadedClass, $offset - 1), '\\' . $suiteClassName) === 0 ||
stripos(substr($loadedClass, $offset - 1), '_' . $suiteClassName) === 0) {
$suiteClassName = $loadedClass;
break;

View File

@@ -41,7 +41,7 @@ final class Version
}
if (self::$version === '') {
self::$version = (new VersionId('9.5.20', dirname(__DIR__, 2)))->getVersion();
self::$version = (new VersionId('9.5.24', dirname(__DIR__, 2)))->getVersion();
}
return self::$version;

View File

@@ -23,6 +23,7 @@ use function sprintf;
use function str_pad;
use function str_repeat;
use function strlen;
use function trim;
use function vsprintf;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
@@ -374,7 +375,7 @@ class DefaultResultPrinter extends Printer implements ResultPrinter
$this->write((string) $e);
while ($e = $e->getPrevious()) {
$this->write("\nCaused by\n" . $e);
$this->write("\nCaused by\n" . trim((string) $e) . "\n");
}
}

View File

@@ -331,8 +331,8 @@ final class TestRunner extends BaseTestRunner
'PHPUnit ' .
Version::id() .
' ' .
Color::colorize('bg-blue', '#StandWith') .
Color::colorize('bg-yellow', 'Ukraine') .
Color::colorize('bg-blue,fg-white', '#StandWith') .
Color::colorize('bg-yellow,fg-black', 'Ukraine') .
"\n"
);
} else {

View File

@@ -45,17 +45,17 @@ final class TestSuiteMapper
$testSuite = new TestSuiteObject($testSuiteConfiguration->name());
$testSuiteEmpty = true;
$exclude = [];
foreach ($testSuiteConfiguration->exclude()->asArray() as $file) {
$exclude[] = $file->path();
}
foreach ($testSuiteConfiguration->directories() as $directory) {
if (!version_compare(PHP_VERSION, $directory->phpVersion(), $directory->phpVersionOperator()->asString())) {
continue;
}
$exclude = [];
foreach ($testSuiteConfiguration->exclude()->asArray() as $file) {
$exclude[] = $file->path();
}
$files = (new Facade)->getFilesAsArray(
$directory->path(),
$directory->suffix(),

View File

@@ -30,7 +30,6 @@ use PhpParser\Parser;
use PHPUnit\Framework\TestCase;
use Prophecy\Prophet;
use ReflectionClass;
use ReflectionException;
use SebastianBergmann\CliParser\Parser as CliParser;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeUnit\CodeUnit;
@@ -51,7 +50,6 @@ use SebastianBergmann\Template\Template;
use SebastianBergmann\Timer\Timer;
use SebastianBergmann\Type\TypeName;
use SebastianBergmann\Version;
use Symfony\Polyfill\Ctype\Ctype;
use TheSeer\Tokenizer\Tokenizer;
use Webmozart\Assert\Assert;
@@ -157,9 +155,6 @@ final class ExcludeList
// sebastian/version
Version::class => 1,
// symfony/polyfill-ctype
Ctype::class => 1,
// theseer/tokenizer
Tokenizer::class => 1,
@@ -170,7 +165,12 @@ final class ExcludeList
/**
* @var string[]
*/
private static $directories;
private static $directories = [];
/**
* @var bool
*/
private static $initialized = false;
public static function addDirectory(string $directory): void
{
@@ -223,39 +223,31 @@ final class ExcludeList
*/
private function initialize(): void
{
if (self::$directories === null) {
self::$directories = [];
foreach (self::EXCLUDED_CLASS_NAMES as $className => $parent) {
if (!class_exists($className)) {
continue;
}
try {
$directory = (new ReflectionClass($className))->getFileName();
// @codeCoverageIgnoreStart
} catch (ReflectionException $e) {
throw new Exception(
$e->getMessage(),
(int) $e->getCode(),
$e
);
}
// @codeCoverageIgnoreEnd
for ($i = 0; $i < $parent; $i++) {
$directory = dirname($directory);
}
self::$directories[] = $directory;
}
// Hide process isolation workaround on Windows.
if (DIRECTORY_SEPARATOR === '\\') {
// tempnam() prefix is limited to first 3 chars.
// @see https://php.net/manual/en/function.tempnam.php
self::$directories[] = sys_get_temp_dir() . '\\PHP';
}
if (self::$initialized) {
return;
}
foreach (self::EXCLUDED_CLASS_NAMES as $className => $parent) {
if (!class_exists($className)) {
continue;
}
$directory = (new ReflectionClass($className))->getFileName();
for ($i = 0; $i < $parent; $i++) {
$directory = dirname($directory);
}
self::$directories[] = $directory;
}
// Hide process isolation workaround on Windows.
if (DIRECTORY_SEPARATOR === '\\') {
// tempnam() prefix is limited to first 3 chars.
// @see https://php.net/manual/en/function.tempnam.php
self::$directories[] = sys_get_temp_dir() . '\\PHP';
}
self::$initialized = true;
}
}

View File

@@ -0,0 +1,63 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Util;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionMethod;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class Reflection
{
/**
* @psalm-return list<ReflectionMethod>
*/
public function publicMethodsInTestClass(ReflectionClass $class): array
{
return $this->filterMethods($class, ReflectionMethod::IS_PUBLIC);
}
/**
* @psalm-return list<ReflectionMethod>
*/
public function methodsInTestClass(ReflectionClass $class): array
{
return $this->filterMethods($class, null);
}
/**
* @psalm-return list<ReflectionMethod>
*/
private function filterMethods(ReflectionClass $class, ?int $filter): array
{
$methods = [];
// PHP <7.3.5 throw error when null is passed
// to ReflectionClass::getMethods() when strict_types is enabled.
$classMethods = $filter === null ? $class->getMethods() : $class->getMethods($filter);
foreach ($classMethods as $method) {
if ($method->getDeclaringClass()->getName() === TestCase::class) {
continue;
}
if ($method->getDeclaringClass()->getName() === Assert::class) {
continue;
}
$methods[] = $method;
}
return $methods;
}
}

View File

@@ -37,7 +37,6 @@ use function strpos;
use function strtolower;
use function trim;
use function version_compare;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\CodeCoverageException;
use PHPUnit\Framework\ExecutionOrderDependency;
use PHPUnit\Framework\InvalidCoversTargetException;
@@ -526,15 +525,7 @@ final class Test
self::$hookMethods[$className] = self::emptyHookMethodsArray();
try {
foreach ((new ReflectionClass($className))->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() === Assert::class) {
continue;
}
if ($method->getDeclaringClass()->getName() === TestCase::class) {
continue;
}
foreach ((new Reflection)->methodsInTestClass(new ReflectionClass($className)) as $method) {
$docBlock = Registry::getInstance()->forMethod($className, $method->getName());
if ($method->isStatic()) {