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
1 change: 1 addition & 0 deletions resources/functionMap_bleedingEdge.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +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='=>'0|FILE_USE_INCLUDE_PATH|FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES', 'context='=>'resource'],
Copy link
Copy Markdown
Contributor

@iluuu1994 iluuu1994 Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing the FILE_NO_DEFAULT_CONTEXT flag (which is apparently undocumented).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks will have a look

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

],
'old' => [

Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1368,4 +1368,14 @@ public function testBenevolentSuperglobalKeys(): void
$this->analyse([__DIR__ . '/data/benevolent-superglobal-keys.php'], []);
}

public function testFileParams(): void
{
$this->analyse([__DIR__ . '/data/file.php'], [
[
'Parameter #2 $flags of function file expects 0|1|2|4, 8 given.',
16,
],
]);
}

}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/Functions/data/file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace fileFlags;

class Foo {
public function ok():void {
$lines = file('http://www.example.com/');
$lines1 = file('http://www.example.com/', 0);

$f1 = file(__FILE__, FILE_USE_INCLUDE_PATH);
$f2 = file(__FILE__, FILE_IGNORE_NEW_LINES);
$f3 = file(__FILE__, FILE_SKIP_EMPTY_LINES);
}

public function error():void {
$f = file(__FILE__, FILE_APPEND);
}
}