Skip to content

Commit b4abdab

Browse files
authored
[ci] use reflection in root namespace && handle 6.2 routing config (#1230)
1 parent cd4c31e commit b4abdab

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/Util/TemplateComponentGenerator.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Util;
1313

14-
use ReflectionClass;
15-
use ReflectionException;
16-
1714
/**
1815
* @author Jesse Rushlow <[email protected]>
1916
*
@@ -48,11 +45,11 @@ public function getPropertyType(ClassNameDetails $classNameDetails): ?string
4845
}
4946

5047
/**
51-
* @throws ReflectionException
48+
* @throws \ReflectionException
5249
*/
5350
public function repositoryHasSaveAndRemoveMethods(string $repositoryFullClassName): bool
5451
{
55-
$reflectedComponents = new ReflectionClass($repositoryFullClassName);
52+
$reflectedComponents = new \ReflectionClass($repositoryFullClassName);
5653

5754
return $reflectedComponents->hasMethod('save') && $reflectedComponents->hasMethod('remove');
5855
}

tests/Maker/FunctionalTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\MakerBundle\Tests\Maker;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use ReflectionClass;
1615
use Symfony\Bundle\FrameworkBundle\Console\Application;
1716
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
1817
use Symfony\Bundle\MakerBundle\Test\MakerTestKernel;
@@ -38,7 +37,7 @@ public function testWiring()
3837

3938
$application = new Application($kernel);
4039
foreach ($finder as $file) {
41-
$maker = new ReflectionClass(sprintf('Symfony\Bundle\MakerBundle\Maker\%s', $file->getBasename('.php')));
40+
$maker = new \ReflectionClass(sprintf('Symfony\Bundle\MakerBundle\Maker\%s', $file->getBasename('.php')));
4241

4342
if ($maker->isAbstract()) {
4443
continue;

tests/Maker/MakeCrudTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ public function getTestDetails(): \Generator
122122
Yaml::dump(['maker' => ['root_namespace' => 'Custom']])
123123
);
124124

125+
// @legacy Conditional can be removed when Symfony 5.4 support is dropped
126+
if (60000 <= $runner->getSymfonyVersion()) {
127+
// Symfony 6.2 sets the path and namespace for router resources
128+
$runner->modifyYamlFile('config/routes.yaml', function (array $config) {
129+
if (!isset($config['controllers']['resource']['namespace'])) {
130+
return $config;
131+
}
132+
133+
$config['controllers']['resource']['namespace'] = 'Custom\Controller';
134+
135+
return $config;
136+
});
137+
}
138+
125139
$runner->copy(
126140
'make-crud/SweetFood-custom-namespace.php',
127141
'src/Entity/SweetFood.php'

0 commit comments

Comments
 (0)