Skip to content

Commit 33a4a68

Browse files
authored
Merge pull request #298 from ray-di/psalm6
2 parents f033242 + e290e15 commit 33a4a68

36 files changed

+1681
-553
lines changed

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"koriym/attributes": "^1.0.4",
1515
"koriym/null-object": "^1.0",
1616
"koriym/param-reader": "^1.0",
17-
"ray/aop": "^2.16",
17+
"ray/aop": "^2.18",
1818
"ray/compiler": "^1.10.3"
1919
},
2020
"require-dev": {
@@ -47,10 +47,11 @@
4747
"cs": ["phpcs --standard=./phpcs.xml src tests"],
4848
"cs-fix": ["phpcbf src tests"],
4949
"clean": ["phpstan clear-result-cache", "psalm --clear-cache", "rm -rf tests/tmp/*.php"],
50-
"sa": ["psalm -m -c psalm.xml --show-info=true", "phpstan analyse -c phpstan.neon --no-progress "],
50+
"sa": ["psalm -m -c psalm.xml --show-info=false", "phpstan analyse -c phpstan.neon --no-progress "],
5151
"metrics": ["@test", "phpmetrics --report-html=build/metrics --exclude=Exception --log-junit=build/junit.xml --junit=build/junit.xml src"],
5252
"phpmd": ["phpmd src/di text ./phpmd.xml"],
53-
"build": ["@cs", "@sa", "@pcov", "@metrics"]
53+
"build": ["@cs", "@sa", "@pcov", "@metrics"],
54+
"baseline": ["phpstan analyse -c phpstan.neon --generate-baseline", "psalm --set-baseline=psalm-baseline.xml"]
5455
},
5556
"extra": {
5657
"bamarni-bin": {

phpstan-baseline.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Negated boolean expression is always false\.$#'
5+
identifier: booleanNot.alwaysFalse
6+
count: 1
7+
path: src/di/AnnotatedClassMethods.php

psalm-baseline.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
3+
<file src="src/di/AnnotatedClassMethods.php">
4+
<DocblockTypeContradiction occurrences="2">
5+
<code>! $constructor</code>
6+
<code>$constructor</code>
7+
</DocblockTypeContradiction>
8+
</file>
9+
<file src="src/di/AspectBind.php">
10+
<MixedArrayOffset occurrences="1">
11+
<code>$instantiatedBindings[$methodName]</code>
12+
</MixedArrayOffset>
13+
<MixedAssignment occurrences="3">
14+
<code>$interceptorClassName</code>
15+
<code>$interceptorClassNames</code>
16+
<code>$methodName</code>
17+
</MixedAssignment>
18+
<MixedReturnTypeCoercion occurrences="2">
19+
<code>$instantiatedBindings</code>
20+
<code>array&lt;non-empty-string, list&lt;MethodInterceptor&gt;&gt;</code>
21+
</MixedReturnTypeCoercion>
22+
</file>
23+
<file src="src/di/Dependency.php">
24+
<InvalidArgument occurrences="1">
25+
<code>$pointcuts</code>
26+
</InvalidArgument>
27+
</file>
28+
<file src="src/di/NewInstance.php">
29+
<InvalidArgument occurrences="1">
30+
<code>$this-&gt;bind-&gt;inject($container)</code>
31+
</InvalidArgument>
32+
</file>
33+
</files>

psalm.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config https://psalm.dev/schema/config"
7+
findUnusedCode="false"
78
>
89
<projectFiles>
910
<directory name="src/di"/>
10-
<directory name="tests/type"/>
1111
</projectFiles>
1212
<stubs>
1313
<file name="tests/stub/BindInterface.phpstub"/>
1414
</stubs>
15-
<plugins><pluginClass class="Psalm\PhpUnitPlugin\Plugin"/></plugins></psalm>
15+
<issueHandlers>
16+
<MissingOverrideAttribute errorLevel="suppress"/>
17+
</issueHandlers>
18+
</psalm>

src/di/AnnotatedClassMethods.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Ray\Di\Di\InjectInterface;
1010
use Ray\Di\Di\Named;
1111

12+
use function assert;
13+
1214
use const PHP_VERSION_ID;
1315

1416
final class AnnotatedClassMethods
@@ -38,6 +40,7 @@ public function getConstructorName(ReflectionClass $class): Name
3840
}
3941
}
4042

43+
assert($constructor instanceof ReflectionMethod);
4144
$named = $constructor->getAnnotation(Named::class);
4245
if ($named instanceof Named) {
4346
return new Name($named->value);

src/di/AspectBind.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(AopBind $bind)
2222
/**
2323
* Instantiate interceptors
2424
*
25-
* @return array<string, list<MethodInterceptor>>
25+
* @return array<non-empty-string, list<MethodInterceptor>>
2626
*/
2727
public function inject(Container $container): array
2828
{

src/di/AssistedInjectModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Assisted module for php8 attributes
1111
*/
12-
class AssistedInjectModule extends AbstractModule
12+
final class AssistedInjectModule extends AbstractModule
1313
{
1414
protected function configure(): void
1515
{

src/di/AssistedModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use const PHP_VERSION_ID;
1111

12-
class AssistedModule extends AbstractModule
12+
final class AssistedModule extends AbstractModule
1313
{
1414
protected function configure(): void
1515
{

src/di/Bind.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function toConstructor(string $class, $name, ?InjectionPoints $injectionP
117117
}
118118

119119
$this->untarget = null;
120-
$postConstructRef = $postConstruct ? new ReflectionMethod($class, $postConstruct) : null;
120+
$postConstructRef = $postConstruct !== null ? new ReflectionMethod($class, $postConstruct) : null;
121121
/** @var ReflectionClass<object> $reflection */
122122
$reflection = new ReflectionClass($class);
123123
$this->bound = (new DependencyFactory())->newToConstructor($reflection, $name, $injectionPoints, $postConstructRef);

src/di/BindValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function to(string $interface, string $class): ReflectionClass
4242
throw new InvalidType("[{$class}] is no implemented [{$interface}] interface");
4343
}
4444

45-
return new ReflectionClass($class); // @phpstan-ignore-line
45+
return new ReflectionClass($class);
4646
}
4747

4848
/**

0 commit comments

Comments
 (0)