Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/Type/Php/StrContainingTypeSpecifyingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\Reflection\FunctionReflection;
use PHPStan\ShouldNotHappenException;
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\FunctionTypeSpecifyingExtension;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\StringType;
Expand Down Expand Up @@ -86,13 +84,6 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n
$accessories[] = new AccessoryNonEmptyStringType();
}

if ($haystackType->isLiteralString()->yes()) {
$accessories[] = new AccessoryLiteralStringType();
}
if ($haystackType->isNumericString()->yes()) {
$accessories[] = new AccessoryNumericStringType();
}
Comment on lines -89 to -94

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while looking into whether we are missing uppercase/lowercase handling here, I realized this code is not necessary at all

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened phpstan/phpstan#14594 btw


return $this->typeSpecifier->create(
$args[$hackstackArg]->value,
new IntersectionType($accessories),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class Foo {
* @param numeric-string $numS
* @param literal-string $literalS
* @param non-empty-string&numeric-string $nonEAndNumericS
* @param uppercase-string $upper
* @param lowercase-string $lower
*/
public function strContains(string $s, string $s2, $nonES, $nonFalsy, $numS, $literalS, $nonEAndNumericS, int $i): void
public function strContains(string $s, string $s2, $nonES, $nonFalsy, $numS, $literalS, $nonEAndNumericS, int $i, $upper, $lower): void
{
if (str_contains($i, 0)) {
assertType('int', $i);
Expand Down Expand Up @@ -72,6 +74,16 @@ public function strContains(string $s, string $s2, $nonES, $nonFalsy, $numS, $li
if (str_contains($numS, $nonFalsy)) {
assertType('non-falsy-string&numeric-string', $numS);
}

if (str_contains($upper, ':')) {
assertType('non-falsy-string&uppercase-string', $upper);
}
assertType('uppercase-string', $upper);

if (str_contains($lower, ':')) {
assertType('lowercase-string&non-falsy-string', $lower);
}
assertType('lowercase-string', $lower);
}

public function variants(string $s) {
Expand Down
Loading