Skip to content

Commit 016b4ed

Browse files
authored
Merge pull request #300 from koriym/php8.5-support
Add PHP 8.5 support
2 parents f85c539 + be7c607 commit 016b4ed

File tree

5 files changed

+119
-3
lines changed

5 files changed

+119
-3
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
ci:
1010
uses: ray-di/.github/.github/workflows/continuous-integration.yml@v1
1111
with:
12-
old_stable: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"]'
13-
current_stable: 8.4
12+
old_stable: '["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]'
13+
current_stable: 8.5
1414
script: demo/run.php

.sonarcloud.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Exclude GitHub workflow files from security hotspot analysis
2+
sonar.exclusions=.github/workflows/**

phpcs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<!-- Base -->
2929
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
3030
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
31+
<exclude name="Squiz.WhiteSpace.LanguageConstructSpacing"/>
3132
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
3233
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
3334
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
@@ -54,6 +55,7 @@
5455
</rule>
5556

5657
<!-- Additional Rules -->
58+
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
5759
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
5860
<properties>
5961
<property name="searchAnnotations" value="true"/>

src/di/Injector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct($module = null, string $tmpDir = '')
3939
/** @var non-empty-string $classDir */
4040
$classDir = is_dir($tmpDir) ? $tmpDir : sys_get_temp_dir();
4141
if (! is_writable($classDir)) {
42-
throw new DirectoryNotWritable($classDir); // @CodeCoverageIgnore
42+
throw new DirectoryNotWritable($classDir); // @codeCoverageIgnore
4343
}
4444

4545
$this->classDir = $classDir;

tests/di/SetterMethodTest.php

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPUnit\Framework\TestCase;
88
use Ray\Di\Exception\Unbound;
99
use ReflectionMethod;
10+
use ReflectionParameter;
1011

1112
use function spl_object_hash;
1213

@@ -41,4 +42,115 @@ public function testUnbound(): void
4142
$car = new FakeCar(new FakeEngine());
4243
$this->setterMethods->__invoke($car, $container);
4344
}
45+
46+
public function testAcceptWithUnboundException(): void
47+
{
48+
$this->expectException(Unbound::class);
49+
$method = new ReflectionMethod(FakeCar::class, 'setTires');
50+
$setterMethod = new SetterMethod($method, new Name(Name::ANY));
51+
52+
$visitor = new class implements VisitorInterface
53+
{
54+
public function visitSetterMethod(string $method, Arguments $arguments): void
55+
{
56+
throw new Unbound(FakeTyreInterface::class);
57+
}
58+
59+
public function visitDependency(NewInstance $newInstance, ?string $postConstruct, bool $isSingleton): void
60+
{
61+
}
62+
63+
public function visitProvider(Dependency $dependency, string $context, bool $isSingleton): string
64+
{
65+
return '';
66+
}
67+
68+
/** @param mixed $value */
69+
public function visitInstance($value): string
70+
{
71+
return '';
72+
}
73+
74+
public function visitAspectBind(\Ray\Aop\Bind $aopBind): void
75+
{
76+
}
77+
78+
public function visitNewInstance(string $class, SetterMethods $setterMethods, ?Arguments $arguments, ?AspectBind $bind): void
79+
{
80+
}
81+
82+
/** @param array<SetterMethod> $setterMethods */
83+
public function visitSetterMethods(array $setterMethods): void
84+
{
85+
}
86+
87+
/** @param array<Argument> $arguments */
88+
public function visitArguments(array $arguments): void
89+
{
90+
}
91+
92+
/** @param mixed $defaultValue */
93+
public function visitArgument(string $index, bool $isDefaultAvailable, $defaultValue, ReflectionParameter $parameter): void
94+
{
95+
}
96+
};
97+
98+
$setterMethod->accept($visitor);
99+
}
100+
101+
public function testAcceptWithUnboundExceptionOptional(): void
102+
{
103+
$method = new ReflectionMethod(FakeCar::class, 'setTires');
104+
$setterMethod = new SetterMethod($method, new Name(Name::ANY));
105+
$setterMethod->setOptional();
106+
107+
$visitor = new class implements VisitorInterface
108+
{
109+
public function visitSetterMethod(string $method, Arguments $arguments): void
110+
{
111+
throw new Unbound(FakeTyreInterface::class);
112+
}
113+
114+
public function visitDependency(NewInstance $newInstance, ?string $postConstruct, bool $isSingleton): void
115+
{
116+
}
117+
118+
public function visitProvider(Dependency $dependency, string $context, bool $isSingleton): string
119+
{
120+
return '';
121+
}
122+
123+
/** @param mixed $value */
124+
public function visitInstance($value): string
125+
{
126+
return '';
127+
}
128+
129+
public function visitAspectBind(\Ray\Aop\Bind $aopBind): void
130+
{
131+
}
132+
133+
public function visitNewInstance(string $class, SetterMethods $setterMethods, ?Arguments $arguments, ?AspectBind $bind): void
134+
{
135+
}
136+
137+
/** @param array<SetterMethod> $setterMethods */
138+
public function visitSetterMethods(array $setterMethods): void
139+
{
140+
}
141+
142+
/** @param array<Argument> $arguments */
143+
public function visitArguments(array $arguments): void
144+
{
145+
}
146+
147+
/** @param mixed $defaultValue */
148+
public function visitArgument(string $index, bool $isDefaultAvailable, $defaultValue, ReflectionParameter $parameter): void
149+
{
150+
}
151+
};
152+
153+
$result = $setterMethod->accept($visitor);
154+
$this->assertNull($result);
155+
}
44156
}

0 commit comments

Comments
 (0)