Skip to content

Commit

Permalink
validate phpstan lvl 3
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed Mar 6, 2023
1 parent c79c29c commit 7f7a18b
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 45 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/phpspec.yaml
Expand Up @@ -5,6 +5,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: '**/vendor'
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Set COMPOSER_ROOT_VERSION environment variable"
uses: "ergebnis/composer-root-version-action@main"
with:
branch: "main"
- uses: php-actions/composer@v6
with:
args: --prefer-dist
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/phpstan6.yaml
Expand Up @@ -11,6 +11,10 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Set COMPOSER_ROOT_VERSION environment variable"
uses: "ergebnis/composer-root-version-action@main"
with:
branch: "main"
- uses: php-actions/composer@v6
with:
args: '--prefer-dist'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/phpstan7.yaml
Expand Up @@ -11,6 +11,10 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Set COMPOSER_ROOT_VERSION environment variable"
uses: "ergebnis/composer-root-version-action@main"
with:
branch: "main"
- uses: php-actions/composer@v6
with:
args: '--prefer-dist'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/phpstan8.yaml
Expand Up @@ -11,6 +11,10 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: "Set COMPOSER_ROOT_VERSION environment variable"
uses: "ergebnis/composer-root-version-action@main"
with:
branch: "main"
- uses: php-actions/composer@v6
with:
args: '--prefer-dist'
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/rector.yaml
@@ -1,8 +1,7 @@
# github action that checks code with Rector
name: Rector

on:
pull_request: null
on: pull_request

jobs:
rector:
Expand Down Expand Up @@ -30,6 +29,11 @@ jobs:
php-version: '8.2'
coverage: none

- name: "Set COMPOSER_ROOT_VERSION environment variable"
uses: "ergebnis/composer-root-version-action@main"
with:
branch: "main"

- uses: "ramsey/composer-install@v2"

- run: bin/rector --ansi
Expand Down
68 changes: 34 additions & 34 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ClassMetadataBuilder.php
Expand Up @@ -25,7 +25,7 @@ public function __construct(
/**
* @template Subject of object
* @param ClassReferenceMetadataInterface<Subject> $class
* @return ClassTypeMetadataInterface<Subject>
* @return ClassTypeMetadataInterface
*/
public function buildFromReference(ClassReferenceMetadataInterface $class): ClassTypeMetadataInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/IntersectionTypeMetadata.php
Expand Up @@ -26,7 +26,7 @@ public function count(): int
}

/**
* @return \Traversable<TypeMetadataInterface>
* @return \ArrayIterator<TypeMetadataInterface>
*/
public function getIterator(): \ArrayIterator
{
Expand Down
Expand Up @@ -41,7 +41,7 @@ private function filterTypes(TypeMetadataInterface $type): IterableTypeMetadataI

$filtered = [];
foreach ($type as $inner) {
if (!$type instanceof IterableTypeMetadataInterface) {
if (!$inner instanceof IterableTypeMetadataInterface) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/RelationGuesser/PublicPropertyUnaryRelationGuesser.php
Expand Up @@ -41,7 +41,7 @@ private function filterTypes(TypeMetadataInterface $type): CompositeTypeMetadata

$filtered = [];
foreach ($type as $inner) {
if (!$type instanceof CompositeTypeMetadataInterface) {
if (!$inner instanceof CompositeTypeMetadataInterface) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/RelationGuesser/VirtualRelationGuesser.php
Expand Up @@ -39,7 +39,7 @@ private function isSingular(string $field): bool
/**
* @template Subject of object
* @param ClassTypeMetadataInterface<Subject> $class
* @return \Iterator<RelationMetadataInterface<Subject>>
* @return \Iterator<RelationMetadataInterface>
*/
public function __invoke(ClassTypeMetadataInterface $class): \Iterator
{
Expand Down
8 changes: 4 additions & 4 deletions src/TypeGuesser/Native/NativeTypeGuesser.php
Expand Up @@ -23,19 +23,19 @@ public function __invoke(\ReflectionClass $class, \ReflectionType $reflector): \
yield new IntersectionTypeMetadata(...array_map(fn ($reflector) => $this($class, $reflector), $reflector->getTypes()));
} elseif ($reflector instanceof \ReflectionNamedType && $reflector->isBuiltin()) {
yield $this->builtInType($reflector->getName());
} elseif ('self' === $reflector->getName() || 'static' === $reflector->getName()) {
} elseif ('self' === (string) $reflector || 'static' === (string) $reflector) {
try {
$classReflector = new \ReflectionClass($class->getName());
yield new ClassReferenceMetadata(
$classReflector->getShortName(),
$classReflector->getNamespaceName()
);
} catch (\ReflectionException $e) {
throw new \RuntimeException(strtr('The class %class.name% was not declared. It does either not exist or it does not have been auto-loaded.', ['%class.name%' => $reflector->getName()]), 0, $e);
throw new \RuntimeException(strtr('The class %class.name% was not declared. It does either not exist or it does not have been auto-loaded.', ['%class.name%' => (string) $reflector]), 0, $e);
}
} else {
try {
$classReflector = new \ReflectionClass($reflector->getName());
$classReflector = new \ReflectionClass($reflector);

if ($classReflector->isAnonymous()) {
throw new \RuntimeException('Reached an unexpected anonymous class.');
Expand All @@ -45,7 +45,7 @@ public function __invoke(\ReflectionClass $class, \ReflectionType $reflector): \
$classReflector->getNamespaceName()
);
} catch (\ReflectionException $e) {
throw new \RuntimeException(strtr('The class %class.name% was not declared. It does either not exist or it does not have been auto-loaded.', ['%class.name%' => $reflector->getName()]), 0, $e);
throw new \RuntimeException(strtr('The class %class.name% was not declared. It does either not exist or it does not have been auto-loaded.', ['%class.name%' => (string) $reflector]), 0, $e);
}
}

Expand Down

0 comments on commit 7f7a18b

Please sign in to comment.