Skip to content

Commit

Permalink
Merge branch '11.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 22, 2024
2 parents 03c1666 + ac2a438 commit 5088d47
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 19 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 @@ -194,7 +194,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 @@ -1197,7 +1197,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 @@ -1384,7 +1384,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 @@ -1401,7 +1401,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 @@ -1588,7 +1588,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 @@ -187,7 +187,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 @@ -1373,7 +1373,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 @@ -1582,7 +1582,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 @@ -1601,7 +1601,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 @@ -1810,7 +1810,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 @@ -77,7 +77,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
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Generator/DoubledMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ 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,
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/MockObject/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,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
1 change: 0 additions & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,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 5088d47

Please sign in to comment.