mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
parent
e552925af6
commit
c2f7422e80
@ -140,32 +140,34 @@ class ArgumentAnalyzer
|
||||
&& !$arg->value instanceof PhpParser\Node\Expr\ConstFetch
|
||||
) {
|
||||
$values = \preg_split('//u', $arg_value_type->getSingleStringLiteral()->value, -1, \PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
if ($values !== false) {
|
||||
$prev_ord = 0;
|
||||
|
||||
$prev_ord = 0;
|
||||
$gt_count = 0;
|
||||
|
||||
$gt_count = 0;
|
||||
foreach ($values as $value) {
|
||||
$ord = \ord($value);
|
||||
|
||||
foreach ($values as $value) {
|
||||
$ord = \ord($value);
|
||||
if ($ord > $prev_ord) {
|
||||
$gt_count++;
|
||||
}
|
||||
|
||||
if ($ord > $prev_ord) {
|
||||
$gt_count++;
|
||||
$prev_ord = $ord;
|
||||
}
|
||||
|
||||
$prev_ord = $ord;
|
||||
}
|
||||
|
||||
if (count($values) < 12 || ($gt_count / count($values)) < 0.8) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidLiteralArgument(
|
||||
'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id
|
||||
. ' expects a non-literal value, ' . $arg_value_type->getId() . ' provided',
|
||||
new CodeLocation($statements_analyzer->getSource(), $arg->value),
|
||||
$cased_method_id
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
)) {
|
||||
// fall through
|
||||
if (count($values) < 12 || ($gt_count / count($values)) < 0.8) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidLiteralArgument(
|
||||
'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id
|
||||
. ' expects a non-literal value, ' . $arg_value_type->getId() . ' provided',
|
||||
new CodeLocation($statements_analyzer->getSource(), $arg->value),
|
||||
$cased_method_id
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user