Skip to content

Commit 0d626cb

Browse files
authored
Bleeding edge - More precise file() flags args
1 parent be378e1 commit 0d626cb

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Diff for: resources/functionMap_bleedingEdge.php

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
'ImagickKernel::scale' => ['void', 'scale'=>'float', 'normalizeFlag'=>'Imagick::NORMALIZE_KERNEL_*'],
108108
'max' => ['', '...arg1'=>'non-empty-array'],
109109
'min' => ['', '...arg1'=>'non-empty-array'],
110+
'file' => ['list<string>|false', 'filename'=>'string', 'flags='=>'0|FILE_USE_INCLUDE_PATH|FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES', 'context='=>'resource'],
110111
],
111112
'old' => [
112113

Diff for: tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -1368,4 +1368,14 @@ public function testBenevolentSuperglobalKeys(): void
13681368
$this->analyse([__DIR__ . '/data/benevolent-superglobal-keys.php'], []);
13691369
}
13701370

1371+
public function testFileParams(): void
1372+
{
1373+
$this->analyse([__DIR__ . '/data/file.php'], [
1374+
[
1375+
'Parameter #2 $flags of function file expects 0|1|2|4, 8 given.',
1376+
16,
1377+
],
1378+
]);
1379+
}
1380+
13711381
}

Diff for: tests/PHPStan/Rules/Functions/data/file.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace fileFlags;
4+
5+
class Foo {
6+
public function ok():void {
7+
$lines = file('http://www.example.com/');
8+
$lines1 = file('http://www.example.com/', 0);
9+
10+
$f1 = file(__FILE__, FILE_USE_INCLUDE_PATH);
11+
$f2 = file(__FILE__, FILE_IGNORE_NEW_LINES);
12+
$f3 = file(__FILE__, FILE_SKIP_EMPTY_LINES);
13+
}
14+
15+
public function error():void {
16+
$f = file(__FILE__, FILE_APPEND);
17+
}
18+
}

0 commit comments

Comments
 (0)