Skip to content

Commit

Permalink
Housekeep: PHPStan 0.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
radimvaculik authored and f3l1x committed Jan 12, 2021
1 parent 0997bee commit 819a22c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
"nette/caching": "~3.0.0",
"ninjify/qa": "^0.8.0",
"ninjify/nunjuck": "^0.2.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-nette": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11"
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-nette": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12"
},
"conflict": {
"nette/di": "<=3.0.0-RC"
Expand Down
8 changes: 6 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ parameters:
# Multiple methods of casting to string are available, is it possible to check them all?
- '#^Cannot cast Nette\\Reflection\\IAnnotation to string\.$#'

# phpstan bug - https://github.com/phpstan/phpstan/issues/1482
- "#^Call to function method_exists\\(\\) with string and 'getEntityClassNames' will always evaluate to false\\.$#"
includes:
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
10 changes: 7 additions & 3 deletions src/DI/NextrasOrmEventsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ private function loadListeners(array $mapping): void
throw new ServiceCreationException(sprintf("Entity class '%s' not found", $entity));
}

$types = class_uses($entity) + [$entity];
$types = [$entity];
$uses = class_uses($entity);
if ($uses !== false) {
$types = $uses + [$entity];
}

foreach ($types as $type) {
// Parse annotations from phpDoc
$rf = new ClassType($type);
$rf = ClassType::from($type);

// Add entity/trait as dependency
$builder->addDependency($rf);
Expand Down Expand Up @@ -168,7 +172,7 @@ private function loadListenerByAnnotation(array $events, string $repository, str

foreach ($events as $event => $interface) {
// Check implementation
$rf = new ClassType($listener);
$rf = ClassType::from($listener);
if ($rf->implementsInterface($interface) === false) {
throw new ServiceCreationException(sprintf("Object '%s' should implement '%s'", $listener, $interface));
}
Expand Down

0 comments on commit 819a22c

Please sign in to comment.