Skip to content

Support FILE_NO_DEFAULT_CONTEXT in file() #2482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 27, 2023
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 resources/functionMap_bleedingEdge.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
'ImagickKernel::scale' => ['void', 'scale'=>'float', 'normalizeFlag'=>'Imagick::NORMALIZE_KERNEL_*'],
'max' => ['', '...arg1'=>'non-empty-array'],
'min' => ['', '...arg1'=>'non-empty-array'],
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'int-mask<FILE_USE_INCLUDE_PATH|FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES>', 'context='=>'resource'],
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'int-mask<FILE_USE_INCLUDE_PATH|FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES|FILE_NO_DEFAULT_CONTEXT>', 'context='=>'resource'],
'flock' => ['bool', 'fp'=>'resource', 'operation'=>'int-mask<LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB>', '&w_wouldblock='=>'int'],
],
'old' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ public function testFileParams(): void
{
$this->analyse([__DIR__ . '/data/file.php'], [
[
'Parameter #2 $flags of function file expects int<0, 7>, 8 given.',
'Parameter #2 $flags of function file expects 0|1|2|3|4|5|6|7|16|17|18|19|20|21|22|23, 8 given.',
16,
],
]);
Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Rules/Functions/data/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public function error():void {
$f = file(__FILE__, FILE_APPEND);
}

public function noContext():void {
$f = file(__FILE__, FILE_NO_DEFAULT_CONTEXT);
}

public function doFoo():void {
$fileLines = file(__FILE__, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
Expand Down