Skip to content

Commit

Permalink
refact(*): rector
Browse files Browse the repository at this point in the history
  • Loading branch information
EdenMl committed Nov 6, 2023
1 parent de21405 commit 7a87a43
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/ReturnTypes/RequestDateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;
use function get_class;

class RequestDateExtension implements DynamicMethodReturnTypeExtension
{
Expand All @@ -29,6 +28,6 @@ public function getTypeFromMethodCall(
MethodCall $methodCall,
Scope $scope,
): Type {
return TypeCombinator::addNull(new ObjectType(get_class(now())));
return TypeCombinator::addNull(new ObjectType(now()::class));
}
}
4 changes: 1 addition & 3 deletions src/Rules/CarbonCopyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public function processNode(Node $node, Scope $scope): array
$scope,
$node->var,
'',
static function (Type $type) use ($name): bool {
return $type->canCallMethods()->yes() && $type->hasMethod($name)->yes();
}
static fn (Type $type): bool => $type->canCallMethods()->yes() && $type->hasMethod($name)->yes()
);

$type = $typeResult->getType();
Expand Down
2 changes: 1 addition & 1 deletion tests/ExecutesLarastan.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function execLarastan(string $filename)
$jsonResult
);

return json_decode($jsonResult[0], true);
return json_decode($jsonResult[0], true, 512, JSON_THROW_ON_ERROR);
}

private function analyze(string $file): int
Expand Down
2 changes: 1 addition & 1 deletion tests/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function setUp(): void
$this->configPath = __DIR__ . '/Features/phpstan-tests.neon';
}

public function getFeatures(): array
public static function getFeatures(): array
{
$calls = [];
$baseDir = __DIR__ . DIRECTORY_SEPARATOR . 'Features' . DIRECTORY_SEPARATOR;
Expand Down
4 changes: 1 addition & 3 deletions tests/RulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ protected function findErrorsByLine(string $filename): array
{
$errors = $this->findErrors(realpath($filename));

return collect($errors['messages'] ?? [])->mapWithKeys(function ($message) {
return [$message['line'] => $message['message']];
})->toArray();
return collect($errors['messages'] ?? [])->mapWithKeys(fn ($message) => [$message['line'] => $message['message']])->toArray();
}
}

0 comments on commit 7a87a43

Please sign in to comment.