Skip to content

Commit 2f48be4

Browse files
authored
Merge pull request #28 from gyro-project/Symfony7
Make Symfony 7 compatible
2 parents 00b62d2 + 9c1e681 commit 2f48be4

19 files changed

+67
-35
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ jobs:
55
name: Tests
66
runs-on: ubuntu-latest
77
strategy:
8+
fail-fast: false
89
matrix:
9-
php-versions: ['7.4', '8.0', '8.1']
10+
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1011
composer: ['--prefer-lowest', ' ']
1112

1213
steps:
@@ -20,7 +21,7 @@ jobs:
2021
tools: "cs2pr"
2122

2223
- name: "Cache dependencies installed with composer"
23-
uses: "actions/cache@v1"
24+
uses: "actions/cache@v3"
2425
with:
2526
path: "~/.composer/cache"
2627
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -47,7 +48,7 @@ jobs:
4748
tools: "cs2pr"
4849

4950
- name: "Cache dependencies installed with composer"
50-
uses: "actions/cache@v1"
51+
uses: "actions/cache@v3"
5152
with:
5253
path: "~/.composer/cache"
5354
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
@@ -63,6 +64,7 @@ jobs:
6364
name: Psalm
6465
runs-on: ubuntu-latest
6566
strategy:
67+
fail-fast: false
6668
matrix:
6769
composer: ['--prefer-lowest', ' ']
6870

@@ -73,11 +75,11 @@ jobs:
7375
- name: Setup PHP
7476
uses: shivammathur/setup-php@v2
7577
with:
76-
php-version: 8.1
78+
php-version: 8.4
7779
tools: "cs2pr"
7880

7981
- name: "Cache dependencies installed with composer"
80-
uses: "actions/cache@v1"
82+
uses: "actions/cache@v3"
8183
with:
8284
path: "~/.composer/cache"
8385
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@
77
"authors": [
88
{"name": "Benjamin Eberlei", "email": "[email protected]"}
99
],
10+
"require": {
11+
"symfony/http-kernel": "~4.4|~5.4|~6.4|~7.0",
12+
"psr/container": "^1.1|^2.0",
13+
"composer-runtime-api": "*",
14+
"symfony/polyfill-php80": "^1.31",
15+
"technically/callable-reflection": "^0.4.1"
16+
},
1017
"require-dev": {
1118
"php": "~7.4|~8.0",
1219
"phake/phake": "^4.2.0",
13-
"phpunit/phpunit": "^9.4",
14-
"vimeo/psalm": "4.15.0",
15-
"nikic/php-parser": "^4.4",
16-
"symfony/symfony": "~4.4|~5.4|~6.0",
20+
"phpunit/phpunit": "^9.6|^10.5|^11.4",
21+
"vimeo/psalm": "^5.26|^6.9",
22+
"nikic/php-parser": "^4.4|^5.0",
23+
"symfony/symfony": "~4.4|~5.4|~6.4|~7.0",
1724
"doctrine/coding-standard": "^8.2.1",
1825
"twig/twig": "^1.44|^2.14|^3.1"
1926
},
20-
"require": {
21-
"symfony/http-kernel": "~4.4|~5.4|~6.0",
22-
"composer-runtime-api": "*"
23-
},
2427
"autoload": {
2528
"psr-0": {
2629
"Gyro\\Bundle\\MVCBundle\\": "src/",

psalm.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
<MixedAssignment errorLevel="info" />
1818
<MixedArgument errorLevel="info" />
1919
<MixedArgumentTypeCoercion errorLevel="info" />
20-
<MixedInferredReturnType errorLevel="info" />
2120
<MixedReturnStatement errorLevel="info" />
2221
<MoreSpecificReturnType errorLevel="info" />
2322
<LessSpecificReturnType errorLevel="info" />
2423
<LessSpecificReturnStatement errorLevel="info" />
2524
<UndefinedDocblockClass errorLevel="info" />
2625
<DeprecatedClass errorLevel="info" />
2726
<DeprecatedMethod errorLevel="info" />
27+
<PossiblyUnusedMethod errorLevel="info" />
28+
<MissingOverrideAttribute errorLevel="info" />
29+
<ClassMustBeFinal errorLevel="info" />
30+
<UnusedClass errorLevel="info" />
2831
</issueHandlers>
2932
</psalm>

src/Gyro/Bundle/MVCBundle/Controller/ResultConverter/AfterResponseYieldApplier.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
77
use Symfony\Component\HttpFoundation\Request;
88
use Symfony\Component\HttpFoundation\Response;
9-
use Symfony\Component\HttpKernel\Event\TerminateEvent;
109

1110
class AfterResponseYieldApplier implements ControllerYieldApplier, EventSubscriberInterface
1211
{
@@ -31,7 +30,7 @@ public function apply($yield, Request $request, Response $response): void
3130
$this->tasks[] = $yield;
3231
}
3332

34-
public function onKernelTerminate(TerminateEvent $event): void
33+
public function onKernelTerminate(): void
3534
{
3635
foreach ($this->tasks as $task) {
3736
$task();

src/Gyro/Bundle/MVCBundle/Controller/ResultConverter/ArrayToTemplateResponseConverter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function convert($result, Request $request): Response
4949
throw new \RuntimeException(sprintf('Result must be array or TemplateView, %s given', is_object($result) ? get_class($result) : gettype($result)));
5050
}
5151

52+
/** @psalm-suppress RiskyTruthyFalsyComparison */
5253
return $this->makeResponseFor(
5354
$controller,
5455
$result,

src/Gyro/Bundle/MVCBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function getConfigTreeBuilder(): TreeBuilder
2525

2626
assert($rootNode instanceof ArrayNodeDefinition);
2727

28+
/** @psalm-suppress UndefinedInterfaceMethod */
2829
$rootNode
2930
->children()
3031
->arrayNode('convert_exceptions')

src/Gyro/Bundle/MVCBundle/DependencyInjection/GyroMVCExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* This is the class that loads and manages your bundle configuration
1212
*
1313
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
14+
*
15+
* @psalm-suppress InternalClass
1416
*/
1517
class GyroMVCExtension extends Extension
1618
{

src/Gyro/Bundle/MVCBundle/EventListener/ConvertExceptionListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function onKernelException($event): void
5959

6060
$convertedExceptionClass = $this->findConvertToExceptionClass($exception);
6161

62+
/** @psalm-suppress RiskyTruthyFalsyComparison */
6263
if (!$convertedExceptionClass) {
6364
return;
6465
}

src/Gyro/Bundle/MVCBundle/EventListener/ParamConverterListener.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Gyro\Bundle\MVCBundle\SymfonyTokenContext;
1010
use Gyro\MVC\FormRequest;
1111
use Gyro\MVC\TokenContext;
12+
use Technically\CallableReflection\CallableReflection;
1213

1314
/**
1415
* Convert the request parameters into objects when typehinted.
@@ -41,28 +42,22 @@ public function onKernelController(ControllerEvent $event): void
4142
/** @psalm-suppress UndefinedClass */
4243
$request = $event->getRequest();
4344

44-
if (\is_array($controller)) {
45-
$r = new \ReflectionMethod($controller[0], $controller[1]);
46-
} elseif ($controller instanceof \Closure || \method_exists($controller, '__invoke')) {
47-
$r = new \ReflectionMethod($controller, '__invoke');
48-
} else {
49-
$r = new \ReflectionFunction($controller);
50-
}
45+
$r = CallableReflection::fromCallable($controller);
5146

5247
// automatically apply conversion for non-configured objects
5348
foreach ($r->getParameters() as $param) {
54-
if (!$param->getType()) {
49+
if (!$param->getTypes()) {
5550
continue;
5651
}
5752

58-
$type = $param->getType();
53+
$types = $param->getTypes();
5954

6055
// skip union and intersection types (for now?)
61-
if (!($type instanceof \ReflectionNamedType)) {
56+
if (count($types) > 1) {
6257
continue;
6358
}
6459

65-
$class = $type->getName();
60+
$class = $types[0]->getType();
6661
$name = $param->getName();
6762

6863
if (

src/Gyro/Bundle/MVCBundle/EventListener/ViewListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ public function onKernelView($event): void
6060

6161
private function unrollGenerator(Generator $generator, Request $request): Response
6262
{
63-
/** @var array<object,array> $yields */
63+
/** @var list<object|array> $yields */
6464
$yields = iterator_to_array($generator);
6565

6666
$result = $generator->getReturn();
6767
\assert(\is_object($result) || \is_array($result));
6868

69+
/** @psalm-suppress RiskyTruthyFalsyComparison */
6970
if (!$result) {
7071
throw new \LogicException("Controllers with generators must return a result that is or can be converted to a Response.");
7172
}

0 commit comments

Comments
 (0)