Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/Type/Accessory/HasMethodType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace PHPStan\Type\Accessory;

use Closure;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Reflection\ClassMemberAccessAnswerer;
Expand Down Expand Up @@ -83,7 +84,11 @@
return $otherType->isSuperTypeOf($this);
}

if ($this->isCallable()->yes() && $otherType->isCallable()->yes()) {
if (
$this->isCallable()->yes()
&& $otherType->isCallable()->yes()
&& !($otherType->isObject()->yes() && $otherType->isInstanceOf(Closure::class)->yes())

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.5)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, ubuntu-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, windows-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Call to an undefined method PHPStan\Type\Type::isInstanceOf().

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

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

Call to an

Check failure on line 90 in src/Type/Accessory/HasMethodType.php

View workflow job for this annotation

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

Call to an
) {
return IsSuperTypeOfResult::createYes();
}

Expand Down
6 changes: 6 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,12 @@ public function testBug13980(): void
$this->assertNoErrors($errors);
}

public function testBug13975(): void
{
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13975.php');
$this->assertNoErrors($errors);
}

/**
* @param string[]|null $allAnalysedFiles
* @return list<Error>
Expand Down
18 changes: 18 additions & 0 deletions tests/PHPStan/Analyser/data/bug-13975.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace Bug13975;

function foo(): callable
{
return new class () {
public function __invoke(): void
{
}
};
}

$foo = foo();

if (\is_object($foo) && method_exists($foo, '__invoke') && !$foo instanceof \Closure) {
echo 'true';
}
Loading