Skip to content

Commit 74d125f

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 7c66fea + 285bf8c commit 74d125f

File tree

11 files changed

+59
-23
lines changed

11 files changed

+59
-23
lines changed

.github/workflows/php.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Validate composer.json and composer.lock
21+
run: composer validate --strict
22+
23+
- name: Cache Composer packages
24+
id: composer-cache
25+
uses: actions/cache@v3
26+
with:
27+
path: vendor
28+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-php-
31+
32+
- name: Install dependencies
33+
run: composer install --prefer-dist --no-progress
34+
35+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
36+
# Docs: https://getcomposer.org/doc/articles/scripts.md
37+
38+
- name: Run test suite
39+
run: composer run-script test

src/Annotations/Inject.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Inject
99
{
1010
public function __construct(
1111
public readonly ?string $index = null
12-
)
13-
{
12+
) {
1413
}
1514
}

src/Annotations/Provides.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Provides
99
{
1010
public function __construct(
1111
public readonly string $index
12-
)
13-
{
12+
) {
1413
}
1514
}

src/Exceptions/ContainerException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77

88
class ContainerException extends Exception implements ContainerExceptionInterface
99
{
10-
1110
}

src/Exceptions/NotFoundException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77

88
class NotFoundException extends Exception implements NotFoundExceptionInterface
99
{
10-
1110
}

src/ServiceContainer.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public function addAlias(string $alias, string $concrete): void
7171
*
7272
* @param T $id Identifier of the entry to look for.
7373
*
74-
* @return T
7574
* @throws ContainerExceptionInterface Error while retrieving the entry.
76-
*
7775
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
76+
*
77+
* @return T
7878
*/
7979
public function get(string $id): mixed
8080
{
@@ -124,10 +124,11 @@ public function has(string $id): bool
124124
* @param callable $function
125125
* @param array $arguments
126126
*
127-
* @return mixed
128127
* @throws ContainerExceptionInterface
129128
* @throws NotFoundExceptionInterface
130129
* @throws ReflectionException
130+
*
131+
* @return mixed
131132
*/
132133
public function invoke(callable $function, array $arguments = []): mixed
133134
{
@@ -142,8 +143,9 @@ public function invoke(callable $function, array $arguments = []): mixed
142143
* @param string $namespace
143144
* @param bool $enforce
144145
*
145-
* @return void
146146
* @throws ReflectionException
147+
*
148+
* @return void
147149
*/
148150
public function loadDefinitionsFromDirectory(string $directory, string $namespace, bool $enforce = false): void
149151
{
@@ -167,15 +169,16 @@ public function loadDefinitionsFromDirectory(string $directory, string $namespac
167169
* @param ReflectionMethod|ReflectionFunction $reflectionMethod
168170
* @param array $arguments
169171
*
170-
* @return array
171172
* @throws ContainerExceptionInterface
172173
* @throws NotFoundExceptionInterface
173174
* @throws ReflectionException
175+
*
176+
* @return array
174177
*/
175178
private function createArguments(
176-
ReflectionMethod|ReflectionFunction $reflectionMethod, array $arguments = []
177-
): array
178-
{
179+
ReflectionMethod|ReflectionFunction $reflectionMethod,
180+
array $arguments = []
181+
): array {
179182
foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
180183
$argumentName = $reflectionParameter->getName();
181184

tests/ExampleNamespace/ClassB.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ class ClassB
99
public function __construct(
1010
public ClassA $a,
1111
public int $count = 2
12-
)
13-
{
12+
) {
1413
static::increaseCounter();
1514
}
16-
}
15+
}

tests/ExampleNamespace/ClassC.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ class ClassC
99
public function __construct(
1010
public ClassA $a,
1111
public ClassB $b
12-
)
13-
{
12+
) {
1413
static::increaseCounter();
1514
}
1615

1716
public function sayHello()
1817
{
19-
echo "Hello World!";
18+
echo 'Hello World!';
2019
}
2120
}

tests/ExampleNamespace/CountsInstancesTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ trait CountsInstancesTrait
88

99
public static function increaseCounter(): void
1010
{
11-
static::$instancesCounter ++;
11+
static::$instancesCounter++;
1212
}
1313

1414
public static function resetCounter(): void
1515
{
1616
static::$instancesCounter = 0;
1717
}
18-
}
18+
}

tests/ExampleNamespace/InterfaceA.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44

55
interface InterfaceA
66
{
7-
87
}

tests/ServiceContainerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
class ServiceContainerTest extends TestCase
1414
{
1515
private ?ServiceContainer $container;
16+
1617
public function testInstancing(): void
1718
{
1819
$this->assertInstanceOf(ClassA::class, $this->container->get(ClassA::class));

0 commit comments

Comments
 (0)