Skip to content

Commit

Permalink
Merge branch 'symfony:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Rootie authored Jun 28, 2023
2 parents 1c0dc6b + 5c47dab commit cb00ee5
Show file tree
Hide file tree
Showing 49 changed files with 166 additions and 121 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
coding-standards:
name: "Coding Standards (${{ matrix.php-version }})"

runs-on: "ubuntu-18.04"
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
test:
name: "PHP ${{ matrix.php-version }} + @${{ matrix.symfony-version }} ${{ matrix.dependency-versions }} deps"

runs-on: ubuntu-18.04
runs-on: ubuntu-latest

services:
mysql:
Expand Down Expand Up @@ -90,13 +90,14 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.1'
- '8.2'
symfony-version:
- '5.4.*'
- '5.4.x-dev'
- '6.0.x-dev'
- '6.1.x-dev'
- '6.2.x-dev'
- '6.3.x-dev'
dependency-versions: ['highest']
allow-dev-deps-in-apps: ['0']
include:
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [v1.49.0](https://github.com/symfony/maker-bundle/releases/tag/v1.49.0)

*June 7th, 2023*

### Feature

- [#1321](https://github.com/symfony/maker-bundle/pull/1321) - Changing make:stimulus-controller to require StimulusBundle - *@weaverryan*
- [#1309](https://github.com/symfony/maker-bundle/pull/1309) - Apply `get_class_to_class_keyword` PHP-CS-Fixer rule - *@seb-jean*
- [#1276](https://github.com/symfony/maker-bundle/pull/1276) - [make:migration] Change message when required package for migration doesn't exist. - *@bdaler*
- [#1261](https://github.com/symfony/maker-bundle/pull/1261) - [make:registration-form] use UniqueEntity attribute instead of annotation - *@jrushlow*
- [#1253](https://github.com/symfony/maker-bundle/pull/1253) - [make:migration] Add link to new migration files - *@nicolas-grekas*
- [#1251](https://github.com/symfony/maker-bundle/pull/1251) - [make:*] use php-cs-fixer to style/lint all generated php templates - *@jrushlow*
- [#1244](https://github.com/symfony/maker-bundle/pull/1244) - [make:security:form-login] new maker to use built in FormLogin - *@jrushlow*
- [#1242](https://github.com/symfony/maker-bundle/pull/1242) - [make:*] use static return type instead of self for setters - *@jrushlow*
- [#1239](https://github.com/symfony/maker-bundle/pull/1239) - Improve error messages to show PHP & XML configurations are not supported - *@ThomasLandauer*
- [#1238](https://github.com/symfony/maker-bundle/pull/1238) - [make:*] improve output messages for Symfony CLI users - *@jrushlow*
- [#1237](https://github.com/symfony/maker-bundle/pull/1237) - [make:registration-form] Print registration form errors - *@comxd*
### Bug

- [#1307](https://github.com/symfony/maker-bundle/pull/1307) - [make:twig-component] handle upstream changes to how live components are rendered - *@jrushlow*
- [#1270](https://github.com/symfony/maker-bundle/pull/1270) - [make:authenticator] Core\Security or SecurityBundle\Security - Avoid deprecations in 6.2 - *@nacorp*
- [#1265](https://github.com/symfony/maker-bundle/pull/1265) - [make:crud] Make sensio/framework-extra-bundle an optional dependency - *@acrobat*
- [#1264](https://github.com/symfony/maker-bundle/pull/1264) - [make:controller] doctrine/annotations is not needed - *@jrushlow*
- [#1262](https://github.com/symfony/maker-bundle/pull/1262) - [make:reset-password] doctrine/annotations are not needed - *@jrushlow*

## [v1.48.0](https://github.com/symfony/maker-bundle/releases/tag/v1.48.0)

*November 14th, 2022*
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "symfony/maker-bundle",
"type": "symfony-bundle",
"license": "MIT",
"keywords": ["generator", "code generator", "scaffolding", "scaffold"],
"keywords": ["generator", "code generator", "scaffolding", "scaffold", "dev"],
"authors": [
{
"name": "Symfony Community",
Expand All @@ -31,7 +31,7 @@
"doctrine/doctrine-bundle": "^2.4",
"doctrine/orm": "^2.10.0",
"symfony/http-client": "^5.4.7|^6.0",
"symfony/phpunit-bridge": "^5.4.7|^6.0",
"symfony/phpunit-bridge": "^5.4.17|^6.0",
"symfony/polyfill-php80": "^1.16.0",
"symfony/security-core": "^5.4.7|^6.0",
"symfony/yaml": "^5.4.3|^6.0",
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('maker');
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/MakerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ class MakerExtension extends Extension
*/
private const TEST_MAKER_DEPRECATION_MESSAGE = 'The "%service_id%" service is deprecated, use "maker.maker.make_test" instead.';

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/EntityRegenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ private function getMappedFieldsInEntity(ClassMetadata $classMetadata): array
$targetFields = array_diff($targetFields, $traitProperties);

// exclude inherited properties
$targetFields = array_filter($targetFields, static fn ($field) => $classReflection->hasProperty($field) &&
$classReflection->getProperty($field)->getDeclaringClass()->getName() === $classReflection->getName());
$targetFields = array_filter($targetFields, static fn ($field) => $classReflection->hasProperty($field)
&& $classReflection->getProperty($field)->getDeclaringClass()->getName() === $classReflection->getName());
}

return $targetFields;
Expand Down
3 changes: 0 additions & 3 deletions src/InputAwareMakerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@
*/
interface InputAwareMakerInterface extends MakerInterface
{
/**
* {@inheritdoc}
*/
public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null);
}
4 changes: 3 additions & 1 deletion src/Maker/MakeCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Validator\Validation;
Expand Down Expand Up @@ -179,7 +180,8 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
'entity_var_singular' => $entityVarSingular,
'entity_twig_var_singular' => $entityTwigVarSingular,
'entity_identifier' => $entityDoctrineDetails->getIdentifier(),
'use_render_form' => method_exists(AbstractController::class, 'renderForm'),
// @legacy - Remove when support for Symfony <6 is dropped
'use_render_form' => Kernel::VERSION_ID < 60200,
],
$repositoryVars
)
Expand Down
12 changes: 6 additions & 6 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
$input->setArgument('name', $entityClassName);

if (
!$input->getOption('api-resource') &&
(class_exists(ApiResource::class) || class_exists(LegacyApiResource::class)) &&
!class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
!$input->getOption('api-resource')
&& (class_exists(ApiResource::class) || class_exists(LegacyApiResource::class))
&& !class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
) {
$description = $command->getDefinition()->getOption('api-resource')->getDescription();
$question = new ConfirmationQuestion($description, false);
Expand All @@ -146,9 +146,9 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
}

if (
!$input->getOption('broadcast') &&
class_exists(Broadcast::class) &&
!class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
!$input->getOption('broadcast')
&& class_exists(Broadcast::class)
&& !class_exists($this->generator->createClassNameDetails($entityClassName, 'Entity\\')->getFullName())
) {
$description = $command->getDefinition()->getOption('broadcast')->getDescription();
$question = new ConfirmationQuestion($description, false);
Expand Down
16 changes: 14 additions & 2 deletions src/Maker/MakeStimulusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\UX\StimulusBundle\StimulusBundle;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;

/**
Expand Down Expand Up @@ -227,9 +228,20 @@ private function getValuesTypes(): array

public function configureDependencies(DependencyBuilder $dependencies): void
{
// lower than 8.1, allow WebpackEncoreBundle
if (\PHP_VERSION_ID < 80100) {
$dependencies->addClassDependency(
WebpackEncoreBundle::class,
'symfony/webpack-encore-bundle'
);

return;
}

// else: encourage StimulusBundle by requiring it
$dependencies->addClassDependency(
WebpackEncoreBundle::class,
'webpack-encore-bundle'
StimulusBundle::class,
'symfony/stimulus-bundle'
);
}
}
4 changes: 1 addition & 3 deletions src/Maker/MakeTwigComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen
$factory = $generator->createClassNameDetails(
$name,
'Twig\\Components',
'Component'
);

$shortName = Str::asSnakeCase(Str::removeSuffix($factory->getShortName(), 'Component'));
$shortName = Str::getShortClassName($factory->getShortName());

$generator->generateClass(
$factory->getFullName(),
sprintf('%s/../Resources/skeleton/twig/%s', __DIR__, $live ? 'LiveComponent.tpl.php' : 'Component.tpl.php'),
[
'live' => $live,
'short_name' => $shortName,
]
);
$generator->generateTemplate(
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/skeleton/crud/controller/Controller.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function new(Request $request, EntityManagerInterface $entityManager): Re
<?php } else { ?>
return $this->render('<?= $templates_path ?>/new.html.twig', [
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
'form' => $form->createView(),
'form' => $form,
]);
<?php } ?>
}
Expand Down Expand Up @@ -107,7 +107,7 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
<?php } else { ?>
return $this->render('<?= $templates_path ?>/edit.html.twig', [
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
'form' => $form->createView(),
'form' => $form,
]);
<?php } ?>
}
Expand Down
12 changes: 7 additions & 5 deletions src/Resources/skeleton/doctrine/Repository.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ public function __construct(ManagerRegistry $registry)

public function save(<?= $entity_class_name ?> $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
$entityManager = $this->getEntityManager();
$entityManager->persist($entity);

if ($flush) {
$this->getEntityManager()->flush();
$entityManager->flush();
}
}

public function remove(<?= $entity_class_name ?> $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
$entityManager = $this->getEntityManager();
$entityManager->remove($entity);

if ($flush) {
$this->getEntityManager()->flush();
$entityManager->flush();
}
}
<?php if ($include_example_comments): // When adding a new method without existing default comments, the blank line is automatically added.?>
Expand All @@ -46,7 +48,7 @@ public function remove(<?= $entity_class_name ?> $entity, bool $flush = false):
public function upgradePassword(<?= sprintf('%s ', $password_upgrade_user_interface->getShortName()); ?>$user, string $newHashedPassword): void
{
if (!$user instanceof <?= $entity_class_name ?>) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
}

$user->setPassword($newHashedPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function verifyUserEmail(Request $request<?php if ($translator_available)
<?php if (!$verify_email_anonymously): ?>
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
<?php else: ?>
$id = $request->get('id');
$id = $request->query->get('id');

if (null === $id) {
return $this->redirectToRoute('app_register');
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/security/UserProvider.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function loadUserByUsername($username): UserInterface
public function refreshUser(UserInterface $user): UserInterface
{
if (!$user instanceof <?= $user_short_name ?>) {
throw new UnsupportedUserException(sprintf('Invalid user class "%s".', get_class($user)));
throw new UnsupportedUserException(sprintf('Invalid user class "%s".', $user::class));
}

// Return a User object after making sure its data is "fresh".
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/skeleton/twig/Component.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;

#[AsTwigComponent('<?= $short_name; ?>')]
#[AsTwigComponent()]
final class <?= $class_name."\n" ?>
{
}
2 changes: 1 addition & 1 deletion src/Resources/skeleton/twig/LiveComponent.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\DefaultActionTrait;

#[AsLiveComponent('<?= $short_name; ?>')]
#[AsLiveComponent()]
final class <?= $class_name."\n" ?>
{
use DefaultActionTrait;
Expand Down
2 changes: 1 addition & 1 deletion src/Security/UserClassBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ private function addEraseCredentials(ClassSourceManipulator $manipulator): void
// add eraseCredentials: always empty
$builder = $manipulator->createMethodBuilder(
'eraseCredentials',
null,
'void',
false,
['@see UserInterface']
);
Expand Down
4 changes: 4 additions & 0 deletions src/Test/MakerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ protected function executeMakerCommand(MakerTestDetails $testDetails)
$this->markTestSkipped();
}

if ($testDetails->skipOnWindows() && '\\' === \DIRECTORY_SEPARATOR) {
$this->markTestSkipped('This test is not supported on Windows');
}

$testEnv = MakerTestEnvironment::create($testDetails);

// prepare environment to test
Expand Down
8 changes: 8 additions & 0 deletions src/Test/MakerTestDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class MakerTestDetails
private array $requiredPackageVersions = [];
private int $blockedPhpVersionUpper = 0;
private int $blockedPhpVersionLower = 0;
private bool $skipOnWindows = false;

public function __construct(
private MakerInterface $maker,
Expand Down Expand Up @@ -175,4 +176,11 @@ public function getPreRunCallbacks(): array
{
return $this->preRunCallbacks;
}

public function skipOnWindows(): self
{
$this->skipOnWindows = true;

return $this;
}
}
2 changes: 1 addition & 1 deletion src/Test/MakerTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function configureDatabase(bool $createSchema = true): void
{
$this->replaceInFile(
'.env',
'postgresql://app:[email protected]:5432/app?serverVersion=14&charset=utf8',
'postgresql://app:[email protected]:5432/app?serverVersion=15&charset=utf8',
getenv('TEST_DATABASE_DSN')
);

Expand Down
4 changes: 2 additions & 2 deletions src/Util/ClassSourceManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function addEmbeddedEntity(string $propertyName, string $className): void
// look for "$this->propertyName = "

$constructorString = $this->printer->prettyPrint([$this->getConstructorNode()]);
if (false !== strpos($constructorString, sprintf('$this->%s = ', $propertyName))) {
if (str_contains($constructorString, sprintf('$this->%s = ', $propertyName))) {
$addEmbedded = false;
}
}
Expand Down Expand Up @@ -834,7 +834,7 @@ public function addUseStatementIfNecessary(string $class): string
* @param array $options The named arguments for the attribute ($key = argument name, $value = argument value)
* @param ?string $attributePrefix If a prefix is provided, the node is built using the prefix. E.g. #[ORM\Column()]
*/
public function buildAttributeNode(string $attributeClass, array $options, ?string $attributePrefix = null): Node\Attribute
public function buildAttributeNode(string $attributeClass, array $options, string $attributePrefix = null): Node\Attribute
{
$options = $this->sortOptionsByClassConstructorParameters($options, $attributeClass);

Expand Down
2 changes: 1 addition & 1 deletion src/Util/TemplateLinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function lintPhpTemplate(string|array $templateFilePath): void
foreach ($templateFilePath as $filePath) {
$cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : '';

$process = Process::fromShellCommandline(sprintf('%s%s --config=%s --using-cache=no fix %s', $cmdPrefix, $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath));
$process = Process::fromShellCommandline(sprintf('PHP_CS_FIXER_IGNORE_ENV=1 %s%s --config=%s --using-cache=no fix %s', $cmdPrefix, $this->phpCsFixerBinaryPath, $this->phpCsFixerConfigPath, $filePath));

$process->run();
}
Expand Down
Loading

0 comments on commit cb00ee5

Please sign in to comment.