mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Don't report InvalidLiteralArgument for paths
This commit is contained in:
parent
f3e950bac7
commit
9730f2c073
@ -71,7 +71,9 @@ use function reset;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function substr;
|
||||
use function substr_count;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PREG_SPLIT_NO_EMPTY;
|
||||
|
||||
/**
|
||||
@ -174,7 +176,9 @@ class ArgumentAnalyzer
|
||||
$prev_ord = $ord;
|
||||
}
|
||||
|
||||
if (count($values) < 12 || ($gt_count / count($values)) < 0.8) {
|
||||
if (substr_count($arg_value_type->getSingleStringLiteral()->value, DIRECTORY_SEPARATOR) <= 2
|
||||
&& (count($values) < 12 || ($gt_count / count($values)) < 0.8)
|
||||
) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new InvalidLiteralArgument(
|
||||
'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id
|
||||
|
@ -262,6 +262,12 @@ class CoreStubsTest extends TestCase
|
||||
'$c===' => 'false|string',
|
||||
],
|
||||
];
|
||||
yield "str_contains doesn't yield InvalidLiteralArgument for __DIR__" => [
|
||||
'code' => '<?php
|
||||
$d = __DIR__;
|
||||
echo str_contains($d, "psalm");
|
||||
',
|
||||
];
|
||||
}
|
||||
|
||||
public function providerInvalidCodeParse(): iterable
|
||||
|
Loading…
Reference in New Issue
Block a user