Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Oct 20, 2024
1 parent 12271ac commit 3088f94
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PHPStan\Parser\LastConditionVisitor;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use function count;
use function sprintf;
use function strtolower;

Expand Down
3 changes: 2 additions & 1 deletion src/Rules/Comparison/ImpossibleCheckTypeMethodCallRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\ShouldNotHappenException;
use function count;
use function sprintf;

/**
Expand Down Expand Up @@ -45,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array
}

$addTip = function (RuleErrorBuilder $ruleErrorBuilder) use ($scope, $node, $reasons): RuleErrorBuilder {
if (count($reasons)) {
if (count($reasons) > 0) {
return $ruleErrorBuilder->acceptsReasonsTip($reasons);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
use PHPStan\ShouldNotHappenException;
use function count;
use function sprintf;

/**
Expand Down Expand Up @@ -46,7 +47,6 @@ public function processNode(Node $node, Scope $scope): array

$addTip = function (RuleErrorBuilder $ruleErrorBuilder) use ($scope, $node, $reasons): RuleErrorBuilder {
if (count($reasons) > 0) {
var_dump($reasons);die;
return $ruleErrorBuilder->acceptsReasonsTip($reasons);
}

Expand Down
12 changes: 9 additions & 3 deletions src/Type/Accessory/AccessoryLowercaseStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use PHPStan\Type\Type;
use PHPStan\Type\UnionType;
use PHPStan\Type\VerbosityLevel;
use function sprintf;

class AccessoryLowercaseStringType implements CompoundType, AccessoryType
{
Expand Down Expand Up @@ -110,9 +111,14 @@ public function isSubTypeOfWithReason(Type $otherType): IsSuperTypeOfResult
return $otherType->isSuperTypeOfWithReason($this);
}

return (new IsSuperTypeOfResult($otherType->isLowercaseString(), [
sprintf("%s is not lowercase.", $otherType->describe(VerbosityLevel::value())),
]))
$isLowercase = $otherType->isLowercaseString();

return (new IsSuperTypeOfResult(
$isLowercase,
$otherType->isString()->yes() && $isLowercase->no()
? [sprintf("%s is not lowercase.", $otherType->describe(VerbosityLevel::value()))]
: []
))
->and($otherType instanceof self ? IsSuperTypeOfResult::createYes() : IsSuperTypeOfResult::createMaybe());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ public function testBug11799(): void
11,
"• 'publishDate' is not lowercase.
• 'approvedAt' is not lowercase.
• 'allowedValues' is not lowercase."
• 'allowedValues' is not lowercase.",
],
]);
}
Expand Down

0 comments on commit 3088f94

Please sign in to comment.