Skip to content

Commit 2856b36

Browse files
authored
Fix exceptions constructor compatibility (#1250)
1 parent becc8a9 commit 2856b36

File tree

5 files changed

+51
-61
lines changed

5 files changed

+51
-61
lines changed

.github/workflows/main.yml

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
git config --global core.autocrlf false
2929
git config --global core.eol lf
3030
- name: Checkout
31-
uses: actions/checkout@v3
31+
uses: actions/checkout@v6
3232

3333
- name: Configure environment
3434
run: |
@@ -40,28 +40,16 @@ jobs:
4040
uses: shivammathur/setup-php@v2
4141
with:
4242
php-version: ${{ matrix.php }}
43+
4344
- name: Validate Composer
4445
run: composer validate
45-
- name: Get Composer Cache Directory
46-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
47-
id: composer-cache
48-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
49-
- name: Restore Composer Cache
50-
uses: actions/cache@v4
51-
with:
52-
path: ${{ steps.composer-cache.outputs.dir }}
53-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
54-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
55-
- name: Install Dependencies
56-
uses: nick-invision/retry@v1
57-
with:
58-
timeout_minutes: 5
59-
max_attempts: 5
60-
command: composer update --prefer-dist --no-interaction --no-progress
46+
47+
- name: Install dependencies
48+
uses: ramsey/composer-install@v3
6149

6250
# Execution
63-
- name: Security Advisories
64-
run: composer require --dev roave/security-advisories:dev-latest
51+
- name: Audit dependencies
52+
run: composer audit
6553

6654
static-analysis:
6755
name: Psalm and Rector
@@ -70,7 +58,7 @@ jobs:
7058
strategy:
7159
fail-fast: false
7260
matrix:
73-
php: ['8.4'] # Note: This workflow requires only the LATEST version of PHP
61+
php: ['8.5'] # Note: This workflow requires only the LATEST version of PHP
7462
os: [ubuntu-latest]
7563

7664
steps:
@@ -80,36 +68,26 @@ jobs:
8068
git config --global core.autocrlf false
8169
git config --global core.eol lf
8270
- name: Checkout
83-
uses: actions/checkout@v3
71+
uses: actions/checkout@v6
8472

8573
- name: Configure environment
8674
run: |
8775
export COMPOSER_ROOT_VERSION=$(/usr/bin/jq --null-input --raw-output 'first(inputs["extra"]["branch-alias"])[]' composer.json)
8876
echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV
8977
90-
# Install PHP Dependencies
78+
# Install PHP and Dependencies
9179
- name: Setup PHP ${{ matrix.php }}
9280
uses: shivammathur/setup-php@v2
9381
with:
9482
php-version: ${{ matrix.php }}
83+
9584
- name: Validate Composer
9685
run: composer validate
97-
- name: Get Composer Cache Directory
98-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
99-
id: composer-cache
100-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
101-
- name: Restore Composer Cache
102-
uses: actions/cache@v4
103-
with:
104-
path: ${{ steps.composer-cache.outputs.dir }}
105-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
106-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
107-
- name: Install Dependencies
108-
uses: nick-invision/retry@v2
86+
87+
- name: Install dependencies
88+
uses: ramsey/composer-install@v3
10989
with:
110-
timeout_minutes: 5
111-
max_attempts: 5
112-
command: composer update --prefer-dist --no-interaction --no-progress
90+
composer-options: "--prefer-dist --no-audit"
11391

11492
# Execution
11593
- name: Static Analysis
@@ -127,12 +105,12 @@ jobs:
127105
strategy:
128106
fail-fast: false
129107
matrix:
130-
php: ['8.1', '8.2', '8.3', '8.4']
108+
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
131109
os: [ubuntu-latest]
132-
stability: [prefer-lowest, prefer-stable]
110+
stability: [lowest, highest]
133111
exclude:
134-
- php: 8.4
135-
stability: prefer-lowest
112+
- php: 8.5
113+
stability: lowest
136114

137115
steps:
138116
# General Steps
@@ -141,7 +119,7 @@ jobs:
141119
git config --global core.autocrlf false
142120
git config --global core.eol lf
143121
- name: Checkout
144-
uses: actions/checkout@v3
122+
uses: actions/checkout@v6
145123

146124
- name: Configure environment
147125
run: |
@@ -158,24 +136,24 @@ jobs:
158136
coverage: pcov
159137
tools: pecl
160138
ini-values: "memory_limit=-1"
139+
161140
- name: Validate Composer
162141
run: composer validate
163-
- name: Get Composer Cache Directory
164-
# Docs: <https://github.com/actions/cache/blob/master/examples.md#php---composer>
165-
id: composer-cache
166-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
167-
- name: Restore Composer Cache
168-
uses: actions/cache@v4
142+
143+
# Install PHP and Dependencies
144+
- name: Setup PHP ${{ matrix.php }}
145+
uses: shivammathur/setup-php@v2
169146
with:
170-
path: ${{ steps.composer-cache.outputs.dir }}
171-
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
172-
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-
173-
- name: Install Dependencies
174-
uses: nick-invision/retry@v2
147+
php-version: ${{ matrix.php }}
148+
149+
- name: Validate Composer
150+
run: composer validate
151+
152+
- name: Install dependencies
153+
uses: ramsey/composer-install@v3
175154
with:
176-
timeout_minutes: 5
177-
max_attempts: 5
178-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
155+
dependency-versions: ${{ matrix.stability }}
156+
composer-options: "--prefer-dist --no-audit"
179157

180158
# Execution
181159
- name: Execute Tests

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,11 @@
281281
"allow-plugins": {
282282
"composer/package-versions-deprecated": true,
283283
"spiral/composer-publish-plugin": true
284+
},
285+
"audit": {
286+
"ignore": {
287+
"GHSA-vvj3-c3rp-c85p": "PHPUnit is a dev dependency and does not affect production code."
288+
}
284289
}
285290
},
286291
"minimum-stability": "dev",

src/Core/src/Exception/Container/ArgumentException.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ class ArgumentException extends AutowireException
1616
public function __construct(
1717
protected \ReflectionParameter $parameter,
1818
protected \ReflectionFunctionAbstract $context,
19+
?\Throwable $previous = null,
1920
) {
2021
$name = $context->getName();
2122
if ($context instanceof \ReflectionMethod) {
2223
$name = $context->class . '::' . $name;
2324
}
2425

25-
parent::__construct(\sprintf("Unable to resolve '%s' argument in '%s'", $parameter->name, $name));
26+
parent::__construct(
27+
\sprintf("Unable to resolve '%s' argument in '%s'", $parameter->name, $name),
28+
previous: $previous,
29+
);
2630
}
2731

2832
public function getParameter(): \ReflectionParameter

src/Core/src/Exception/Resolver/WrongTypeException.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
final class WrongTypeException extends ResolvingException
88
{
9-
public function __construct(\ReflectionFunctionAbstract $reflection, \TypeError $error)
10-
{
9+
public function __construct(
10+
\ReflectionFunctionAbstract $reflection,
11+
\TypeError $error,
12+
?\Throwable $previous = null,
13+
) {
1114
$message = 'An argument resolved with wrong type: ';
1215
parent::__construct(
1316
$message . $error->getMessage(),
1417
$error->getCode(),
15-
$error,
18+
$previous ?? $error,
1619
);
1720
}
1821
}

src/Core/src/Internal/Actor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class Actor
5050

5151
public function __construct(Registry $constructor)
5252
{
53-
$constructor->set('hub', $this);
53+
$constructor->set('actor', $this);
5454

5555
$this->state = $constructor->get('state', State::class);
5656
$this->binder = $constructor->get('binder', BinderInterface::class);

0 commit comments

Comments
 (0)