Skip to content

Commit 2f22626

Browse files
committed
Provisional support for PHP 8.5, proactive Symfony 8.0 compat fix
1 parent b33571d commit 2f22626

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
symfony: '6.4.*'
1919
composer-flags: '--prefer-stable --prefer-lowest'
2020
can-fail: false
21+
- php: '8.5'
22+
symfony: '7.4.*@dev'
23+
composer-flags: '--prefer-stable'
24+
can-fail: true
2125

2226
name: "PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }}${{ matrix.composer-flags != '' && format(' - Composer {0}', matrix.composer-flags) || '' }}"
2327

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"license": "MIT",
1212
"require": {
13-
"php": "8.3.* || 8.4.*",
13+
"php": "8.3.* || 8.4.* || 8.5.*",
1414
"ext-pcntl": "*",
1515
"babdev/websocket-server": "0.1.*",
1616
"symfony/config": "^6.4 || ^7.3",

docs/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ The below table shows the supported PHP and Symfony versions for this bundle.
1515

1616
| Version | Status | PHP Versions | Symfony Versions |
1717
|---------|----------------|--------------|------------------|
18-
| 1.x | In Development | 8.3-8.4 | 6.4, 7.3 |
18+
| 1.x | In Development | 8.3-8.5 | 6.4, 7.3 |

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,6 @@ parameters:
192192
count: 1
193193
path: src/DependencyInjection/Factory/Authentication/SessionAuthenticationProviderFactory.php
194194

195-
-
196-
message: '#^Call to function method_exists\(\) with \$this\(BabDev\\WebSocketBundle\\Routing\\Loader\\AttributeLoader\) and ''setRouteAttributeCl…'' will always evaluate to true\.$#'
197-
identifier: function.alreadyNarrowedType
198-
count: 1
199-
path: src/Routing/Loader/AttributeLoader.php
200-
201195
-
202196
message: '#^Parameter \#1 \$class of function class_exists expects string, mixed given\.$#'
203197
identifier: argument.type

src/Routing/Loader/AttributeLoader.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,35 @@
1313
*/
1414
final class AttributeLoader extends AttributeClassLoader
1515
{
16+
/**
17+
* @var class-string
18+
*/
19+
private string $routeAttributeClass;
20+
1621
public function __construct(?string $env = null)
1722
{
23+
$this->routeAttributeClass = AsMessageHandler::class;
24+
1825
parent::__construct($env);
1926

27+
/** @phpstan-ignore function.alreadyNarrowedType */
2028
if (method_exists($this, 'setRouteAttributeClass')) {
2129
$this->setRouteAttributeClass(AsMessageHandler::class);
2230
} else {
2331
$this->setRouteAnnotationClass(AsMessageHandler::class);
2432
}
2533
}
2634

35+
/**
36+
* @param class-string $class
37+
*/
38+
public function setRouteAttributeClass(string $class): void
39+
{
40+
$this->routeAttributeClass = $class;
41+
42+
parent::setRouteAttributeClass($class);
43+
}
44+
2745
/**
2846
* Loads from attributes from a class.
2947
*
@@ -47,7 +65,7 @@ public function load(mixed $class, ?string $type = null): RouteCollection
4765
$collection->addResource(new FileResource($class->getFileName()));
4866

4967
/** @var \ReflectionAttribute<AsMessageHandler>|null $attribute */
50-
$attribute = $class->getAttributes($this->routeAnnotationClass, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null;
68+
$attribute = $class->getAttributes($this->routeAttributeClass, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null;
5169

5270
if (!$attribute instanceof \ReflectionAttribute) {
5371
return $collection;
@@ -109,7 +127,7 @@ public function load(mixed $class, ?string $type = null): RouteCollection
109127
/**
110128
* @param \ReflectionClass<AsMessageHandler> $class
111129
*/
112-
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void
130+
protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $attr): void
113131
{
114132
// Method is purposefully unused, but is required by the parent class
115133
}

0 commit comments

Comments
 (0)