Skip to content

Commit

Permalink
More precise string-containing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jan 6, 2025
1 parent 05279fb commit b1fb846
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Type/Php/StrContainingTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n
[$hackstackArg, $needleArg] = self::STR_CONTAINING_FUNCTIONS[strtolower($functionReflection->getName())];

$haystackType = $scope->getType($args[$hackstackArg]->value);
$needleType = $scope->getType($args[$needleArg]->value);
$needleType = $scope->getType($args[$needleArg]->value)->toString();

if ($needleType->isNonEmptyString()->yes() && $haystackType->isString()->yes()) {
$accessories = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class Foo {
*/
public function strContains(string $s, string $s2, $nonES, $nonFalsy, $numS, $literalS, $nonEAndNumericS, int $i): void
{
if (str_contains($s, 0)) {
assertType('non-empty-string', $s);
}
if (str_contains($s, 1)) {
assertType('non-falsy-string', $s);
}

if (str_contains($s, ':')) {
assertType('non-falsy-string', $s);
}
Expand Down

0 comments on commit b1fb846

Please sign in to comment.