Skip to content

Commit a817abf

Browse files
authored
use benevolent union for stream_get_contents() to prevent strict-rule errors (#4146)
1 parent 9dbff97 commit a817abf

File tree

3 files changed

+2
-48
lines changed

3 files changed

+2
-48
lines changed

resources/functionMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11366,7 +11366,7 @@
1136611366
'stream_filter_prepend' => ['resource|false', 'stream'=>'resource', 'filtername'=>'string', 'read_write='=>'int', 'params='=>'mixed'],
1136711367
'stream_filter_register' => ['bool', 'filtername'=>'string', 'classname'=>'string'],
1136811368
'stream_filter_remove' => ['bool', 'stream_filter'=>'resource'],
11369-
'stream_get_contents' => ['string|false', 'source'=>'resource', 'maxlen='=>'int', 'offset='=>'int'],
11369+
'stream_get_contents' => ['__benevolent<string|false>', 'source'=>'resource', 'maxlen='=>'int', 'offset='=>'int'],
1137011370
'stream_get_filters' => ['list<string>'],
1137111371
'stream_get_line' => ['string|false', 'stream'=>'resource', 'maxlen'=>'int', 'ending='=>'string'],
1137211372
'stream_get_meta_data' => ['array{timed_out:bool,blocked:bool,eof:bool,unread_bytes:int,stream_type:string,wrapper_type:string,wrapper_data:mixed,mode:string,seekable:bool,uri?:string,mediatype?:string,base64?:bool}', 'fp'=>'resource'],

src/Type/Php/StreamGetContentsFunctionReturnTypeExtension.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,12 +3653,7 @@ public function testBug3396(): void
36533653
$this->checkUnionTypes = true;
36543654
$this->checkExplicitMixed = false;
36553655

3656-
$this->analyse([__DIR__ . '/data/bug-3396.php'], [
3657-
[
3658-
'Parameter #1 $s of method Bug3396\HelloWorld::takesString() expects string, string|false given.',
3659-
18,
3660-
],
3661-
]);
3656+
$this->analyse([__DIR__ . '/data/bug-3396.php'], []);
36623657
}
36633658

36643659
}

0 commit comments

Comments
 (0)