www folder composer updates

This commit is contained in:
Clemens Schwaighofer
2023-08-22 13:04:01 +09:00
parent f29e915068
commit 53192da571
189 changed files with 2850 additions and 2364 deletions

View File

@@ -2,6 +2,17 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [9.2.27] - 2023-07-26
### Changed
* The result of `CodeCoverage::getReport()` is now cached
### Fixed
* Static analysis cache keys do not include configuration settings that affect source code parsing
* The Clover, Cobertura, Crap4j, and PHP report writers no longer create a `php:` directory when they should write to `php://stdout`, for instance
## [9.2.26] - 2023-03-06
### Changed
@@ -476,6 +487,7 @@ 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.27]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.26...9.2.27
[9.2.26]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.25...9.2.26
[9.2.25]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.24...9.2.25
[9.2.24]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.23...9.2.24

View File

@@ -17,7 +17,8 @@
}
],
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues"
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy"
},
"config": {
"platform": {

View File

@@ -114,6 +114,11 @@ final class CodeCoverage
*/
private $cacheDirectory;
/**
* @var ?Directory
*/
private $cachedReport;
public function __construct(Driver $driver, Filter $filter)
{
$this->driver = $driver;
@@ -127,7 +132,11 @@ final class CodeCoverage
*/
public function getReport(): Directory
{
return (new Builder($this->analyser()))->build($this);
if ($this->cachedReport === null) {
$this->cachedReport = (new Builder($this->analyser()))->build($this);
}
return $this->cachedReport;
}
/**
@@ -135,9 +144,10 @@ final class CodeCoverage
*/
public function clear(): void
{
$this->currentId = null;
$this->data = new ProcessedCodeCoverageData;
$this->tests = [];
$this->currentId = null;
$this->data = new ProcessedCodeCoverageData;
$this->tests = [];
$this->cachedReport = null;
}
/**
@@ -202,6 +212,8 @@ final class CodeCoverage
$this->currentId = $id;
$this->driver->start();
$this->cachedReport = null;
}
/**
@@ -220,7 +232,8 @@ final class CodeCoverage
$data = $this->driver->stop();
$this->append($data, null, $append, $linesToBeCovered, $linesToBeUsed);
$this->currentId = null;
$this->currentId = null;
$this->cachedReport = null;
return $data;
}
@@ -245,6 +258,8 @@ final class CodeCoverage
throw new TestIdMissingException;
}
$this->cachedReport = null;
$this->applyFilter($rawData);
$this->applyExecutableLinesFilter($rawData);
@@ -312,6 +327,8 @@ final class CodeCoverage
$this->data->merge($that->data);
$this->tests = array_merge($this->tests, $that->getTests());
$this->cachedReport = null;
}
public function enableCheckForUnintentionallyCoveredCode(): void
@@ -673,7 +690,9 @@ final class CodeCoverage
if ($this->cachesStaticAnalysis()) {
$this->analyser = new CachingFileAnalyser(
$this->cacheDirectory,
$this->analyser
$this->analyser,
$this->useAnnotationsForIgnoringCode,
$this->ignoreDeprecatedCode
);
}

View File

@@ -16,6 +16,7 @@ use function is_string;
use function ksort;
use function max;
use function range;
use function strpos;
use function time;
use DOMDocument;
use SebastianBergmann\CodeCoverage\CodeCoverage;
@@ -243,7 +244,9 @@ final class Clover
$buffer = $xmlDocument->saveXML();
if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}
if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);

View File

@@ -16,6 +16,7 @@ use function file_put_contents;
use function preg_match;
use function range;
use function str_replace;
use function strpos;
use function time;
use DOMImplementation;
use SebastianBergmann\CodeCoverage\CodeCoverage;
@@ -294,7 +295,9 @@ final class Cobertura
$buffer = $document->saveXML();
if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}
if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);

View File

@@ -15,6 +15,7 @@ use function file_put_contents;
use function htmlspecialchars;
use function is_string;
use function round;
use function strpos;
use DOMDocument;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
@@ -124,7 +125,9 @@ final class Crap4j
$buffer = $document->saveXML();
if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}
if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);

View File

@@ -12,6 +12,7 @@ namespace SebastianBergmann\CodeCoverage\Report;
use function dirname;
use function file_put_contents;
use function serialize;
use function strpos;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Driver\WriteOperationFailedException;
use SebastianBergmann\CodeCoverage\Util\Filesystem;
@@ -24,7 +25,9 @@ final class PHP
return \unserialize(<<<'END_OF_COVERAGE_SERIALIZATION'" . PHP_EOL . serialize($coverage) . PHP_EOL . 'END_OF_COVERAGE_SERIALIZATION' . PHP_EOL . ');';
if ($target !== null) {
Filesystem::createDirectory(dirname($target));
if (!strpos($target, '://') !== false) {
Filesystem::createDirectory(dirname($target));
}
if (@file_put_contents($target, $buffer) === false) {
throw new WriteOperationFailedException($target);

View File

@@ -17,7 +17,6 @@ use DOMElement;
final class Tests
{
private $contextNode;
private $codeMap = [
-1 => 'UNKNOWN', // PHPUnit_Runner_BaseTestRunner::STATUS_UNKNOWN
0 => 'PASSED', // PHPUnit_Runner_BaseTestRunner::STATUS_PASSED

View File

@@ -20,7 +20,9 @@ final class CacheWarmer
new ParsingFileAnalyser(
$useAnnotationsForIgnoringCode,
$ignoreDeprecatedCode
)
),
$useAnnotationsForIgnoringCode,
$ignoreDeprecatedCode,
);
foreach ($filter->files() as $file) {

View File

@@ -29,27 +29,39 @@ final class CachingFileAnalyser implements FileAnalyser
*/
private static $cacheVersion;
/**
* @var string
*/
private $directory;
/**
* @var FileAnalyser
*/
private $analyser;
/**
* @var bool
*/
private $useAnnotationsForIgnoringCode;
/**
* @var bool
*/
private $ignoreDeprecatedCode;
/**
* @var array
*/
private $cache = [];
/**
* @var string
*/
private $directory;
public function __construct(string $directory, FileAnalyser $analyser)
public function __construct(string $directory, FileAnalyser $analyser, bool $useAnnotationsForIgnoringCode, bool $ignoreDeprecatedCode)
{
Filesystem::createDirectory($directory);
$this->analyser = $analyser;
$this->directory = $directory;
$this->analyser = $analyser;
$this->directory = $directory;
$this->useAnnotationsForIgnoringCode = $useAnnotationsForIgnoringCode;
$this->ignoreDeprecatedCode = $ignoreDeprecatedCode;
}
public function classesIn(string $filename): array
@@ -161,7 +173,20 @@ final class CachingFileAnalyser implements FileAnalyser
private function cacheFile(string $filename): string
{
return $this->directory . DIRECTORY_SEPARATOR . md5($filename . "\0" . file_get_contents($filename) . "\0" . self::cacheVersion());
$cacheKey = md5(
implode(
"\0",
[
$filename,
file_get_contents($filename),
self::cacheVersion(),
$this->useAnnotationsForIgnoringCode,
$this->ignoreDeprecatedCode,
]
)
);
return $this->directory . DIRECTORY_SEPARATOR . $cacheKey;
}
private static function cacheVersion(): string

View File

@@ -101,6 +101,7 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
$node instanceof Node\Stmt\Else_ ||
$node instanceof Node\Stmt\EnumCase ||
$node instanceof Node\Stmt\Finally_ ||
$node instanceof Node\Stmt\GroupUse ||
$node instanceof Node\Stmt\Label ||
$node instanceof Node\Stmt\Namespace_ ||
$node instanceof Node\Stmt\Nop ||

View File

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

View File

@@ -2,6 +2,25 @@
All notable changes of the PHPUnit 9.6 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [9.6.11] - 2023-08-19
### Added
* [#5478](https://github.com/sebastianbergmann/phpunit/pull/5478): `assertObjectHasProperty()` and `assertObjectNotHasProperty()`
## [9.6.10] - 2023-07-10
### Changed
* [#5419](https://github.com/sebastianbergmann/phpunit/pull/5419): Allow empty `<extensions>` element in XML configuration
## [9.6.9] - 2023-06-11
### Fixed
* [#5405](https://github.com/sebastianbergmann/phpunit/issues/5405): XML configuration migration does not migrate `whitelist/file` elements
* Always use `X.Y.Z` version number (and not just `X.Y`) of PHPUnit's version when checking whether a PHAR-distributed extension is compatible
## [9.6.8] - 2023-05-11
### Fixed
@@ -64,6 +83,9 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil
* [#5064](https://github.com/sebastianbergmann/phpunit/issues/5064): Deprecate `PHPUnit\Framework\TestCase::getMockClass()`
* [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): Deprecate `Test` suffix for abstract test case classes
[9.6.11]: https://github.com/sebastianbergmann/phpunit/compare/9.6.10...9.6.11
[9.6.10]: https://github.com/sebastianbergmann/phpunit/compare/9.6.9...9.6.10
[9.6.9]: https://github.com/sebastianbergmann/phpunit/compare/9.6.8...9.6.9
[9.6.8]: https://github.com/sebastianbergmann/phpunit/compare/9.6.7...9.6.8
[9.6.7]: https://github.com/sebastianbergmann/phpunit/compare/9.6.6...9.6.7
[9.6.6]: https://github.com/sebastianbergmann/phpunit/compare/9.6.5...9.6.6

View File

@@ -0,0 +1,79 @@
# Deprecations
## Soft Deprecations
This functionality is currently [soft-deprecated](https://phpunit.de/backward-compatibility.html#soft-deprecation):
### Writing Tests
#### Test Double API
* [#3687](https://github.com/sebastianbergmann/phpunit/issues/3687): `MockBuilder::setMethods()` (since PHPUnit 8.3.0)
* [#3687](https://github.com/sebastianbergmann/phpunit/issues/3687): `MockBuilder::setMethodsExcept()` (since PHPUnit 9.6.0)
## Hard Deprecations
This functionality is currently [hard-deprecated](https://phpunit.de/backward-compatibility.html#hard-deprecation):
### Writing Tests
#### Assertions, Constraints, and Expectations
* [#4062](https://github.com/sebastianbergmann/phpunit/issues/4062): `TestCase::assertNotIsReadable()` (since PHPUnit 9.1.0)
* [#4065](https://github.com/sebastianbergmann/phpunit/issues/4065): `TestCase::assertNotIsWritable()` (since PHPUnit 9.1.0)
* [#4068](https://github.com/sebastianbergmann/phpunit/issues/4068): `TestCase::assertDirectoryNotExists()` (since PHPUnit 9.1.0)
* [#4071](https://github.com/sebastianbergmann/phpunit/issues/4071): `TestCase::assertDirectoryNotIsReadable()` (since PHPUnit 9.1.0)
* [#4074](https://github.com/sebastianbergmann/phpunit/issues/4074): `TestCase::assertDirectoryNotIsWritable()` (since PHPUnit 9.1.0)
* [#4077](https://github.com/sebastianbergmann/phpunit/issues/4077): `TestCase::assertFileNotExists()` (since PHPUnit 9.1.0)
* [#4080](https://github.com/sebastianbergmann/phpunit/issues/4080): `TestCase::assertFileNotIsReadable()` (since PHPUnit 9.1.0)
* [#4083](https://github.com/sebastianbergmann/phpunit/issues/4083): `TestCase::assertFileNotIsWritable()` (since PHPUnit 9.1.0)
* [#4086](https://github.com/sebastianbergmann/phpunit/issues/4086): `TestCase::assertRegExp()` (since PHPUnit 9.1.0)
* [#4089](https://github.com/sebastianbergmann/phpunit/issues/4089): `TestCase::assertNotRegExp()` (since PHPUnit 9.1.0)
* [#4091](https://github.com/sebastianbergmann/phpunit/issues/4091): `TestCase::assertEqualXMLStructure()` (since PHPUnit 9.1.0)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertClassHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertClassNotHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertClassHasStaticAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertClassNotHasStaticAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertObjectHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::assertObjectNotHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::classHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::classHasStaticAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `TestCase::objectHasAttribute()` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `ClassHasAttribute` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `ClassHasStaticAttribute` (since PHPUnit 9.6.1)
* [#4601](https://github.com/sebastianbergmann/phpunit/issues/4601): `ObjectHasAttribute` (since PHPUnit 9.6.1)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectDeprecation()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectDeprecationMessage()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectDeprecationMessageMatches()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectError()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectErrorMessage()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectErrorMessageMatches()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectNotice()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectNoticeMessage()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectNoticeMessageMatches()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectWarning()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectWarningMessage()` (since PHPUnit 9.6.0)
* [#5062](https://github.com/sebastianbergmann/phpunit/issues/5062): `TestCase::expectWarningMessageMatches()` (since PHPUnit 9.6.0)
#### Test Double API
* [#4141](https://github.com/sebastianbergmann/phpunit/issues/4141): `TestCase::prophesize()` (since PHPUnit 9.1.0)
* [#4297](https://github.com/sebastianbergmann/phpunit/issues/4297): `TestCase::at()` (since PHPUnit 9.3.0)
* [#4297](https://github.com/sebastianbergmann/phpunit/issues/4297): `InvokedAtIndex` (since PHPUnit 9.3.0)
* [#5063](https://github.com/sebastianbergmann/phpunit/issues/5063): `InvocationMocker::withConsecutive()` (since PHPUnit 9.6.0)
* [#5063](https://github.com/sebastianbergmann/phpunit/issues/5063): `ConsecutiveParameters` (since PHPUnit 9.6.0)
* [#5064](https://github.com/sebastianbergmann/phpunit/issues/5064): `TestCase::getMockClass()` (since PHPUnit 9.6.0)
#### Miscellaneous
* [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): `Test` suffix for abstract test case classes
* `TestCase::$backupGlobalsBlacklist` (since PHPUnit 9.3.0)
* `TestCase::$backupStaticAttributesBlacklist` (since PHPUnit 9.3.0)
### Extending PHPUnit
* [#4039](https://github.com/sebastianbergmann/phpunit/issues/4039): `Command::handleLoader()` (since PHPUnit 9.1.0)
* [#4039](https://github.com/sebastianbergmann/phpunit/issues/4039): `TestSuiteLoader` (since PHPUnit 9.1.0)
* [#4039](https://github.com/sebastianbergmann/phpunit/issues/4039): `StandardTestSuiteLoader` (since PHPUnit 9.1.0)
* [#4676](https://github.com/sebastianbergmann/phpunit/issues/4676): `TestListener` (since PHPUnit 8.0.0)
* [#4676](https://github.com/sebastianbergmann/phpunit/issues/4676): `TestListenerDefaultImplementation` (since PHPUnit 8.2.4)

View File

@@ -25,7 +25,7 @@ Alternatively, you may use [Composer](https://getcomposer.org/) to download and
## Contribute
Please refer to [CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/master/.github/CONTRIBUTING.md) for information on how to contribute to PHPUnit and its related projects.
Please refer to [CONTRIBUTING.md](https://github.com/sebastianbergmann/phpunit/blob/main/.github/CONTRIBUTING.md) for information on how to contribute to PHPUnit and its related projects.
## List of Contributors

View File

@@ -57,7 +57,7 @@
</xs:complexType>
<xs:complexType name="extensionsType">
<xs:sequence>
<xs:element name="extension" type="objectType" maxOccurs="unbounded"/>
<xs:element name="extension" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listenersType">

View File

@@ -73,6 +73,7 @@ use PHPUnit\Framework\Constraint\LogicalOr;
use PHPUnit\Framework\Constraint\LogicalXor;
use PHPUnit\Framework\Constraint\ObjectEquals;
use PHPUnit\Framework\Constraint\ObjectHasAttribute;
use PHPUnit\Framework\Constraint\ObjectHasProperty;
use PHPUnit\Framework\Constraint\RegularExpression;
use PHPUnit\Framework\Constraint\SameSize;
use PHPUnit\Framework\Constraint\StringContains;
@@ -111,14 +112,14 @@ abstract class Assert
if (!(is_int($key) || is_string($key))) {
throw InvalidArgumentException::create(
1,
'integer or string'
'integer or string',
);
}
if (!(is_array($array) || $array instanceof ArrayAccess)) {
throw InvalidArgumentException::create(
2,
'array or ArrayAccess'
'array or ArrayAccess',
);
}
@@ -142,19 +143,19 @@ abstract class Assert
if (!(is_int($key) || is_string($key))) {
throw InvalidArgumentException::create(
1,
'integer or string'
'integer or string',
);
}
if (!(is_array($array) || $array instanceof ArrayAccess)) {
throw InvalidArgumentException::create(
2,
'array or ArrayAccess'
'array or ArrayAccess',
);
}
$constraint = new LogicalNot(
new ArrayHasKey($key)
new ArrayHasKey($key),
);
static::assertThat($array, $constraint, $message);
@@ -191,7 +192,7 @@ abstract class Assert
public static function assertNotContains($needle, iterable $haystack, string $message = ''): void
{
$constraint = new LogicalNot(
new TraversableContainsIdentical($needle)
new TraversableContainsIdentical($needle),
);
static::assertThat($haystack, $constraint, $message);
@@ -220,9 +221,9 @@ abstract class Assert
$haystack,
new TraversableContainsOnly(
$type,
$isNativeType
$isNativeType,
),
$message
$message,
);
}
@@ -238,9 +239,9 @@ abstract class Assert
$haystack,
new TraversableContainsOnly(
$className,
false
false,
),
$message
$message,
);
}
@@ -261,10 +262,10 @@ abstract class Assert
new LogicalNot(
new TraversableContainsOnly(
$type,
$isNativeType
)
$isNativeType,
),
),
$message
$message,
);
}
@@ -290,7 +291,7 @@ abstract class Assert
static::assertThat(
$haystack,
new Count($expectedCount),
$message
$message,
);
}
@@ -314,7 +315,7 @@ abstract class Assert
}
$constraint = new LogicalNot(
new Count($expectedCount)
new Count($expectedCount),
);
static::assertThat($haystack, $constraint, $message);
@@ -369,7 +370,7 @@ abstract class Assert
{
$constraint = new IsEqualWithDelta(
$expected,
$delta
$delta,
);
static::assertThat($actual, $constraint, $message);
@@ -384,7 +385,7 @@ abstract class Assert
public static function assertNotEquals($expected, $actual, string $message = ''): void
{
$constraint = new LogicalNot(
new IsEqual($expected)
new IsEqual($expected),
);
static::assertThat($actual, $constraint, $message);
@@ -399,7 +400,7 @@ abstract class Assert
public static function assertNotEqualsCanonicalizing($expected, $actual, string $message = ''): void
{
$constraint = new LogicalNot(
new IsEqualCanonicalizing($expected)
new IsEqualCanonicalizing($expected),
);
static::assertThat($actual, $constraint, $message);
@@ -414,7 +415,7 @@ abstract class Assert
public static function assertNotEqualsIgnoringCase($expected, $actual, string $message = ''): void
{
$constraint = new LogicalNot(
new IsEqualIgnoringCase($expected)
new IsEqualIgnoringCase($expected),
);
static::assertThat($actual, $constraint, $message);
@@ -431,8 +432,8 @@ abstract class Assert
$constraint = new LogicalNot(
new IsEqualWithDelta(
$expected,
$delta
)
$delta,
),
);
static::assertThat($actual, $constraint, $message);
@@ -446,7 +447,7 @@ abstract class Assert
static::assertThat(
$actual,
static::objectEquals($expected, $method),
$message
$message,
);
}
@@ -506,7 +507,7 @@ abstract class Assert
static::assertThat(
$actual,
static::greaterThanOrEqual($expected),
$message
$message,
);
}
@@ -562,7 +563,7 @@ abstract class Assert
static::assertFileExists($actual, $message);
$constraint = new IsEqualCanonicalizing(
file_get_contents($expected)
file_get_contents($expected),
);
static::assertThat(file_get_contents($actual), $constraint, $message);
@@ -598,7 +599,7 @@ abstract class Assert
static::assertFileExists($actual, $message);
$constraint = new LogicalNot(
new IsEqual(file_get_contents($expected))
new IsEqual(file_get_contents($expected)),
);
static::assertThat(file_get_contents($actual), $constraint, $message);
@@ -617,7 +618,7 @@ abstract class Assert
static::assertFileExists($actual, $message);
$constraint = new LogicalNot(
new IsEqualCanonicalizing(file_get_contents($expected))
new IsEqualCanonicalizing(file_get_contents($expected)),
);
static::assertThat(file_get_contents($actual), $constraint, $message);
@@ -636,7 +637,7 @@ abstract class Assert
static::assertFileExists($actual, $message);
$constraint = new LogicalNot(
new IsEqualIgnoringCase(file_get_contents($expected))
new IsEqualIgnoringCase(file_get_contents($expected)),
);
static::assertThat(file_get_contents($actual), $constraint, $message);
@@ -702,7 +703,7 @@ abstract class Assert
static::assertFileExists($expectedFile, $message);
$constraint = new LogicalNot(
new IsEqual(file_get_contents($expectedFile))
new IsEqual(file_get_contents($expectedFile)),
);
static::assertThat($actualString, $constraint, $message);
@@ -720,7 +721,7 @@ abstract class Assert
static::assertFileExists($expectedFile, $message);
$constraint = new LogicalNot(
new IsEqualCanonicalizing(file_get_contents($expectedFile))
new IsEqualCanonicalizing(file_get_contents($expectedFile)),
);
static::assertThat($actualString, $constraint, $message);
@@ -738,7 +739,7 @@ abstract class Assert
static::assertFileExists($expectedFile, $message);
$constraint = new LogicalNot(
new IsEqualIgnoringCase(file_get_contents($expectedFile))
new IsEqualIgnoringCase(file_get_contents($expectedFile)),
);
static::assertThat($actualString, $constraint, $message);
@@ -1227,9 +1228,9 @@ abstract class Assert
static::assertThat(
$className,
new LogicalNot(
new ClassHasAttribute($attributeName)
new ClassHasAttribute($attributeName),
),
$message
$message,
);
}
@@ -1257,7 +1258,7 @@ abstract class Assert
static::assertThat(
$className,
new ClassHasStaticAttribute($attributeName),
$message
$message,
);
}
@@ -1285,9 +1286,9 @@ abstract class Assert
static::assertThat(
$className,
new LogicalNot(
new ClassHasStaticAttribute($attributeName)
new ClassHasStaticAttribute($attributeName),
),
$message
$message,
);
}
@@ -1304,7 +1305,7 @@ abstract class Assert
*/
public static function assertObjectHasAttribute(string $attributeName, $object, string $message = ''): void
{
self::createWarning('assertObjectHasAttribute() is deprecated and will be removed in PHPUnit 10. Refactor your test to use assertObjectHasProperty() (PHPUnit 10.1.0+) instead.');
self::createWarning('assertObjectHasAttribute() is deprecated and will be removed in PHPUnit 10. Refactor your test to use assertObjectHasProperty() instead.');
if (!self::isValidObjectAttributeName($attributeName)) {
throw InvalidArgumentException::create(1, 'valid attribute name');
@@ -1317,7 +1318,7 @@ abstract class Assert
static::assertThat(
$object,
new ObjectHasAttribute($attributeName),
$message
$message,
);
}
@@ -1334,7 +1335,7 @@ abstract class Assert
*/
public static function assertObjectNotHasAttribute(string $attributeName, $object, string $message = ''): void
{
self::createWarning('assertObjectNotHasAttribute() is deprecated and will be removed in PHPUnit 10. Refactor your test to use assertObjectNotHasProperty() (PHPUnit 10.1.0+) instead.');
self::createWarning('assertObjectNotHasAttribute() is deprecated and will be removed in PHPUnit 10. Refactor your test to use assertObjectNotHasProperty() instead.');
if (!self::isValidObjectAttributeName($attributeName)) {
throw InvalidArgumentException::create(1, 'valid attribute name');
@@ -1347,9 +1348,39 @@ abstract class Assert
static::assertThat(
$object,
new LogicalNot(
new ObjectHasAttribute($attributeName)
new ObjectHasAttribute($attributeName),
),
$message
$message,
);
}
/**
* Asserts that an object has a specified property.
*
* @throws ExpectationFailedException
*/
final public static function assertObjectHasProperty(string $propertyName, object $object, string $message = ''): void
{
static::assertThat(
$object,
new ObjectHasProperty($propertyName),
$message,
);
}
/**
* Asserts that an object does not have a specified property.
*
* @throws ExpectationFailedException
*/
final public static function assertObjectNotHasProperty(string $propertyName, object $object, string $message = ''): void
{
static::assertThat(
$object,
new LogicalNot(
new ObjectHasProperty($propertyName),
),
$message,
);
}
@@ -1372,7 +1403,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsIdentical($expected),
$message
$message,
);
}
@@ -1393,9 +1424,9 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(
new IsIdentical($expected)
new IsIdentical($expected),
),
$message
$message,
);
}
@@ -1421,7 +1452,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsInstanceOf($expected),
$message
$message,
);
}
@@ -1447,9 +1478,9 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(
new IsInstanceOf($expected)
new IsInstanceOf($expected),
),
$message
$message,
);
}
@@ -1466,7 +1497,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_ARRAY),
$message
$message,
);
}
@@ -1483,7 +1514,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_BOOL),
$message
$message,
);
}
@@ -1500,7 +1531,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_FLOAT),
$message
$message,
);
}
@@ -1517,7 +1548,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_INT),
$message
$message,
);
}
@@ -1534,7 +1565,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_NUMERIC),
$message
$message,
);
}
@@ -1551,7 +1582,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_OBJECT),
$message
$message,
);
}
@@ -1568,7 +1599,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_RESOURCE),
$message
$message,
);
}
@@ -1585,7 +1616,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_CLOSED_RESOURCE),
$message
$message,
);
}
@@ -1602,7 +1633,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_STRING),
$message
$message,
);
}
@@ -1619,7 +1650,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_SCALAR),
$message
$message,
);
}
@@ -1636,7 +1667,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_CALLABLE),
$message
$message,
);
}
@@ -1653,7 +1684,7 @@ abstract class Assert
static::assertThat(
$actual,
new IsType(IsType::TYPE_ITERABLE),
$message
$message,
);
}
@@ -1670,7 +1701,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_ARRAY)),
$message
$message,
);
}
@@ -1687,7 +1718,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_BOOL)),
$message
$message,
);
}
@@ -1704,7 +1735,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_FLOAT)),
$message
$message,
);
}
@@ -1721,7 +1752,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_INT)),
$message
$message,
);
}
@@ -1738,7 +1769,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_NUMERIC)),
$message
$message,
);
}
@@ -1755,7 +1786,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_OBJECT)),
$message
$message,
);
}
@@ -1772,7 +1803,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_RESOURCE)),
$message
$message,
);
}
@@ -1789,7 +1820,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_CLOSED_RESOURCE)),
$message
$message,
);
}
@@ -1806,7 +1837,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_STRING)),
$message
$message,
);
}
@@ -1823,7 +1854,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_SCALAR)),
$message
$message,
);
}
@@ -1840,7 +1871,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_CALLABLE)),
$message
$message,
);
}
@@ -1857,7 +1888,7 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(new IsType(IsType::TYPE_ITERABLE)),
$message
$message,
);
}
@@ -1900,9 +1931,9 @@ abstract class Assert
static::assertThat(
$string,
new LogicalNot(
new RegularExpression($pattern)
new RegularExpression($pattern),
),
$message
$message,
);
}
@@ -1923,9 +1954,9 @@ abstract class Assert
static::assertThat(
$string,
new LogicalNot(
new RegularExpression($pattern)
new RegularExpression($pattern),
),
$message
$message,
);
}
@@ -1961,7 +1992,7 @@ abstract class Assert
static::assertThat(
$actual,
new SameSize($expected),
$message
$message,
);
}
@@ -1997,9 +2028,9 @@ abstract class Assert
static::assertThat(
$actual,
new LogicalNot(
new SameSize($expected)
new SameSize($expected),
),
$message
$message,
);
}
@@ -2025,9 +2056,9 @@ abstract class Assert
static::assertThat(
$string,
new LogicalNot(
new StringMatchesFormatDescription($format)
new StringMatchesFormatDescription($format),
),
$message
$message,
);
}
@@ -2044,9 +2075,9 @@ abstract class Assert
static::assertThat(
$string,
new StringMatchesFormatDescription(
file_get_contents($formatFile)
file_get_contents($formatFile),
),
$message
$message,
);
}
@@ -2064,10 +2095,10 @@ abstract class Assert
$string,
new LogicalNot(
new StringMatchesFormatDescription(
file_get_contents($formatFile)
)
file_get_contents($formatFile),
),
),
$message
$message,
);
}
@@ -2096,9 +2127,9 @@ abstract class Assert
static::assertThat(
$string,
new LogicalNot(
new StringStartsWith($prefix)
new StringStartsWith($prefix),
),
$message
$message,
);
}
@@ -2168,9 +2199,9 @@ abstract class Assert
static::assertThat(
$string,
new LogicalNot(
new StringEndsWith($suffix)
new StringEndsWith($suffix),
),
$message
$message,
);
}
@@ -2335,7 +2366,7 @@ abstract class Assert
static::assertSame(
$expectedElement->tagName,
$actualElement->tagName,
$message
$message,
);
if ($checkAttributes) {
@@ -2346,8 +2377,8 @@ abstract class Assert
'%s%sNumber of attributes on node "%s" does not match',
$message,
!empty($message) ? "\n" : '',
$expectedElement->tagName
)
$expectedElement->tagName,
),
);
for ($i = 0; $i < $expectedElement->attributes->length; $i++) {
@@ -2363,8 +2394,8 @@ abstract class Assert
$message,
!empty($message) ? "\n" : '',
$expectedAttribute->name,
$expectedElement->tagName
)
$expectedElement->tagName,
),
);
}
}
@@ -2380,8 +2411,8 @@ abstract class Assert
'%s%sNumber of child nodes of "%s" differs',
$message,
!empty($message) ? "\n" : '',
$expectedElement->tagName
)
$expectedElement->tagName,
),
);
for ($i = 0; $i < $expectedElement->childNodes->length; $i++) {
@@ -2389,7 +2420,7 @@ abstract class Assert
$expectedElement->childNodes->item($i),
$actualElement->childNodes->item($i),
$checkAttributes,
$message
$message,
);
}
}
@@ -2449,9 +2480,9 @@ abstract class Assert
static::assertThat(
$actualJson,
new LogicalNot(
new JsonMatches($expectedJson)
new JsonMatches($expectedJson),
),
$message
$message,
);
}
@@ -2489,9 +2520,9 @@ abstract class Assert
static::assertThat(
$actualJson,
new LogicalNot(
new JsonMatches($expectedJson)
new JsonMatches($expectedJson),
),
$message
$message,
);
}
@@ -2513,7 +2544,7 @@ abstract class Assert
static::assertJson($actualJson, $message);
$constraintExpected = new JsonMatches(
$expectedJson
$expectedJson,
);
$constraintActual = new JsonMatches($actualJson);
@@ -2540,7 +2571,7 @@ abstract class Assert
static::assertJson($actualJson, $message);
$constraintExpected = new JsonMatches(
$expectedJson
$expectedJson,
);
$constraintActual = new JsonMatches($actualJson);
@@ -2721,7 +2752,7 @@ abstract class Assert
{
return static::logicalOr(
new IsEqual($value),
new GreaterThan($value)
new GreaterThan($value),
);
}
@@ -2779,7 +2810,7 @@ abstract class Assert
{
return static::logicalOr(
new IsEqual($value),
new LessThan($value)
new LessThan($value),
);
}

View File

@@ -1444,6 +1444,42 @@ if (!function_exists('PHPUnit\Framework\assertObjectNotHasAttribute')) {
}
}
if (!function_exists('PHPUnit\Framework\assertObjectHasProperty')) {
/**
* Asserts that an object has a specified property.
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertObjectHasProperty
*/
function assertObjectHasProperty(string $attributeName, object $object, string $message = ''): void
{
Assert::assertObjectHasProperty(...func_get_args());
}
}
if (!function_exists('PHPUnit\Framework\assertObjectNotHasProperty')) {
/**
* Asserts that an object does not have a specified property.
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws Exception
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
* @see Assert::assertObjectNotHasProperty
*/
function assertObjectNotHasProperty(string $attributeName, object $object, string $message = ''): void
{
Assert::assertObjectNotHasProperty(...func_get_args());
}
}
if (!function_exists('PHPUnit\Framework\assertSame')) {
/**
* Asserts that two variables have the same type and value.
@@ -2927,7 +2963,7 @@ if (!function_exists('PHPUnit\Framework\atLeast')) {
function atLeast(int $requiredInvocations): InvokedAtLeastCountMatcher
{
return new InvokedAtLeastCountMatcher(
$requiredInvocations
$requiredInvocations,
);
}
}

View File

@@ -40,7 +40,7 @@ class Count extends Constraint
{
return sprintf(
'count matches %d',
$this->expectedCount
$this->expectedCount,
);
}
@@ -76,7 +76,7 @@ class Count extends Constraint
throw new Exception(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
}
@@ -136,7 +136,7 @@ class Count extends Constraint
return sprintf(
'actual size %d matches expected size %d',
(int) $this->getCountOf($other),
$this->expectedCount
$this->expectedCount,
);
}
}

View File

@@ -64,7 +64,7 @@ final class IsEmpty extends Constraint
'%s %s %s',
strpos($type, 'a') === 0 || strpos($type, 'o') === 0 ? 'an' : 'a',
$type,
$this->toString()
$this->toString(),
);
}
}

View File

@@ -106,7 +106,7 @@ abstract class Constraint implements Countable, SelfDescribing
{
$failureDescription = sprintf(
'Failed asserting that %s.',
$this->failureDescription($other)
$this->failureDescription($other),
);
$additionalFailureDescription = $this->additionalFailureDescription($other);
@@ -121,7 +121,7 @@ abstract class Constraint implements Countable, SelfDescribing
throw new ExpectationFailedException(
$failureDescription,
$comparisonFailure
$comparisonFailure,
);
}

View File

@@ -78,7 +78,7 @@ final class IsEqual extends Constraint
try {
$comparator = $comparatorFactory->getComparatorFor(
$this->value,
$other
$other,
);
$comparator->assertEquals(
@@ -86,7 +86,7 @@ final class IsEqual extends Constraint
$other,
$this->delta,
$this->canonicalize,
$this->ignoreCase
$this->ignoreCase,
);
} catch (ComparisonFailure $f) {
if ($returnResult) {
@@ -95,7 +95,7 @@ final class IsEqual extends Constraint
throw new ExpectationFailedException(
trim($description . "\n" . $f->getMessage()),
$f
$f,
);
}
@@ -118,21 +118,21 @@ final class IsEqual extends Constraint
return sprintf(
"is equal to '%s'",
$this->value
$this->value,
);
}
if ($this->delta != 0) {
$delta = sprintf(
' with delta <%F>',
$this->delta
$this->delta,
);
}
return sprintf(
'is equal to %s%s',
$this->exporter()->export($this->value),
$delta
$delta,
);
}
}

View File

@@ -58,7 +58,7 @@ final class IsEqualCanonicalizing extends Constraint
try {
$comparator = $comparatorFactory->getComparatorFor(
$this->value,
$other
$other,
);
$comparator->assertEquals(
@@ -66,7 +66,7 @@ final class IsEqualCanonicalizing extends Constraint
$other,
0.0,
true,
false
false,
);
} catch (ComparisonFailure $f) {
if ($returnResult) {
@@ -75,7 +75,7 @@ final class IsEqualCanonicalizing extends Constraint
throw new ExpectationFailedException(
trim($description . "\n" . $f->getMessage()),
$f
$f,
);
}
@@ -96,13 +96,13 @@ final class IsEqualCanonicalizing extends Constraint
return sprintf(
"is equal to '%s'",
$this->value
$this->value,
);
}
return sprintf(
'is equal to %s',
$this->exporter()->export($this->value)
$this->exporter()->export($this->value),
);
}
}

View File

@@ -58,7 +58,7 @@ final class IsEqualIgnoringCase extends Constraint
try {
$comparator = $comparatorFactory->getComparatorFor(
$this->value,
$other
$other,
);
$comparator->assertEquals(
@@ -66,7 +66,7 @@ final class IsEqualIgnoringCase extends Constraint
$other,
0.0,
false,
true
true,
);
} catch (ComparisonFailure $f) {
if ($returnResult) {
@@ -75,7 +75,7 @@ final class IsEqualIgnoringCase extends Constraint
throw new ExpectationFailedException(
trim($description . "\n" . $f->getMessage()),
$f
$f,
);
}
@@ -96,13 +96,13 @@ final class IsEqualIgnoringCase extends Constraint
return sprintf(
"is equal to '%s'",
$this->value
$this->value,
);
}
return sprintf(
'is equal to %s',
$this->exporter()->export($this->value)
$this->exporter()->export($this->value),
);
}
}

View File

@@ -62,13 +62,13 @@ final class IsEqualWithDelta extends Constraint
try {
$comparator = $comparatorFactory->getComparatorFor(
$this->value,
$other
$other,
);
$comparator->assertEquals(
$this->value,
$other,
$this->delta
$this->delta,
);
} catch (ComparisonFailure $f) {
if ($returnResult) {
@@ -77,7 +77,7 @@ final class IsEqualWithDelta extends Constraint
throw new ExpectationFailedException(
trim($description . "\n" . $f->getMessage()),
$f
$f,
);
}
@@ -94,7 +94,7 @@ final class IsEqualWithDelta extends Constraint
return sprintf(
'is equal to %s with delta <%F>',
$this->exporter()->export($this->value),
$this->delta
$this->delta,
);
}
}

View File

@@ -36,7 +36,7 @@ final class Exception extends Constraint
{
return sprintf(
'exception of type "%s"',
$this->className
$this->className,
);
}
@@ -73,13 +73,13 @@ final class Exception extends Constraint
'exception of type "%s" matches expected exception "%s"%s',
get_class($other),
$this->className,
$message
$message,
);
}
return sprintf(
'exception of type "%s" is thrown',
$this->className
$this->className,
);
}
}

View File

@@ -61,7 +61,7 @@ final class ExceptionCode extends Constraint
return sprintf(
'%s is equal to expected exception code %s',
$this->exporter()->export($other->getCode()),
$this->exporter()->export($this->expectedCode)
$this->exporter()->export($this->expectedCode),
);
}
}

View File

@@ -65,14 +65,14 @@ final class ExceptionMessage extends Constraint
if ($this->expectedMessage === '') {
return sprintf(
"exception message is empty but is '%s'",
$other->getMessage()
$other->getMessage(),
);
}
return sprintf(
"exception message '%s' contains '%s'",
$other->getMessage(),
$this->expectedMessage
$this->expectedMessage,
);
}
}

View File

@@ -48,7 +48,7 @@ final class ExceptionMessageRegularExpression extends Constraint
if ($match === false) {
throw new \PHPUnit\Framework\Exception(
"Invalid expected exception message regex given: '{$this->expectedMessageRegExp}'"
"Invalid expected exception message regex given: '{$this->expectedMessageRegExp}'",
);
}
@@ -68,7 +68,7 @@ final class ExceptionMessageRegularExpression extends Constraint
return sprintf(
"exception message '%s' matches '%s'",
$other->getMessage(),
$this->expectedMessageRegExp
$this->expectedMessageRegExp,
);
}
}

View File

@@ -48,7 +48,7 @@ final class DirectoryExists extends Constraint
{
return sprintf(
'directory "%s" exists',
$other
$other,
);
}
}

View File

@@ -48,7 +48,7 @@ final class FileExists extends Constraint
{
return sprintf(
'file "%s" exists',
$other
$other,
);
}
}

View File

@@ -48,7 +48,7 @@ final class IsReadable extends Constraint
{
return sprintf(
'"%s" is readable',
$other
$other,
);
}
}

View File

@@ -48,7 +48,7 @@ final class IsWritable extends Constraint
{
return sprintf(
'"%s" is writable',
$other
$other,
);
}
}

View File

@@ -62,7 +62,7 @@ final class IsIdentical extends Constraint
$this->value,
$other,
sprintf("'%s'", $this->value),
sprintf("'%s'", $other)
sprintf("'%s'", $other),
);
}
@@ -72,7 +72,7 @@ final class IsIdentical extends Constraint
$this->value,
$other,
$this->exporter()->export($this->value),
$this->exporter()->export($other)
$this->exporter()->export($other),
);
}

View File

@@ -37,7 +37,7 @@ final class JsonMatches extends Constraint
{
return sprintf(
'matches JSON string "%s"',
$this->value
$this->value,
);
}
@@ -100,7 +100,7 @@ final class JsonMatches extends Constraint
Json::prettify($recodedValue),
Json::prettify($recodedOther),
false,
'Failed asserting that two json values are equal.'
'Failed asserting that two json values are equal.',
);
}

View File

@@ -40,7 +40,7 @@ class ClassHasAttribute extends Constraint
{
return sprintf(
'has attribute "%s"',
$this->attributeName
$this->attributeName,
);
}
@@ -59,7 +59,7 @@ class ClassHasAttribute extends Constraint
throw new Exception(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -79,7 +79,7 @@ class ClassHasAttribute extends Constraint
'%sclass "%s" %s',
is_object($other) ? 'object of ' : '',
is_object($other) ? get_class($other) : $other,
$this->toString()
$this->toString(),
);
}

View File

@@ -28,7 +28,7 @@ final class ClassHasStaticAttribute extends ClassHasAttribute
{
return sprintf(
'has static attribute "%s"',
$this->attributeName()
$this->attributeName(),
);
}
@@ -51,7 +51,7 @@ final class ClassHasStaticAttribute extends ClassHasAttribute
throw new Exception(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd

View File

@@ -65,7 +65,7 @@ final class ObjectEquals extends Constraint
if (!$object->hasMethod($this->method)) {
throw new ComparisonMethodDoesNotExistException(
get_class($other),
$this->method
$this->method,
);
}
@@ -75,7 +75,7 @@ final class ObjectEquals extends Constraint
if (!$method->hasReturnType()) {
throw new ComparisonMethodDoesNotDeclareBoolReturnTypeException(
get_class($other),
$this->method
$this->method,
);
}
@@ -84,28 +84,28 @@ final class ObjectEquals extends Constraint
if (!$returnType instanceof ReflectionNamedType) {
throw new ComparisonMethodDoesNotDeclareBoolReturnTypeException(
get_class($other),
$this->method
$this->method,
);
}
if ($returnType->allowsNull()) {
throw new ComparisonMethodDoesNotDeclareBoolReturnTypeException(
get_class($other),
$this->method
$this->method,
);
}
if ($returnType->getName() !== 'bool') {
throw new ComparisonMethodDoesNotDeclareBoolReturnTypeException(
get_class($other),
$this->method
$this->method,
);
}
if ($method->getNumberOfParameters() !== 1 || $method->getNumberOfRequiredParameters() !== 1) {
throw new ComparisonMethodDoesNotDeclareExactlyOneParameterException(
get_class($other),
$this->method
$this->method,
);
}
@@ -114,7 +114,7 @@ final class ObjectEquals extends Constraint
if (!$parameter->hasType()) {
throw new ComparisonMethodDoesNotDeclareParameterTypeException(
get_class($other),
$this->method
$this->method,
);
}
@@ -123,7 +123,7 @@ final class ObjectEquals extends Constraint
if (!$type instanceof ReflectionNamedType) {
throw new ComparisonMethodDoesNotDeclareParameterTypeException(
get_class($other),
$this->method
$this->method,
);
}
@@ -137,7 +137,7 @@ final class ObjectEquals extends Constraint
throw new ComparisonMethodDoesNotAcceptParameterTypeException(
get_class($other),
$this->method,
get_class($this->expected)
get_class($this->expected),
);
}

View File

@@ -0,0 +1,84 @@
<?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\Framework\Constraint;
use function get_class;
use function gettype;
use function is_object;
use function sprintf;
use ReflectionObject;
/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*/
final class ObjectHasProperty extends Constraint
{
/**
* @var string
*/
private $propertyName;
public function __construct(string $propertyName)
{
$this->propertyName = $propertyName;
}
/**
* Returns a string representation of the constraint.
*/
public function toString(): string
{
return sprintf(
'has property "%s"',
$this->propertyName,
);
}
/**
* Evaluates the constraint for parameter $other. Returns true if the
* constraint is met, false otherwise.
*
* @param mixed $other value or object to evaluate
*/
protected function matches($other): bool
{
if (!is_object($other)) {
return false;
}
return (new ReflectionObject($other))->hasProperty($this->propertyName);
}
/**
* Returns the description of the failure.
*
* The beginning of failure messages is "Failed asserting that" in most
* cases. This method should return the second part of that sentence.
*
* @param mixed $other evaluated value or object
*/
protected function failureDescription($other): string
{
if (is_object($other)) {
return sprintf(
'object of class "%s" %s',
get_class($other),
$this->toString(),
);
}
return sprintf(
'"%s" (%s) %s',
$other,
gettype($other),
$this->toString(),
);
}
}

View File

@@ -63,15 +63,15 @@ final class LogicalNot extends UnaryOperator
preg_replace(
$positives,
$negatives,
$nonInput
$nonInput,
),
$string
$string,
);
} else {
$negatedString = preg_replace(
$positives,
$negatives,
$string
$string,
);
}

View File

@@ -57,7 +57,7 @@ final class LogicalXor extends BinaryOperator
{
return $matches xor $constraint->evaluate($other, '', true);
},
$initial->evaluate($other, '', true)
$initial->evaluate($other, '', true),
);
}
}

View File

@@ -65,13 +65,13 @@ final class IsJson extends Constraint
json_decode($other);
$error = (string) JsonMatchesErrorMessageProvider::determineJsonError(
(string) json_last_error()
(string) json_last_error(),
);
return sprintf(
'%s is valid JSON (%s)',
$this->exporter()->shortenedExport($other),
$error
$error,
);
}
}

View File

@@ -34,7 +34,7 @@ class RegularExpression extends Constraint
{
return sprintf(
'matches PCRE pattern "%s"',
$this->pattern
$this->pattern,
);
}

View File

@@ -48,7 +48,7 @@ final class StringContains extends Constraint
return sprintf(
'contains "%s"',
$string
$string,
);
}

View File

@@ -33,8 +33,8 @@ final class StringMatchesFormatDescription extends RegularExpression
{
parent::__construct(
$this->createPatternFromFormat(
$this->convertNewlines($string)
)
$this->convertNewlines($string),
),
);
$this->string = $string;
@@ -49,7 +49,7 @@ final class StringMatchesFormatDescription extends RegularExpression
protected function matches($other): bool
{
return parent::matches(
$this->convertNewlines($other)
$this->convertNewlines($other),
);
}
@@ -96,7 +96,7 @@ final class StringMatchesFormatDescription extends RegularExpression
'%x' => '[0-9a-fA-F]+',
'%f' => '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?',
'%c' => '.',
]
],
);
return '/^' . $string . '$/s';

View File

@@ -9,7 +9,6 @@
*/
namespace PHPUnit\Framework\Constraint;
use function strlen;
use function strpos;
use PHPUnit\Framework\InvalidArgumentException;
@@ -25,7 +24,7 @@ final class StringStartsWith extends Constraint
public function __construct(string $prefix)
{
if (strlen($prefix) === 0) {
if ($prefix === '') {
throw InvalidArgumentException::create(1, 'non-empty string');
}

View File

@@ -52,7 +52,7 @@ abstract class TraversableContains extends Constraint
return sprintf(
'%s %s',
is_array($other) ? 'an array' : 'a traversable',
$this->toString()
$this->toString(),
);
}

View File

@@ -36,7 +36,7 @@ final class TraversableContainsOnly extends Constraint
$this->constraint = new IsType($type);
} else {
$this->constraint = new IsInstanceOf(
$type
$type,
);
}

View File

@@ -36,7 +36,7 @@ final class IsInstanceOf extends Constraint
return sprintf(
'is instance of %s "%s"',
$this->getType(),
$this->className
$this->className,
);
}
@@ -67,7 +67,7 @@ final class IsInstanceOf extends Constraint
'%s is an instance of %s "%s"',
$this->exporter()->shortenedExport($other),
$this->getType(),
$this->className
$this->className,
);
}

View File

@@ -130,8 +130,8 @@ final class IsType extends Constraint
sprintf(
'Type specified for PHPUnit\Framework\Constraint\IsType <%s> ' .
'is not a valid type.',
$type
)
$type,
),
);
}
@@ -145,7 +145,7 @@ final class IsType extends Constraint
{
return sprintf(
'is of type "%s"',
$this->type
$this->type,
);
}

View File

@@ -15,17 +15,17 @@ namespace PHPUnit\Framework;
final class ErrorTestCase extends TestCase
{
/**
* @var bool
* @var ?bool
*/
protected $backupGlobals = false;
/**
* @var bool
* @var ?bool
*/
protected $backupStaticAttributes = false;
/**
* @var bool
* @var ?bool
*/
protected $runTestInSeparateProcess = false;

View File

@@ -21,7 +21,7 @@ final class ActualValueIsNotAnObjectException extends Exception
parent::__construct(
'Actual value is not an object',
0,
null
null,
);
}

View File

@@ -24,10 +24,10 @@ final class ComparisonMethodDoesNotAcceptParameterTypeException extends Exceptio
'%s is not an accepted argument type for comparison method %s::%s().',
$type,
$className,
$methodName
$methodName,
),
0,
null
null,
);
}

View File

@@ -23,10 +23,10 @@ final class ComparisonMethodDoesNotDeclareBoolReturnTypeException extends Except
sprintf(
'Comparison method %s::%s() does not declare bool return type.',
$className,
$methodName
$methodName,
),
0,
null
null,
);
}

View File

@@ -23,10 +23,10 @@ final class ComparisonMethodDoesNotDeclareExactlyOneParameterException extends E
sprintf(
'Comparison method %s::%s() does not declare exactly one parameter.',
$className,
$methodName
$methodName,
),
0,
null
null,
);
}

View File

@@ -23,10 +23,10 @@ final class ComparisonMethodDoesNotDeclareParameterTypeException extends Excepti
sprintf(
'Parameter of comparison method %s::%s() does not have a declared type.',
$className,
$methodName
$methodName,
),
0,
null
null,
);
}

View File

@@ -23,10 +23,10 @@ final class ComparisonMethodDoesNotExistException extends Exception
sprintf(
'Comparison method %s::%s() does not exist.',
$className,
$methodName
$methodName,
),
0,
null
null,
);
}

View File

@@ -34,8 +34,8 @@ final class InvalidArgumentException extends Exception
$argument,
$function,
in_array(lcfirst($type)[0], ['a', 'e', 'i', 'o', 'u'], true) ? 'an' : 'a',
$type
)
$type,
),
);
}

View File

@@ -77,8 +77,8 @@ final class ExecutionOrderDependency
static function (self $d)
{
return $d->isValid();
}
)
},
),
);
}
@@ -95,7 +95,7 @@ final class ExecutionOrderDependency
{
return $dependency->getTarget();
},
$existing
$existing,
);
foreach ($additional as $dependency) {
@@ -132,7 +132,7 @@ final class ExecutionOrderDependency
{
return $dependency->getTarget();
},
$right
$right,
);
foreach ($left as $dependency) {

View File

@@ -15,17 +15,17 @@ namespace PHPUnit\Framework;
final class IncompleteTestCase extends TestCase
{
/**
* @var bool
* @var ?bool
*/
protected $backupGlobals = false;
/**
* @var bool
* @var ?bool
*/
protected $backupStaticAttributes = false;
/**
* @var bool
* @var ?bool
*/
protected $runTestInSeparateProcess = false;

View File

@@ -42,7 +42,7 @@ trait Api
{
if (isset(static::$__phpunit_configurableMethods)) {
throw new ConfigurableMethodsAlreadyInitializedException(
'Configurable methods is already initialized and can not be reinitialized'
'Configurable methods is already initialized and can not be reinitialized',
);
}
@@ -67,7 +67,7 @@ trait Api
if ($this->__phpunit_invocationMocker === null) {
$this->__phpunit_invocationMocker = new InvocationHandler(
static::$__phpunit_configurableMethods,
$this->__phpunit_returnValueGeneration
$this->__phpunit_returnValueGeneration,
);
}

View File

@@ -24,7 +24,7 @@ trait Method
return call_user_func_array(
[$expects, 'method'],
func_get_args()
func_get_args(),
);
}
}

View File

@@ -241,7 +241,7 @@ final class InvocationMocker implements InvocationStubber, MethodNameMatch
{
return strtolower($configurable->getName());
},
$this->configurableMethods
$this->configurableMethods,
);
if (is_string($constraint) && !in_array(strtolower($constraint), $configurableMethodNames, true)) {
@@ -300,7 +300,7 @@ final class InvocationMocker implements InvocationStubber, MethodNameMatch
if (!$configuredMethod->mayReturn($value)) {
throw new IncompatibleReturnValueException(
$configuredMethod,
$value
$value,
);
}
}

View File

@@ -20,46 +20,46 @@ interface InvocationStubber
public function will(Stub $stub): Identity;
/** @return self */
public function willReturn($value, ...$nextValues)/*: self */;
public function willReturn($value, ...$nextValues)/* : self */;
/**
* @param mixed $reference
*
* @return self
*/
public function willReturnReference(&$reference)/*: self */;
public function willReturnReference(&$reference)/* : self */;
/**
* @param array<int, array<int, mixed>> $valueMap
*
* @return self
*/
public function willReturnMap(array $valueMap)/*: self */;
public function willReturnMap(array $valueMap)/* : self */;
/**
* @param int $argumentIndex
*
* @return self
*/
public function willReturnArgument($argumentIndex)/*: self */;
public function willReturnArgument($argumentIndex)/* : self */;
/**
* @param callable $callback
*
* @return self
*/
public function willReturnCallback($callback)/*: self */;
public function willReturnCallback($callback)/* : self */;
/** @return self */
public function willReturnSelf()/*: self */;
public function willReturnSelf()/* : self */;
/**
* @param mixed $values
*
* @return self
*/
public function willReturnOnConsecutiveCalls(...$values)/*: self */;
public function willReturnOnConsecutiveCalls(...$values)/* : self */;
/** @return self */
public function willThrowException(Throwable $exception)/*: self */;
public function willThrowException(Throwable $exception)/* : self */;
}

View File

@@ -22,8 +22,8 @@ final class CannotUseAddMethodsException extends \PHPUnit\Framework\Exception im
sprintf(
'Trying to configure method "%s" with addMethods(), but it exists in class "%s". Use onlyMethods() for methods that exist in the class',
$methodName,
$type
)
$type,
),
);
}
}

View File

@@ -22,8 +22,8 @@ final class CannotUseOnlyMethodsException extends \PHPUnit\Framework\Exception i
sprintf(
'Trying to configure method "%s" with onlyMethods(), but it does not exist in class "%s". Use addMethods() for methods that do not exist in the class',
$methodName,
$type
)
$type,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class ClassAlreadyExistsException extends \PHPUnit\Framework\Exception imp
parent::__construct(
sprintf(
'Class "%s" already exists',
$className
)
$className,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class ClassIsFinalException extends \PHPUnit\Framework\Exception implement
parent::__construct(
sprintf(
'Class "%s" is declared "final" and cannot be doubled',
$className
)
$className,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class ClassIsReadonlyException extends \PHPUnit\Framework\Exception implem
parent::__construct(
sprintf(
'Class "%s" is declared "readonly" and cannot be doubled',
$className
)
$className,
),
);
}
}

View File

@@ -28,8 +28,8 @@ final class DuplicateMethodException extends \PHPUnit\Framework\Exception implem
sprintf(
'Cannot double using a method list that contains duplicates: "%s" (duplicate: "%s")',
implode(', ', $methods),
implode(', ', array_unique(array_diff_assoc($methods, array_unique($methods))))
)
implode(', ', array_unique(array_diff_assoc($methods, array_unique($methods)))),
),
);
}
}

View File

@@ -29,8 +29,8 @@ final class IncompatibleReturnValueException extends \PHPUnit\Framework\Exceptio
'Method %s may not return value of type %s, its declared return type is "%s"',
$method->getName(),
is_object($value) ? get_class($value) : gettype($value),
$method->getReturnTypeDeclaration()
)
$method->getReturnTypeDeclaration(),
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class InvalidMethodNameException extends \PHPUnit\Framework\Exception impl
parent::__construct(
sprintf(
'Cannot double method with invalid name "%s"',
$method
)
$method,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class MatchBuilderNotFoundException extends \PHPUnit\Framework\Exception i
parent::__construct(
sprintf(
'No builder found for match builder identification <%s>',
$id
)
$id,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class MatcherAlreadyRegisteredException extends \PHPUnit\Framework\Excepti
parent::__construct(
sprintf(
'Matcher with id <%s> is already registered',
$id
)
$id,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class MethodCannotBeConfiguredException extends \PHPUnit\Framework\Excepti
parent::__construct(
sprintf(
'Trying to configure method "%s" which cannot be configured because it does not exist, has not been specified, is final, or is static',
$method
)
$method,
),
);
}
}

View File

@@ -22,8 +22,8 @@ final class ReturnValueNotConfiguredException extends \PHPUnit\Framework\Excepti
sprintf(
'Return value inference disabled and no expectation set up for %s::%s()',
$invocation->getClassName(),
$invocation->getMethodName()
)
$invocation->getMethodName(),
),
);
}
}

View File

@@ -17,7 +17,7 @@ final class SoapExtensionNotAvailableException extends \PHPUnit\Framework\Except
public function __construct()
{
parent::__construct(
'The SOAP extension is required to generate a test double from WSDL'
'The SOAP extension is required to generate a test double from WSDL',
);
}
}

View File

@@ -21,8 +21,8 @@ final class UnknownClassException extends \PHPUnit\Framework\Exception implement
parent::__construct(
sprintf(
'Class "%s" does not exist',
$className
)
$className,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class UnknownTraitException extends \PHPUnit\Framework\Exception implement
parent::__construct(
sprintf(
'Trait "%s" does not exist',
$traitName
)
$traitName,
),
);
}
}

View File

@@ -21,8 +21,8 @@ final class UnknownTypeException extends \PHPUnit\Framework\Exception implements
parent::__construct(
sprintf(
'Class or interface "%s" does not exist',
$type
)
$type,
),
);
}
}

View File

@@ -186,7 +186,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -207,7 +207,7 @@ EOT;
$callOriginalClone,
$callAutoload,
$cloneArguments,
$callOriginalMethods
$callOriginalMethods,
);
return $this->getObject(
@@ -218,7 +218,7 @@ EOT;
$arguments,
$callOriginalMethods,
$proxyTarget,
$returnValueGeneration
$returnValueGeneration,
);
}
@@ -265,7 +265,7 @@ EOT;
$intersectionName = sprintf(
'Intersection_%s_%s',
implode('_', $unqualifiedNames),
substr(md5((string) mt_rand()), 0, 8)
substr(md5((string) mt_rand()), 0, 8),
);
} while (interface_exists($intersectionName, false));
@@ -275,7 +275,7 @@ EOT;
[
'intersection' => $intersectionName,
'interfaces' => implode(', ', $interfaces),
]
],
);
eval($template->render());
@@ -318,7 +318,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -343,7 +343,7 @@ EOT;
$callOriginalConstructor,
$callOriginalClone,
$callAutoload,
$cloneArguments
$cloneArguments,
);
}
@@ -379,7 +379,7 @@ EOT;
$className = $this->generateClassName(
$traitName,
'',
'Trait_'
'Trait_',
);
$classTemplate = $this->getTemplate('trait_class.tpl');
@@ -389,7 +389,7 @@ EOT;
'prologue' => 'abstract ',
'class_name' => $className['className'],
'trait_name' => $traitName,
]
],
);
$mockTrait = new MockTrait($classTemplate->render(), $className['className']);
@@ -416,7 +416,7 @@ EOT;
$className = $this->generateClassName(
$traitName,
$traitClassName,
'Trait_'
'Trait_',
);
$classTemplate = $this->getTemplate('trait_class.tpl');
@@ -426,18 +426,18 @@ EOT;
'prologue' => '',
'class_name' => $className['className'],
'trait_name' => $traitName,
]
],
);
return $this->getObject(
new MockTrait(
$classTemplate->render(),
$className['className']
$className['className'],
),
'',
$callOriginalConstructor,
$callAutoload,
$arguments
$arguments,
);
}
@@ -457,7 +457,7 @@ EOT;
$callOriginalClone,
$callAutoload,
$cloneArguments,
$callOriginalMethods
$callOriginalMethods,
);
}
@@ -466,7 +466,7 @@ EOT;
serialize($methods) .
serialize($callOriginalClone) .
serialize($cloneArguments) .
serialize($callOriginalMethods)
serialize($callOriginalMethods),
);
if (!isset(self::$cache[$key])) {
@@ -477,7 +477,7 @@ EOT;
$callOriginalClone,
$callAutoload,
$cloneArguments,
$callOriginalMethods
$callOriginalMethods,
);
}
@@ -504,7 +504,7 @@ EOT;
throw new RuntimeException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
@@ -523,7 +523,7 @@ EOT;
if (empty($methods) || in_array($name, $methods, true)) {
$args = explode(
',',
str_replace(')', '', substr($method, $nameEnd + 1))
str_replace(')', '', substr($method, $nameEnd + 1)),
);
foreach (range(0, count($args) - 1) as $i) {
@@ -540,7 +540,7 @@ EOT;
[
'method_name' => $name,
'arguments' => implode(', ', $args),
]
],
);
$methodsBuffer .= $methodTemplate->render();
@@ -571,7 +571,7 @@ EOT;
'wsdl' => $wsdlFile,
'options' => $optionsBuffer,
'methods' => $methodsBuffer,
]
],
);
return $classTemplate->render();
@@ -591,7 +591,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -621,7 +621,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -651,7 +651,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -681,7 +681,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -718,7 +718,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -745,7 +745,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -784,7 +784,7 @@ EOT;
$_mockClassName = $this->generateClassName(
$type,
$mockClassName,
'Mock_'
'Mock_',
);
if (class_exists($_mockClassName['fullClassName'], $callAutoload)) {
@@ -813,7 +813,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -839,7 +839,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -855,7 +855,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -866,14 +866,14 @@ EOT;
}
$mockMethods->addMethods(
MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments)
MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments),
);
}
$_mockClassName = $this->generateClassName(
$actualClassName,
$_mockClassName['className'],
'Mock_'
'Mock_',
);
}
@@ -884,7 +884,7 @@ EOT;
$additionalInterfaces[] = Iterator::class;
$mockMethods->addMethods(
...$this->mockClassMethods(Iterator::class, $callOriginalMethods, $cloneArguments)
...$this->mockClassMethods(Iterator::class, $callOriginalMethods, $cloneArguments),
);
}
@@ -896,7 +896,7 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -915,13 +915,13 @@ EOT;
if ($isClass && $explicitMethods === []) {
$mockMethods->addMethods(
...$this->mockClassMethods($_mockClassName['fullClassName'], $callOriginalMethods, $cloneArguments)
...$this->mockClassMethods($_mockClassName['fullClassName'], $callOriginalMethods, $cloneArguments),
);
}
if ($isInterface && ($explicitMethods === [] || $explicitMethods === null)) {
$mockMethods->addMethods(
...$this->mockInterfaceMethods($_mockClassName['fullClassName'], $cloneArguments)
...$this->mockInterfaceMethods($_mockClassName['fullClassName'], $cloneArguments),
);
}
@@ -935,14 +935,14 @@ EOT;
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
if ($this->canMockMethod($method)) {
$mockMethods->addMethods(
MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments)
MockMethod::fromReflection($method, $callOriginalMethods, $cloneArguments),
);
}
} else {
@@ -950,8 +950,8 @@ EOT;
MockMethod::fromName(
$_mockClassName['fullClassName'],
$methodName,
$cloneArguments
)
$cloneArguments,
),
);
}
}
@@ -988,19 +988,19 @@ EOT;
'class_declaration' => $this->generateMockClassDeclaration(
$_mockClassName,
$isInterface,
$additionalInterfaces
$additionalInterfaces,
),
'clone' => $cloneTrait,
'mock_class_name' => $_mockClassName['className'],
'mocked_methods' => $mockedMethods,
'method' => $method,
]
],
);
return new MockClass(
$classTemplate->render(),
$_mockClassName['className'],
$configurable
$configurable,
);
}
@@ -1047,7 +1047,7 @@ EOT;
$buffer .= sprintf(
'%s implements %s',
$mockClassName['className'],
$interfaces
$interfaces,
);
if (!in_array($mockClassName['originalClassName'], $additionalInterfaces, true)) {
@@ -1065,7 +1065,7 @@ EOT;
$mockClassName['className'],
!empty($mockClassName['namespaceName']) ? $mockClassName['namespaceName'] . '\\' : '',
$mockClassName['originalClassName'],
$interfaces
$interfaces,
);
}
@@ -1096,7 +1096,7 @@ EOT;
throw new RuntimeException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
}

View File

@@ -183,7 +183,7 @@ final class Invocation implements SelfDescribing
throw new RuntimeException(
$t->getMessage(),
(int) $t->getCode(),
$t
$t,
);
}
}
@@ -221,7 +221,7 @@ final class Invocation implements SelfDescribing
throw new RuntimeException(
$t->getMessage(),
(int) $t->getCode(),
$t
$t,
);
}
}
@@ -256,8 +256,8 @@ final class Invocation implements SelfDescribing
'Return value for %s::%s() cannot be generated%s, please configure a return value for this method',
$this->className,
$this->methodName,
$reason
)
$reason,
),
);
}
@@ -273,10 +273,10 @@ final class Invocation implements SelfDescribing
', ',
array_map(
[$exporter, 'shortenedExport'],
$this->parameters
)
$this->parameters,
),
),
$this->returnType ? sprintf(': %s', $this->returnType) : ''
$this->returnType ? sprintf(': %s', $this->returnType) : '',
);
}

View File

@@ -102,7 +102,7 @@ final class InvocationHandler
return new InvocationMocker(
$this,
$matcher,
...$this->configurableMethods
...$this->configurableMethods,
);
}

View File

@@ -117,8 +117,8 @@ final class Matcher
if ($this->afterMatchBuilderId !== null) {
$matcher = $invocation->getObject()
->__phpunit_getInvocationHandler()
->lookupMatcher($this->afterMatchBuilderId);
->__phpunit_getInvocationHandler()
->lookupMatcher($this->afterMatchBuilderId);
if (!$matcher) {
throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
@@ -143,9 +143,9 @@ final class Matcher
"Expectation failed for %s when %s\n%s",
$this->methodNameRule->toString(),
$this->invocationRule->toString(),
$e->getMessage()
$e->getMessage(),
),
$e->getComparisonFailure()
$e->getComparisonFailure(),
);
}
@@ -167,8 +167,8 @@ final class Matcher
{
if ($this->afterMatchBuilderId !== null) {
$matcher = $invocation->getObject()
->__phpunit_getInvocationHandler()
->lookupMatcher($this->afterMatchBuilderId);
->__phpunit_getInvocationHandler()
->lookupMatcher($this->afterMatchBuilderId);
if (!$matcher) {
throw new MatchBuilderNotFoundException($this->afterMatchBuilderId);
@@ -199,9 +199,9 @@ final class Matcher
"Expectation failed for %s when %s\n%s",
$this->methodNameRule->toString(),
$this->invocationRule->toString(),
$e->getMessage()
$e->getMessage(),
),
$e->getComparisonFailure()
$e->getComparisonFailure(),
);
}
@@ -239,8 +239,8 @@ final class Matcher
"Expectation failed for %s when %s.\n%s",
$this->methodNameRule->toString(),
$this->invocationRule->toString(),
TestFailure::exceptionToString($e)
)
TestFailure::exceptionToString($e),
),
);
}
}

View File

@@ -33,7 +33,7 @@ final class MethodNameConstraint extends Constraint
{
return sprintf(
'is "%s"',
$this->methodName
$this->methodName,
);
}

View File

@@ -138,7 +138,7 @@ final class MockBuilder
$this->callOriginalMethods,
$this->proxyTarget,
$this->allowMockingUnknownTypes,
$this->returnValueGeneration
$this->returnValueGeneration,
);
$this->testCase->registerMockObject($object);
@@ -165,7 +165,7 @@ final class MockBuilder
$this->originalClone,
$this->autoload,
$this->methods,
$this->cloneArguments
$this->cloneArguments,
);
$this->testCase->registerMockObject($object);
@@ -192,7 +192,7 @@ final class MockBuilder
$this->originalClone,
$this->autoload,
$this->methods,
$this->cloneArguments
$this->cloneArguments,
);
$this->testCase->registerMockObject($object);
@@ -243,7 +243,7 @@ final class MockBuilder
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -285,7 +285,7 @@ final class MockBuilder
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd
@@ -313,8 +313,8 @@ final class MockBuilder
return $this->setMethods(
array_diff(
$this->generator->getClassMethods($this->type),
$methods
)
$methods,
),
);
}

View File

@@ -55,7 +55,7 @@ final class MockClass implements MockType
$this->mockName,
'__phpunit_initConfigurableMethods',
],
...$this->configurableMethods
...$this->configurableMethods,
);
}

View File

@@ -140,7 +140,7 @@ final class MockMethod
$reference,
$callOriginalMethod,
$method->isStatic(),
$deprecation
$deprecation,
);
}
@@ -157,7 +157,7 @@ final class MockMethod
'',
false,
false,
null
null,
);
}
@@ -191,12 +191,12 @@ final class MockMethod
} elseif ($this->returnType->isNever() || $this->returnType->isVoid()) {
$templateFile = sprintf(
'%s_method_never_or_void.tpl',
$this->callOriginalMethod ? 'proxied' : 'mocked'
$this->callOriginalMethod ? 'proxied' : 'mocked',
);
} else {
$templateFile = sprintf(
'%s_method.tpl',
$this->callOriginalMethod ? 'proxied' : 'mocked'
$this->callOriginalMethod ? 'proxied' : 'mocked',
);
}
@@ -209,7 +209,7 @@ final class MockMethod
$deprecationTemplate->setVar(
[
'deprecation' => var_export($deprecation, true),
]
],
);
$deprecation = $deprecationTemplate->render();
@@ -230,7 +230,7 @@ final class MockMethod
'reference' => $this->reference,
'clone_arguments' => $this->cloneArguments ? 'true' : 'false',
'deprecation' => $deprecation,
]
],
);
return $template->render();
@@ -255,7 +255,7 @@ final class MockMethod
throw new RuntimeException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
}
@@ -361,18 +361,18 @@ final class MockMethod
substr(
substr(
$parameterAsString,
strpos($parameterAsString, '<optional> ') + strlen('<optional> ')
strpos($parameterAsString, '<optional> ') + strlen('<optional> '),
),
0,
-2
)
-2,
),
)[1];
// @codeCoverageIgnoreStart
} catch (\ReflectionException $e) {
throw new ReflectionException(
$e->getMessage(),
$e->getCode(),
$e
$e,
);
}
// @codeCoverageIgnoreEnd

View File

@@ -47,8 +47,8 @@ final class ConsecutiveParameters implements ParametersRule
sprintf(
'Parameter group #%d must be an array or Traversable, got %s',
$index,
gettype($parameters)
)
gettype($parameters),
),
);
}
@@ -111,8 +111,8 @@ final class ConsecutiveParameters implements ParametersRule
throw new ExpectationFailedException(
sprintf(
'Parameter count for invocation %s is too low.',
$invocation->toString()
)
$invocation->toString(),
),
);
}
@@ -124,8 +124,8 @@ final class ConsecutiveParameters implements ParametersRule
'value.',
$i,
$callIndex,
$invocation->toString()
)
$invocation->toString(),
),
);
}
}

View File

@@ -64,8 +64,8 @@ final class InvokedAtIndex extends InvocationOrder
throw new ExpectationFailedException(
sprintf(
'The expected invocation at index %s was never reached.',
$this->sequenceIndex
)
$this->sequenceIndex,
),
);
}
}

View File

@@ -48,7 +48,7 @@ final class InvokedAtLeastCount extends InvocationOrder
if ($count < $this->requiredInvocations) {
throw new ExpectationFailedException(
'Expected invocation at least ' . $this->requiredInvocations .
' times but it occurred ' . $count . ' time(s).'
' times but it occurred ' . $count . ' time(s).',
);
}
}

View File

@@ -34,7 +34,7 @@ final class InvokedAtLeastOnce extends InvocationOrder
if ($count < 1) {
throw new ExpectationFailedException(
'Expected invocation at least once but it never occurred.'
'Expected invocation at least once but it never occurred.',
);
}
}

View File

@@ -48,7 +48,7 @@ final class InvokedAtMostCount extends InvocationOrder
if ($count > $this->allowedInvocations) {
throw new ExpectationFailedException(
'Expected invocation at most ' . $this->allowedInvocations .
' times but it occurred ' . $count . ' time(s).'
' times but it occurred ' . $count . ' time(s).',
);
}
}

View File

@@ -62,8 +62,8 @@ final class InvokedCount extends InvocationOrder
'Method was expected to be called %d times, ' .
'actually called %d times.',
$this->expectedCount,
$count
)
$count,
),
);
}
}
@@ -92,7 +92,7 @@ final class InvokedCount extends InvocationOrder
default:
$message .= sprintf(
'was not expected to be called more than %d times.',
$this->expectedCount
$this->expectedCount,
);
}

View File

@@ -47,7 +47,7 @@ final class Parameters implements ParametersRule
foreach ($parameters as $parameter) {
if (!($parameter instanceof Constraint)) {
$parameter = new IsEqual(
$parameter
$parameter,
);
}
@@ -127,7 +127,7 @@ final class Parameters implements ParametersRule
}
throw new ExpectationFailedException(
sprintf($message, $this->invocation->toString())
sprintf($message, $this->invocation->toString()),
);
}
@@ -138,8 +138,8 @@ final class Parameters implements ParametersRule
'Parameter %s for invocation %s does not match expected ' .
'value.',
$i,
$this->invocation->toString()
)
$this->invocation->toString(),
),
);
}

View File

@@ -51,7 +51,7 @@ final class ConsecutiveCalls implements Stub
return sprintf(
'return user-specified value %s',
$exporter->export($this->value)
$exporter->export($this->value),
);
}
}

View File

@@ -40,7 +40,7 @@ final class Exception implements Stub
return sprintf(
'raise user-specified exception %s',
$exporter->export($this->exception)
$exporter->export($this->exception),
);
}
}

View File

@@ -49,7 +49,7 @@ final class ReturnCallback implements Stub
'passed arguments',
$class,
$type,
$this->callback[1]
$this->callback[1],
);
}

View File

@@ -39,7 +39,7 @@ final class ReturnReference implements Stub
return sprintf(
'return user-specified reference %s',
$exporter->export($this->reference)
$exporter->export($this->reference),
);
}
}

View File

@@ -39,7 +39,7 @@ final class ReturnStub implements Stub
return sprintf(
'return user-specified value %s',
$exporter->export($this->value)
$exporter->export($this->value),
);
}
}

Some files were not shown because too many files have changed in this diff Show More