Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ parameters:
message: '#^Variable property access on T of PHPStan\\Rules\\RuleError\.$#'
path: ../src/Rules/RuleErrorBuilder.php
-
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, string given\\.$#"
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, 'PHPStan…' given\\.$#"
count: 1
path: ../src/Command/CommandHelper.php
-
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, string given\\.$#"
message: "#^Parameter \\#1 (?:\\$argument|\\$objectOrClass) of class ReflectionClass constructor expects class\\-string\\<PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig\\>\\|PHPStan\\\\ExtensionInstaller\\\\GeneratedConfig, 'PHPStan…' given\\.$#"
count: 1
path: ../src/Diagnose/PHPStanDiagnoseExtension.php
- identifier: ternary.shortNotAllowed
Expand Down
4 changes: 4 additions & 0 deletions src/Type/VerbosityLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@
$moreVerbose = true;
return $type;
}
if ($type->isString()->yes() && $type->isClassString()->yes()) {

Check warning on line 177 in src/Type/VerbosityLevel.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.4, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $moreVerbose = true; return $type; } - if ($type->isString()->yes() && $type->isClassString()->yes()) { + if (!$type->isString()->no() && $type->isClassString()->yes()) { $moreVerbose = true; return $type; }

Check warning on line 177 in src/Type/VerbosityLevel.php

View workflow job for this annotation

GitHub Actions / Mutation Testing (8.3, ubuntu-latest)

Escaped Mutant for Mutator "PHPStan\Infection\TrinaryLogicMutator": @@ @@ $moreVerbose = true; return $type; } - if ($type->isString()->yes() && $type->isClassString()->yes()) { + if (!$type->isString()->no() && $type->isClassString()->yes()) { $moreVerbose = true; return $type; }
$moreVerbose = true;
return $type;
}
return $traverse($type);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ public function testBug4413(): void
require_once __DIR__ . '/data/bug-4413.php';
$this->analyse([__DIR__ . '/data/bug-4413.php'], [
[
'Parameter #1 $date of function Bug4413\takesDate expects class-string<DateTime>, string given.',
'Parameter #1 $date of function Bug4413\takesDate expects class-string<DateTime>, \'stdClass\' given.',
18,
],
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ public function testCallMethods(): void
1461,
],
[
'Parameter #1 $s of method Test\ClassStringWithUpperBounds::doFoo() expects class-string<Exception>, string given.',
'Parameter #1 $s of method Test\ClassStringWithUpperBounds::doFoo() expects class-string<Exception>, \'Throwable\' given.',
1490,
],
[
Expand Down Expand Up @@ -834,7 +834,7 @@ public function testCallMethodsOnThisOnly(): void
1379,
],
[
'Parameter #1 $s of method Test\ClassStringWithUpperBounds::doFoo() expects class-string<Exception>, string given.',
'Parameter #1 $s of method Test\ClassStringWithUpperBounds::doFoo() expects class-string<Exception>, \'Throwable\' given.',
1490,
],
[
Expand Down
6 changes: 3 additions & 3 deletions tests/PHPStan/Rules/Methods/CallStaticMethodsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ public function testBug4550(): void
$this->checkThisOnly = false;
$this->analyse([__DIR__ . '/data/bug-4550.php'], [
[
'Parameter #1 $class of static method Bug4550\Test::valuesOf() expects class-string<Person>, string given.',
"Parameter #1 \$class of static method Bug4550\Test::valuesOf() expects class-string<Person>, 'Person' given.",
34,
],
[
'Parameter #1 $class of static method Bug4550\Test::valuesOf() expects class-string<Person>, string given.',
"Parameter #1 \$class of static method Bug4550\Test::valuesOf() expects class-string<Person>, 'Person' given.",
44,
],
]);
Expand Down Expand Up @@ -579,7 +579,7 @@ public function testTemplateTypeInOneBranchOfConditional(): void
[
'Parameter #1 $params of static method TemplateTypeInOneBranchOfConditional\DriverManager::getConnection() expects array{wrapperClass?: class-string<TemplateTypeInOneBranchOfConditional\Connection>}, array{wrapperClass: \'stdClass\'} given.',
27,
"Offset 'wrapperClass' (class-string<TemplateTypeInOneBranchOfConditional\Connection>) does not accept type string.",
"Offset 'wrapperClass' (class-string<TemplateTypeInOneBranchOfConditional\Connection>) does not accept type 'stdClass'.",
],
[
'Unable to resolve the template type T in call to static method TemplateTypeInOneBranchOfConditional\DriverManager::getConnection()',
Expand Down
14 changes: 14 additions & 0 deletions tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1331,4 +1331,18 @@ public function testBug11430(): void
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-11430.php'], []);
}

public function testBug14440(): void
{
$this->analyse([__DIR__ . '/data/bug-14440.php'], [
[
'Method Bug14440\ChildOne::getCounterpartClass() should return class-string<Bug14440\ChildOne> but returns \'Bug14440\\\\ChildTwo\'.',
18,
],
[
'Method Bug14440\ChildTwo::getCounterpartClass() should return class-string<Bug14440\ChildTwo> but returns \'Bug14440\\\\ChildOne\'.',
27,
],
]);
}

}
29 changes: 29 additions & 0 deletions tests/PHPStan/Rules/Methods/data/bug-14440.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types = 1);

namespace Bug14440;

interface I {}

abstract class A
{
/** @return class-string<static&I> */
abstract public static function getCounterpartClass(): string;
}

final class ChildOne extends A implements I
{
#[\Override]
public static function getCounterpartClass(): string
{
return ChildTwo::class;
}
}

final class ChildTwo extends A implements I
{
#[\Override]
public static function getCounterpartClass(): string
{
return ChildOne::class;
}
}
Loading