Skip to content

[ci] use reflection in root namespace && handle 6.2 routing config #1230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/Util/TemplateComponentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace Symfony\Bundle\MakerBundle\Util;

use ReflectionClass;
use ReflectionException;

/**
* @author Jesse Rushlow <[email protected]>
*
Expand Down Expand Up @@ -48,11 +45,11 @@ public function getPropertyType(ClassNameDetails $classNameDetails): ?string
}

/**
* @throws ReflectionException
* @throws \ReflectionException
*/
public function repositoryHasSaveAndRemoveMethods(string $repositoryFullClassName): bool
{
$reflectedComponents = new ReflectionClass($repositoryFullClassName);
$reflectedComponents = new \ReflectionClass($repositoryFullClassName);

return $reflectedComponents->hasMethod('save') && $reflectedComponents->hasMethod('remove');
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Maker/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Bundle\MakerBundle\Tests\Maker;

use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\MakerBundle\Command\MakerCommand;
use Symfony\Bundle\MakerBundle\Test\MakerTestKernel;
Expand All @@ -38,7 +37,7 @@ public function testWiring()

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

if ($maker->isAbstract()) {
continue;
Expand Down
14 changes: 14 additions & 0 deletions tests/Maker/MakeCrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ public function getTestDetails(): \Generator
Yaml::dump(['maker' => ['root_namespace' => 'Custom']])
);

// @legacy Conditional can be removed when Symfony 5.4 support is dropped
if (60000 <= $runner->getSymfonyVersion()) {
// Symfony 6.2 sets the path and namespace for router resources
$runner->modifyYamlFile('config/routes.yaml', function (array $config) {
if (!isset($config['controllers']['resource']['namespace'])) {
return $config;
}

$config['controllers']['resource']['namespace'] = 'Custom\Controller';

return $config;
});
}

$runner->copy(
'make-crud/SweetFood-custom-namespace.php',
'src/Entity/SweetFood.php'
Expand Down