Skip to content
Merged
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
2 changes: 1 addition & 1 deletion stubs/typeCheckingFunctions.stub
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function is_long(mixed $value): bool

/**
* @phpstan-assert-if-true =resource $value
* @return bool
* @return ($value is resource ? bool : false)
*/
function is_resource(mixed $value): bool
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,12 @@ public function testBug12087c(): void
]);
}

public function testBug10394(): void
{
$this->treatPhpDocTypesAsCertain = true;
$this->analyse([__DIR__ . '/data/bug-10394.php'], []);
}

public function testBug9666(): void
{
$tipText = 'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.';
Expand Down
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-10394.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Bug10394;

class SomeClass
{
private int $integer = 0;

public function __construct()
{
// try commenting this out!
$this->integer = 45;

if (is_resource($this->integer)) {
throw new \Exception('A resource??');
}
}
}
Loading