Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Jun 12, 2023
1 parent 92ccad7 commit 7d72199
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -22,6 +22,7 @@
use function array_fill;
use function array_pop;
use function count;
use function preg_match;
use function sprintf;

/**
Expand Down Expand Up @@ -93,7 +94,8 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev
if (preg_match('/^%(?:\d+\$)?[-+]?0(?:\.0)?s$/', $type->getSingleStringLiteral()->value) === 1) {
IssueBuffer::maybeAdd(
new InvalidArgument(
'The pattern of argument 1 of ' . $event->getFunctionId() . ' will always return an empty string',
'The pattern of argument 1 of ' . $event->getFunctionId()
. ' will always return an empty string',
$event->getCodeLocation(),
$event->getFunctionId(),
),
Expand All @@ -108,12 +110,17 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev
}

// placeholders are too complex to handle for now
if (preg_match('/%(?:\d+\$)?[-+]?(?:\d+|\*)(?:\.(?:\d+|\*))?[bcdouxXeEfFgGhHs]/', $type->getSingleStringLiteral()->value) === 1) {
if (preg_match(
'/%(?:\d+\$)?[-+]?(?:\d+|\*)(?:\.(?:\d+|\*))?[bcdouxXeEfFgGhHs]/',
$type->getSingleStringLiteral()->value
) === 1
) {
if ($event->getFunctionId() === 'printf') {
return null;
}

// the core stubs are wrong for these too, since these might be empty strings, e.g. sprintf(\'%0.*s\', 0, "abc")
// the core stubs are wrong for these too, since these might be empty strings
// e.g. sprintf(\'%0.*s\', 0, "abc")
return Type::getString();
}

Expand Down

0 comments on commit 7d72199

Please sign in to comment.