Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Jan 15, 2025
2 parents 0b4e510 + abbae6a commit fd645ff
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -961,4 +961,18 @@ public function testBug3979(): void
$this->analyse([__DIR__ . '/data/bug-3979.php'], []);
}

public function testBug8464(): void
{
$this->checkAlwaysTrueCheckTypeFunctionCall = true;

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.1)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 966 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-8464.php'], []);
}

public function testBug8954(): void
{
$this->checkAlwaysTrueCheckTypeFunctionCall = true;

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.1)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.

Check failure on line 973 in tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Access to an undefined property PHPStan\Rules\Comparison\ImpossibleCheckTypeFunctionCallRuleTest::$checkAlwaysTrueCheckTypeFunctionCall.
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-8954.php'], []);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-8464.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php // lint >= 8.0

namespace Bug8464;

final class ObjectUtil
{
/**
* @param class-string $type
*/
public static function instanceOf(mixed $object, string $type): bool
{
return \is_object($object)
&& (
$object::class === $type ||
is_subclass_of($object, $type)
);
}
}
28 changes: 28 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-8954.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types = 1);

namespace Bug8954;

/**
* @template U
* @template V
*
* @param ?class-string<U> $class
* @param class-string<V> $expected
*
* @return ?class-string<V>
*/
function ensureSubclassOf(?string $class, string $expected): ?string {
if ($class === null) {
return $class;
}

if (!class_exists($class)) {
throw new \Exception("Class “{$class}” does not exist.");
}

if (!is_subclass_of($class, $expected)) {
throw new \Exception("Class “{$class}” is not a subclass of “{$expected}”.");
}

return $class;
}

0 comments on commit fd645ff

Please sign in to comment.