Skip to content

Commit

Permalink
Merge branch '11.4' into 11.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 22, 2024
2 parents 4cd4298 + c08158d commit ac2a438
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 21 deletions.
16 changes: 16 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,19 @@ parameters:
level: 6
paths:
- src

treatPhpDocTypesAsCertain: false

ignoreErrors:
# ignore errors caused by defensive programming
- '#Call to function assert\(\) with true will always evaluate to true.#'
- '#Instanceof between .* and .* will always evaluate to true.#'
- '#Strict comparison using !== between .*non-empty-string.* and .* will always evaluate to true.#'
- '#Strict comparison using !== between .*non-falsy-string.* and .* will always evaluate to true.#'
- identifier: argument.named

excludePaths:
- src/Framework/MockObject/Runtime/Api # exclude partial traits, which are only used in runtime generated code

includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
10 changes: 5 additions & 5 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ final public static function assertArrayNotHasKey(int|string $key, array|ArrayAc
}

/**
* @phpstan-assert list $array
* @phpstan-assert list<mixed> $array
*
* @throws ExpectationFailedException
*/
Expand Down Expand Up @@ -1198,7 +1198,7 @@ final public static function assertNotInstanceOf(string $expected, mixed $actual
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert array $actual
* @phpstan-assert array<mixed> $actual
*/
final public static function assertIsArray(mixed $actual, string $message = ''): void
{
Expand Down Expand Up @@ -1385,7 +1385,7 @@ final public static function assertIsCallable(mixed $actual, string $message = '
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert iterable $actual
* @phpstan-assert iterable<mixed> $actual
*/
final public static function assertIsIterable(mixed $actual, string $message = ''): void
{
Expand All @@ -1402,7 +1402,7 @@ final public static function assertIsIterable(mixed $actual, string $message = '
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert !array $actual
* @phpstan-assert !array<mixed> $actual
*/
final public static function assertIsNotArray(mixed $actual, string $message = ''): void
{
Expand Down Expand Up @@ -1589,7 +1589,7 @@ final public static function assertIsNotCallable(mixed $actual, string $message
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert !iterable $actual
* @phpstan-assert !iterable<mixed> $actual
*/
final public static function assertIsNotIterable(mixed $actual, string $message = ''): void
{
Expand Down
10 changes: 5 additions & 5 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function assertArrayNotHasKey(int|string $key, array|ArrayAccess $array, string

if (!function_exists('PHPUnit\Framework\assertIsList')) {
/**
* @phpstan-assert list $array
* @phpstan-assert list<mixed> $array
*
* @throws ExpectationFailedException
*
Expand Down Expand Up @@ -1379,7 +1379,7 @@ function assertNotInstanceOf(string $expected, mixed $actual, string $message =
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert array $actual
* @phpstan-assert array<mixed> $actual
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
Expand Down Expand Up @@ -1588,7 +1588,7 @@ function assertIsCallable(mixed $actual, string $message = ''): void
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert iterable $actual
* @phpstan-assert iterable<mixed> $actual
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
Expand All @@ -1607,7 +1607,7 @@ function assertIsIterable(mixed $actual, string $message = ''): void
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert !array $actual
* @phpstan-assert !array<mixed> $actual
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
Expand Down Expand Up @@ -1816,7 +1816,7 @@ function assertIsNotCallable(mixed $actual, string $message = ''): void
* @throws Exception
* @throws ExpectationFailedException
*
* @phpstan-assert !iterable $actual
* @phpstan-assert !iterable<mixed> $actual
*
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
*
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/Equality/IsEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(mixed $value)
*
* @throws ExpectationFailedException
*/
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): ?bool
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): bool
{
// If $this->value and $other are identical, they are also equal.
// This is the most common path and will allow us to skip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(mixed $value)
*
* @throws ExpectationFailedException
*/
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): ?bool
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): bool
{
// If $this->value and $other are identical, they are also equal.
// This is the most common path and will allow us to skip
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/Equality/IsEqualIgnoringCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(mixed $value)
*
* @throws ExpectationFailedException
*/
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): ?bool
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): bool
{
// If $this->value and $other are identical, they are also equal.
// This is the most common path and will allow us to skip
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Constraint/Equality/IsEqualWithDelta.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(mixed $value, float $delta)
*
* @throws ExpectationFailedException
*/
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): ?bool
public function evaluate(mixed $other, string $description = '', bool $returnResult = false): bool
{
// If $this->value and $other are identical, they are also equal.
// This is the most common path and will allow us to skip
Expand Down
1 change: 0 additions & 1 deletion src/Framework/Constraint/Type/IsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ final class IsType extends Constraint
*/
public function __construct(string $type)
{
/** @phpstan-ignore isset.offset */
if (!isset(self::KNOWN_TYPES[$type])) {
throw new UnknownTypeException($type);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/MockObject/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public function generateClassFromWsdl(string $wsdlFile, string $className, array

try {
$client = new SoapClient($wsdlFile, $options);
$_methods = array_unique($client->__getFunctions());
$_methods = array_unique($client->__getFunctions() ?? []);

unset($client);
} catch (SoapFault $e) {
Expand Down Expand Up @@ -781,7 +781,7 @@ private function generateCodeForTestDoubleClass(string $type, bool $mockObject,

if (is_array($explicitMethods)) {
foreach ($explicitMethods as $methodName) {
if ($class !== null && $class->hasMethod($methodName)) {
if ($class->hasMethod($methodName)) {
$method = $class->getMethod($methodName);

if ($this->canMethodBeDoubled($method)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/MockObject/Generator/MockMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ public function generateCode(): string
'arguments_call' => $this->argumentsForCall,
'return_declaration' => !empty($this->returnType->asString()) ? (': ' . $this->returnType->asString()) : '',
'return_type' => $this->returnType->asString(),
'arguments_count' => $argumentsCount,
'arguments_count' => (string) $argumentsCount,
'class_name' => $this->className,
'method_name' => $this->methodName,
'modifier' => $this->modifier,
'reference' => $this->reference,
'clone_arguments' => $this->cloneArguments ? 'true' : 'false',
'deprecation' => $deprecation,
'deprecation' => $deprecation ?? '',
'return_result' => $returnResult,
],
);
Expand Down
1 change: 0 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,6 @@ private function getActiveErrorHandlers(): array
set_error_handler($handler);
}

/** @phpstan-ignore if.alwaysFalse */
if ($invalidErrorHandlerStack) {
$message = 'At least one error handler is not callable outside the scope it was registered in';

Expand Down
8 changes: 7 additions & 1 deletion src/Runner/Filter/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function assert;
use FilterIterator;
use Iterator;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestSuite;

/**
Expand All @@ -22,7 +23,7 @@
final class Factory
{
/**
* @var list<array{className: class-string, argument: list<non-empty-string>|non-empty-string}>
* @var list<array{className: class-string<FilterIterator<int, Test, Iterator<int, Test>>>, argument: list<non-empty-string>|non-empty-string}>
*/
private array $filters = [];

Expand Down Expand Up @@ -81,6 +82,11 @@ public function addExcludeNameFilter(string $name): void
];
}

/**
* @param Iterator<int, Test> $iterator
*
* @return FilterIterator<int, Test, Iterator<int, Test>>
*/
public function factory(Iterator $iterator, TestSuite $suite): FilterIterator
{
foreach ($this->filters as $filter) {
Expand Down

0 comments on commit ac2a438

Please sign in to comment.