Skip to content

Commit 3a4cd59

Browse files
committed
strval accepts Stringable
1 parent 670d04d commit 3a4cd59

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

resources/functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11807,7 +11807,7 @@
1180711807
'strtoupper' => ['string', 'str'=>'string'],
1180811808
'strtr' => ['string', 'str'=>'string', 'from'=>'string', 'to'=>'string'],
1180911809
'strtr\'1' => ['string', 'str'=>'string', 'replace_pairs'=>'array'],
11810-
'strval' => ['string', 'var'=>'scalar|resource|null'],
11810+
'strval' => ['string', 'var'=>'__stringAndStringable|int|float|bool|resource|null'],
1181111811
'substr' => ['__benevolent<string|false>', 'string'=>'string', 'start'=>'int', 'length='=>'int'],
1181211812
'substr_compare' => ['int<-1, 1>|false', 'main_str'=>'string', 'str'=>'string', 'offset'=>'int', 'length='=>'int', 'case_sensitivity='=>'bool'],
1181311813
'substr_count' => ['0|positive-int', 'haystack'=>'string', 'needle'=>'string', 'offset='=>'int', 'length='=>'int'],

tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,4 +1329,13 @@ public function testFilterInputType(): void
13291329
$this->analyse([__DIR__ . '/data/filter-input-type.php'], $errors);
13301330
}
13311331

1332+
public function testBug9283(): void
1333+
{
1334+
if (PHP_VERSION_ID < 80000) {
1335+
$this->markTestSkipped('Test requires PHP 8.0');
1336+
}
1337+
1338+
$this->analyse([__DIR__ . '/data/bug-9283.php'], []);
1339+
}
1340+
13321341
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types = 1); // lint >= 8.0
2+
3+
namespace Bug9283;
4+
5+
/**
6+
* @param \Stringable $obj
7+
*/
8+
function test(object $obj): string {
9+
return strval($obj);
10+
}

0 commit comments

Comments
 (0)