Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,54 @@
use Generator;
use PhpParser\Node\Expr;
use PhpParser\Node\Scalar\Float_;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt;
use PHPStan\Analyser\ExpressionContext;
use PHPStan\Analyser\Generator\ExprAnalysisResult;
use PHPStan\Analyser\Generator\ExprHandler;
use PHPStan\Analyser\Generator\GeneratorScope;
use PHPStan\Analyser\SpecifiedTypes;
use PHPStan\DependencyInjection\AutowiredService;
use PHPStan\ShouldNotHappenException;
use PHPStan\Type\Constant\ConstantFloatType;
use PHPStan\Type\Constant\ConstantIntegerType;
use PHPStan\Type\Constant\ConstantStringType;

/**
* @implements ExprHandler<Float_>
*/
#[AutowiredService]
final class ScalarFloatHandler implements ExprHandler
final class ScalarHandler implements ExprHandler
{

public function supports(Expr $expr): bool
{
return $expr instanceof Float_;
return $expr instanceof Float_
|| $expr instanceof Int_
|| $expr instanceof String_;
}

public function analyseExpr(
Stmt $stmt,
Expr $expr,
GeneratorScope $scope,

Check failure on line 39 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 39 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.
ExpressionContext $context,
?callable $alternativeNodeCallback,

Check failure on line 41 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 41 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.
): Generator
{

Check failure on line 43 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 43 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.
yield from [];
$type = new ConstantFloatType($expr->value);

if ($expr instanceof Float_) {

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.5)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.

Check failure on line 46 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Instanceof between PhpParser\Node\Scalar\Float_ and PhpParser\Node\Scalar\Float_ will always evaluate to true.
$type = new ConstantFloatType($expr->value);
} elseif ($expr instanceof Int_) {

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.5)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.

Check failure on line 48 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\Int_ will always evaluate to false.
$type = new ConstantIntegerType($expr->value);
} elseif ($expr instanceof String_) {

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.2)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.4)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.5)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan with result cache (8.3)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.

Check failure on line 50 in src/Analyser/Generator/ExprHandler/ScalarHandler.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Instanceof between *NEVER* and PhpParser\Node\Scalar\String_ will always evaluate to false.
$type = new ConstantStringType($expr->value);
} else {
throw new ShouldNotHappenException();
}

return new ExprAnalysisResult(
$type,
$type,
Expand Down
53 changes: 0 additions & 53 deletions src/Analyser/Generator/ExprHandler/ScalarIntHandler.php

This file was deleted.

53 changes: 0 additions & 53 deletions src/Analyser/Generator/ExprHandler/ScalarStringHandler.php

This file was deleted.

Loading