diff --git a/resources/functionMap.php b/resources/functionMap.php index fade07b20c..69266f315d 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -11661,7 +11661,7 @@ 'stream_filter_prepend' => ['resource|false', 'stream'=>'resource', 'filtername'=>'string', 'read_write='=>'int', 'params='=>'mixed'], 'stream_filter_register' => ['bool', 'filtername'=>'string', 'classname'=>'string'], 'stream_filter_remove' => ['bool', 'stream_filter'=>'resource'], -'stream_get_contents' => ['string|false', 'source'=>'resource', 'maxlen='=>'int', 'offset='=>'int'], +'stream_get_contents' => ['__benevolent', 'source'=>'resource', 'maxlen='=>'int', 'offset='=>'int'], 'stream_get_filters' => ['list'], 'stream_get_line' => ['string|false', 'stream'=>'resource', 'maxlen'=>'int', 'ending='=>'string'], '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'], diff --git a/src/Type/Php/StreamGetContentsFunctionReturnTypeExtension.php b/src/Type/Php/StreamGetContentsFunctionReturnTypeExtension.php deleted file mode 100644 index 791f0d85ab..0000000000 --- a/src/Type/Php/StreamGetContentsFunctionReturnTypeExtension.php +++ /dev/null @@ -1,41 +0,0 @@ -getName() === 'stream_get_contents'; - } - - public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): ?Type - { - if (count($functionCall->getArgs()) >= 3) { - return null; - } - - // stream_get_contents() does not return FALSE unless an invalid offset is provided. - $returnType = ParametersAcceptorSelector::selectFromArgs( - $scope, - $functionCall->getArgs(), - $functionReflection->getVariants(), - )->getReturnType(); - - return TypeCombinator::remove($returnType, new ConstantBooleanType(false)); - } - -} diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index d423d80dbb..bf135b42a6 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -3615,12 +3615,7 @@ public function testBug3396(): void $this->checkUnionTypes = true; $this->checkExplicitMixed = false; - $this->analyse([__DIR__ . '/data/bug-3396.php'], [ - [ - 'Parameter #1 $s of method Bug3396\HelloWorld::takesString() expects string, string|false given.', - 18, - ], - ]); + $this->analyse([__DIR__ . '/data/bug-3396.php'], []); } }