From 09597b3020c8ffd6a5c3818664c25823c42d78af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Sat, 17 Aug 2024 23:51:14 +0200 Subject: [PATCH] [CI] Update php-cs-fixer config --- .php-cs-fixer.dist.php | 2 - composer.json | 2 +- src/Icons/src/Twig/UXIconRuntime.php | 1 + .../Integration/LiveComponentHydratorTest.php | 118 +++++++++--------- .../Unit/Attribute/AsLiveComponentTest.php | 6 +- .../tests/Unit/Attribute/LivePropTest.php | 6 +- .../Unit/Twig/LiveComponentRuntimeTest.php | 8 +- src/Map/tests/MapTest.php | 2 +- src/Turbo/src/TurboBundle.php | 2 +- .../src/Attribute/AsTwigComponent.php | 2 - .../Integration/ComponentFactoryTest.php | 2 +- .../Unit/Attribute/AsTwigComponentTest.php | 4 +- .../tests/Unit/ComponentAttributesTest.php | 4 +- .../Unit/ComputedPropertiesProxyTest.php | 16 +-- .../TwigComponentExtensionTest.php | 2 +- ux.symfony.com/.php-cs-fixer.dist.php | 3 - 16 files changed, 87 insertions(+), 93 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9e576f2108a..a8c7da94b14 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -29,8 +29,6 @@ '@Symfony' => true, '@Symfony:risky' => true, 'header_comment' => ['header' => $fileHeaderComment], - // TODO: Remove once the "compiler_optimized" set includes "sprintf" - 'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true], 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']], ]) ->setRiskyAllowed(true) diff --git a/composer.json b/composer.json index 0674798974e..271f27ec4b1 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,6 @@ "require-dev": { "symfony/filesystem": "^5.2|^6.0|^7.0", "symfony/finder": "^5.4|^6.0|^7.0", - "php-cs-fixer/shim": "^3.13" + "php-cs-fixer/shim": "^3.62" } } diff --git a/src/Icons/src/Twig/UXIconRuntime.php b/src/Icons/src/Twig/UXIconRuntime.php index cac051aea84..7276ac08644 100644 --- a/src/Icons/src/Twig/UXIconRuntime.php +++ b/src/Icons/src/Twig/UXIconRuntime.php @@ -40,6 +40,7 @@ public function renderIcon(string $name, array $attributes = []): string } catch (IconNotFoundException $e) { if ($this->ignoreNotFound) { $this->logger?->warning($e->getMessage()); + return ''; } diff --git a/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php index 2441146fccd..d29a1ab4d6c 100644 --- a/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php +++ b/src/LiveComponent/tests/Integration/LiveComponentHydratorTest.php @@ -151,7 +151,7 @@ public function testCanDehydrateAndHydrateComponentWithTestCases(callable $testF public static function provideDehydrationHydrationTests(): iterable { yield 'onUpdated: exception if method not exists' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true, onUpdated: 'onFirstNameUpdated')] public string $firstName; }) @@ -161,7 +161,7 @@ public static function provideDehydrationHydrationTests(): iterable }]; yield 'onUpdated: with scalar value' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true, onUpdated: 'onFirstNameUpdated')] public string $firstName; @@ -184,7 +184,7 @@ public function onFirstNameUpdated($oldValue) 'name' => 'Chicken', ])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['name'], onUpdated: ['name' => 'onNameUpdated'])] public ProductFixtureEntity $product; @@ -208,7 +208,7 @@ public function onNameUpdated($oldValue) \assert($entityOriginal instanceof Entity1); \assert($entityNext instanceof Entity1); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: [LiveProp::IDENTITY], onUpdated: [LiveProp::IDENTITY => 'onEntireEntityUpdated'])] public Entity1 $entity1; @@ -235,7 +235,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'string: (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public string $firstName; }) @@ -247,7 +247,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'string: changing non-writable causes checksum fail' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public string $firstName; }) @@ -258,7 +258,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'string: changing writable field works' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public string $firstName; }) @@ -272,7 +272,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'float: precision change to the frontend works ok' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public float $price; }) @@ -293,7 +293,7 @@ public function onEntireEntityUpdated($oldValue) yield 'DateTime: (de)hydrates correctly' => [function () { $date = new \DateTime('2023-03-05 9:23', new \DateTimeZone('America/New_York')); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public \DateTime $createdAt; }) @@ -312,7 +312,7 @@ public function onEntireEntityUpdated($oldValue) $entity1 = create(Entity1::class)->object(); \assert($entity1 instanceof Entity1); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public Entity1 $entity1; }) @@ -333,7 +333,7 @@ public function onEntireEntityUpdated($oldValue) \assert($entityOriginal instanceof Entity1); \assert($entityNext instanceof Entity1); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public Entity1 $entity1; }) @@ -354,7 +354,7 @@ public function onEntireEntityUpdated($oldValue) \assert($entityOriginal instanceof Entity1); \assert($entityNext instanceof Entity1); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: [LiveProp::IDENTITY])] public Entity1 $entity1; }) @@ -374,7 +374,7 @@ public function onEntireEntityUpdated($oldValue) 'name' => 'Rubber Chicken', ])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['name'])] public ProductFixtureEntity $product; }) @@ -402,7 +402,7 @@ public function onEntireEntityUpdated($oldValue) yield 'Persisted entity: deleting entity between dehydration and hydration sets it to null' => [function () { $product = create(ProductFixtureEntity::class); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { // test that event the writable path doesn't cause problems #[LiveProp(writable: ['name'])] public ?ProductFixtureEntity $product; @@ -422,7 +422,7 @@ public function onEntireEntityUpdated($oldValue) yield 'Persisted entity: with custom_normalizer and embeddable (de)hydrates correctly' => [function () { $entity2 = create(Entity2::class, ['embedded1' => new Embeddable1('bar'), 'embedded2' => new Embeddable2('baz')])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(useSerializerForHydration: true)] public Entity2 $entity2; }) @@ -445,7 +445,7 @@ public function onEntireEntityUpdated($oldValue) $product->name = 'original name'; $product->price = 333; - return HydrationTest::create(new class() { + return HydrationTest::create(new class { // make a path writable, just to be tricky #[LiveProp(writable: ['price'])] public ProductFixtureEntity $product; @@ -469,7 +469,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Index array: (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public array $foods = []; }) @@ -485,7 +485,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Index array: writable allows all keys to change' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public array $foods = []; }) @@ -503,7 +503,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: (de)hyrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public array $options = []; }) @@ -530,7 +530,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: fully writable allows anything to change' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public array $options = []; }) @@ -558,7 +558,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: fully writable allows partial changes' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public array $options = []; }) @@ -583,7 +583,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: fully writable allows deep partial changes' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true, fieldName: 'invoice')] public array $formData = []; }) @@ -625,7 +625,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: writable paths allow those to change' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['character'])] public array $options = []; }) @@ -655,7 +655,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: writable paths do not allow OTHER keys to change' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['character'])] public array $options = []; }) @@ -678,7 +678,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: support for multiple levels of writable path' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['details.key1'])] public array $stuff = []; }) @@ -704,7 +704,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Associative array: a writable path can itself be an array' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['details'])] public array $stuff = []; }) @@ -732,7 +732,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Empty array: (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public array $foods = []; }) @@ -777,7 +777,7 @@ public function onEntireEntityUpdated($oldValue) }]; yield 'Enum: null remains null' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public ?IntEnum $int = null; @@ -794,7 +794,7 @@ public function onEntireEntityUpdated($oldValue) }, 80100]; yield 'Enum: (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public ?IntEnum $int = null; @@ -813,7 +813,7 @@ public function onEntireEntityUpdated($oldValue) }, 80100]; yield 'Enum: writable enums can be changed' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?IntEnum $int = null; }) @@ -826,7 +826,7 @@ public function onEntireEntityUpdated($oldValue) }, 80100]; yield 'Enum: null-like enum values are handled correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?ZeroIntEnum $zeroInt = null; @@ -856,7 +856,7 @@ public function onEntireEntityUpdated($oldValue) }, 80100]; yield 'Enum: nullable enum with invalid value sets to null' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?IntEnum $int = null; }) @@ -870,7 +870,7 @@ public function onEntireEntityUpdated($oldValue) }, 80100]; yield 'Object: (de)hydrates DTO correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?Address $address = null; @@ -897,7 +897,7 @@ public function mount() }]; yield 'Object: (de)hydrates correctly multidementional DTO' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?CustomerDetails $customerDetails = null; @@ -930,7 +930,7 @@ public function mount() }]; yield 'Object: (de)hydrates correctly array of DTO' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { /** * @var Symfony\UX\LiveComponent\Tests\Fixtures\Dto\CustomerDetails[] $customerDetailsCollection */ @@ -975,7 +975,7 @@ public function mount() $address3 = create(Address::class, ['address' => '124 Conch St.', 'city' => 'Bikini Bottom'])->object(); $address4 = create(Address::class, ['address' => '32 Windsor Gardens', 'city' => 'London'])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { /** * @var Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[] */ @@ -1006,7 +1006,7 @@ public function mount() $address1 = create(Address::class, ['address' => '1600 Pennsylvania Avenue', 'city' => 'Washington DC'])->object(); $address2 = create(Address::class, ['address' => '221 B Baker St', 'city' => 'Birmingham'])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { /** * @var Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Address[] */ @@ -1034,7 +1034,7 @@ public function mount() }]; yield 'Array with DTOs: fully writable allows deep partial changes' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { /** * @var Symfony\UX\LiveComponent\Tests\Fixtures\Dto\HoldsArrayOfDtos[] */ @@ -1091,7 +1091,7 @@ public function mount() }]; yield 'Object: (de)hydrates nested objects with phpdoc typehints' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?ParentDTO $parent = null; @@ -1120,7 +1120,7 @@ public function mount() }]; yield 'Object: using custom normalizer (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(useSerializerForHydration: true)] public Money $money; }) @@ -1136,7 +1136,7 @@ public function mount() }]; yield 'Object: dehydrates to array works correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(useSerializerForHydration: true)] public Temperature $temperature; }) @@ -1155,7 +1155,7 @@ public function mount() }]; yield 'Collection: using serializer (de)hydrates correctly' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { /** @var \Symfony\UX\LiveComponent\Tests\Fixtures\Dto\Temperature[] */ #[LiveProp(useSerializerForHydration: true)] public array $temperatures = []; @@ -1195,7 +1195,7 @@ public function mount() $product->name = 'original name'; $product->price = 333; - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['price'])] public ProductFixtureEntity $product; }) @@ -1208,7 +1208,7 @@ public function mount() }]; yield 'Updating non-writable property is rejected' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp()] public string $name; }) @@ -1221,7 +1221,7 @@ public function mount() }]; yield 'Context: Pass (de)normalization context' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(serializationContext: ['groups' => 'foo'])] public string $name; @@ -1257,7 +1257,7 @@ public function mount() }]; yield 'It is valid to dehydrate to a fully-writable array' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true, dehydrateWith: 'dehydrateDate', hydrateWith: 'hydrateDate')] public \DateTime $createdAt; @@ -1300,7 +1300,7 @@ public function hydrateDate($data) yield 'Use the format option to control the date format' => [function () { return HydrationTest::create( - new class() { + new class { #[LiveProp(writable: true, format: 'Y. m. d.')] public \DateTime $createdAt; @@ -1326,7 +1326,7 @@ public function __construct() yield 'Uses LiveProp modifiers on component dehydration' => [function () { return HydrationTest::create( - new class() { + new class { #[LiveProp(writable: true, modifier: 'modifySearchProp')] public ?string $search = null; @@ -1379,7 +1379,7 @@ public function testHydrationWithInvalidDate(): void $this->expectExceptionMessage('The model path "createdAt" was sent invalid date data "0" or in an invalid format. Make sure it\'s a valid date and it matches the expected format "Y. m. d.".'); $this->executeHydrationTestCase(function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true, format: 'Y. m. d.')] public \DateTime $createdAt; @@ -1403,7 +1403,7 @@ public function __construct() public function testPassingArrayToWritablePropForHydrationIsNotAllowed(): void { - $component = new class() { + $component = new class { #[LiveProp(writable: true)] public \DateTime $createdAt; @@ -1434,7 +1434,7 @@ public function __construct() public function testInterfaceTypedLivePropCannotBeHydrated(): void { - $componentClass = new class() { + $componentClass = new class { #[LiveProp(writable: true)] public ?SimpleDtoInterface $prop = null; }; @@ -1453,7 +1453,7 @@ public function testInterfaceTypedLivePropCannotBeHydrated(): void public function testInterfaceTypedLivePropCannotBeDehydrated(): void { - $componentClass = new class() { + $componentClass = new class { #[LiveProp(writable: true)] public ?SimpleDtoInterface $prop = null; }; @@ -1478,7 +1478,7 @@ public function testInvalidTypeHydration(callable $testFactory, ?int $minPhpVers public static function provideInvalidHydrationTests(): iterable { yield 'invalid_types_string_to_number_uses_coerced' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public int $count; }) @@ -1491,7 +1491,7 @@ public static function provideInvalidHydrationTests(): iterable }]; yield 'invalid_types_array_to_string_is_rejected' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public string $name; }) @@ -1508,7 +1508,7 @@ public static function provideInvalidHydrationTests(): iterable 'price' => 199, ])->object(); - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['name', 'price'])] public ProductFixtureEntity $product; }) @@ -1525,7 +1525,7 @@ public static function provideInvalidHydrationTests(): iterable }]; yield 'invalid_types_enum_with_an_invalid_value' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: true)] public ?IntEnum $nullableInt = null; @@ -1554,7 +1554,7 @@ public static function provideInvalidHydrationTests(): iterable }, 80100]; yield 'writable_path_with_type_problem_ignored' => [function () { - return HydrationTest::create(new class() { + return HydrationTest::create(new class { #[LiveProp(writable: ['name'])] public CategoryFixtureEntity $category; }) @@ -1587,7 +1587,7 @@ public function testHydrationFailsOnChecksumMismatch(): void public function testHydrationTakeUpdatedParentPropsIntoAccount(): void { - $component = new class() { + $component = new class { #[LiveProp(writable: true)] public string $name = 'Ryan'; @@ -1621,7 +1621,7 @@ public function testHydrationTakeUpdatedParentPropsIntoAccount(): void public function testHydrationWithUpdatesParentPropsAndBadChecksumFails(): void { - $component = new class() { + $component = new class { #[LiveProp(updateFromParent: true)] public string $name = 'Ryan'; }; diff --git a/src/LiveComponent/tests/Unit/Attribute/AsLiveComponentTest.php b/src/LiveComponent/tests/Unit/Attribute/AsLiveComponentTest.php index 9e443c7179a..6dcf8029e59 100644 --- a/src/LiveComponent/tests/Unit/Attribute/AsLiveComponentTest.php +++ b/src/LiveComponent/tests/Unit/Attribute/AsLiveComponentTest.php @@ -29,7 +29,7 @@ final class AsLiveComponentTest extends TestCase public function testPreDehydrateMethodsAreOrderedByPriority(): void { $hooks = AsLiveComponent::preDehydrateMethods( - new class() { + new class { #[PreDehydrate(priority: -10)] public function hook1() { @@ -56,7 +56,7 @@ public function hook3() public function testPostHydrateMethodsAreOrderedByPriority(): void { $hooks = AsLiveComponent::postHydrateMethods( - new class() { + new class { #[PostHydrate(priority: -10)] public function hook1() { @@ -83,7 +83,7 @@ public function hook3() public function testPreMountHooksAreOrderedByPriority(): void { $hooks = AsLiveComponent::preReRenderMethods( - new class() { + new class { #[PreReRender(priority: -10)] public function hook1() { diff --git a/src/LiveComponent/tests/Unit/Attribute/LivePropTest.php b/src/LiveComponent/tests/Unit/Attribute/LivePropTest.php index 5ffd4d928a1..be867516f4e 100644 --- a/src/LiveComponent/tests/Unit/Attribute/LivePropTest.php +++ b/src/LiveComponent/tests/Unit/Attribute/LivePropTest.php @@ -33,14 +33,14 @@ public function testDehydrateWithMethod(): void public function testCanCallCalculateFieldNameAsString(): void { - $component = new class() {}; + $component = new class {}; $this->assertSame('field', (new LiveProp(false, null, null, false, [], 'field'))->calculateFieldName($component, 'fallback')); } public function testCanCallCalculateFieldNameAsMethod(): void { - $component = new class() { + $component = new class { public function fieldName(): string { return 'foo'; @@ -52,7 +52,7 @@ public function fieldName(): string public function testCanCallCalculateFieldNameWhenNotSet(): void { - $component = new class() {}; + $component = new class {}; $this->assertSame('fallback', (new LiveProp())->calculateFieldName($component, 'fallback')); } diff --git a/src/LiveComponent/tests/Unit/Twig/LiveComponentRuntimeTest.php b/src/LiveComponent/tests/Unit/Twig/LiveComponentRuntimeTest.php index 654ee92e785..30c3ba8cbbf 100644 --- a/src/LiveComponent/tests/Unit/Twig/LiveComponentRuntimeTest.php +++ b/src/LiveComponent/tests/Unit/Twig/LiveComponentRuntimeTest.php @@ -28,17 +28,17 @@ public function testGetLiveAction(): void $this->assertSame('data-action="live#action" data-live-prop1-param="val1" data-live-some-prop-param="val2" data-live-action-param="action-name"', $props); $props = $runtime->liveAction('action-name', ['prop1' => 'val1', 'prop2' => 'val2'], ['debounce' => 300]); - $this->assertSame('data-action="live#action" data-live-prop1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', \html_entity_decode($props)); + $this->assertSame('data-action="live#action" data-live-prop1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', html_entity_decode($props)); $this->assertSame('data-action="live#action" data-live-prop1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', $props); $props = $runtime->liveAction('action-name:prevent', ['pro1' => 'val1', 'prop2' => 'val2'], ['debounce' => 300]); - $this->assertSame('data-action="live#action:prevent" data-live-pro1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', \html_entity_decode($props)); + $this->assertSame('data-action="live#action:prevent" data-live-pro1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', html_entity_decode($props)); $this->assertSame('data-action="live#action:prevent" data-live-pro1-param="val1" data-live-prop2-param="val2" data-live-action-param="debounce(300)|action-name"', $props); $props = $runtime->liveAction('action-name:prevent', [], ['debounce' => 300]); - $this->assertSame('data-action="live#action:prevent" data-live-action-param="debounce(300)|action-name"', \html_entity_decode($props)); + $this->assertSame('data-action="live#action:prevent" data-live-action-param="debounce(300)|action-name"', html_entity_decode($props)); $props = $runtime->liveAction('action-name', [], [], 'keydown.esc'); - $this->assertSame('data-action="keydown.esc->live#action" data-live-action-param="action-name"', \html_entity_decode($props)); + $this->assertSame('data-action="keydown.esc->live#action" data-live-action-param="action-name"', html_entity_decode($props)); } } diff --git a/src/Map/tests/MapTest.php b/src/Map/tests/MapTest.php index c108e8f67c0..99a4f1ebc37 100644 --- a/src/Map/tests/MapTest.php +++ b/src/Map/tests/MapTest.php @@ -83,7 +83,7 @@ public function testWithMaximumConfiguration(): void ->center(new Point(48.8566, 2.3522)) ->zoom(6) ->fitBoundsToMarkers() - ->options(new class() implements MapOptionsInterface { + ->options(new class implements MapOptionsInterface { public function toArray(): array { return [ diff --git a/src/Turbo/src/TurboBundle.php b/src/Turbo/src/TurboBundle.php index 61542a4bab9..4c97d52584d 100644 --- a/src/Turbo/src/TurboBundle.php +++ b/src/Turbo/src/TurboBundle.php @@ -34,7 +34,7 @@ public function build(ContainerBuilder $container): void { parent::build($container); - $container->addCompilerPass(new class() implements CompilerPassInterface { + $container->addCompilerPass(new class implements CompilerPassInterface { public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('turbo.broadcaster.imux')) { diff --git a/src/TwigComponent/src/Attribute/AsTwigComponent.php b/src/TwigComponent/src/Attribute/AsTwigComponent.php index 3d31240b686..d58e5647ae8 100644 --- a/src/TwigComponent/src/Attribute/AsTwigComponent.php +++ b/src/TwigComponent/src/Attribute/AsTwigComponent.php @@ -78,8 +78,6 @@ public function serviceConfig(): array /** * @param object|class-string $component * - * @return ?\ReflectionMethod - * * @internal */ public static function mountMethod(object|string $component): ?\ReflectionMethod diff --git a/src/TwigComponent/tests/Integration/ComponentFactoryTest.php b/src/TwigComponent/tests/Integration/ComponentFactoryTest.php index f36f9489e3f..72064f47669 100644 --- a/src/TwigComponent/tests/Integration/ComponentFactoryTest.php +++ b/src/TwigComponent/tests/Integration/ComponentFactoryTest.php @@ -94,7 +94,7 @@ public function testExceptionThrownIfRequiredMountParameterIsMissingFromPassedDa public function testStringableObjectCanBePassedToComponent(): void { - $attributes = $this->factory()->create('component_a', ['propB' => 'B', 'data-item-id-param' => new class() { + $attributes = $this->factory()->create('component_a', ['propB' => 'B', 'data-item-id-param' => new class { public function __toString(): string { return 'test'; diff --git a/src/TwigComponent/tests/Unit/Attribute/AsTwigComponentTest.php b/src/TwigComponent/tests/Unit/Attribute/AsTwigComponentTest.php index 3c577280865..1606792ca99 100644 --- a/src/TwigComponent/tests/Unit/Attribute/AsTwigComponentTest.php +++ b/src/TwigComponent/tests/Unit/Attribute/AsTwigComponentTest.php @@ -24,7 +24,7 @@ final class AsTwigComponentTest extends TestCase public function testPreMountHooksAreOrderedByPriority(): void { $hooks = AsTwigComponent::preMountMethods( - new class() { + new class { #[PreMount(priority: -10)] public function hook1() { @@ -51,7 +51,7 @@ public function hook3() public function testPostMountHooksAreOrderedByPriority(): void { $hooks = AsTwigComponent::postMountMethods( - new class() { + new class { #[PostMount(priority: -10)] public function hook1() { diff --git a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php index 824a148f7d3..5e22ac737c8 100644 --- a/src/TwigComponent/tests/Unit/ComponentAttributesTest.php +++ b/src/TwigComponent/tests/Unit/ComponentAttributesTest.php @@ -27,7 +27,7 @@ public function testCanConvertToString(): void { $attributes = new ComponentAttributes([ 'class' => 'foo', - 'style' => new class() { + 'style' => new class { public function __toString(): string { return 'color:black;'; @@ -216,7 +216,7 @@ public function testRenderSingleAttribute(): void public function testRenderingSingleAttributeExcludesFromString(): void { $attributes = new ComponentAttributes([ - 'attr1' => new class() { + 'attr1' => new class { public function __toString(): string { return 'value1'; diff --git a/src/TwigComponent/tests/Unit/ComputedPropertiesProxyTest.php b/src/TwigComponent/tests/Unit/ComputedPropertiesProxyTest.php index d7f6bd3370f..adb954ba224 100644 --- a/src/TwigComponent/tests/Unit/ComputedPropertiesProxyTest.php +++ b/src/TwigComponent/tests/Unit/ComputedPropertiesProxyTest.php @@ -21,7 +21,7 @@ final class ComputedPropertiesProxyTest extends TestCase { public function testProxyCachesGetMethodReturns(): void { - $proxy = new ComputedPropertiesProxy(new class() { + $proxy = new ComputedPropertiesProxy(new class { private int $count = 0; public function getCount(): int @@ -37,7 +37,7 @@ public function getCount(): int public function testProxyCachesIsMethodReturns(): void { - $proxy = new ComputedPropertiesProxy(new class() { + $proxy = new ComputedPropertiesProxy(new class { private int $count = 0; public function isCount(): int @@ -53,7 +53,7 @@ public function isCount(): int public function testProxyCachesHasMethodReturns(): void { - $proxy = new ComputedPropertiesProxy(new class() { + $proxy = new ComputedPropertiesProxy(new class { private int $count = 0; public function hasCount(): int @@ -69,7 +69,7 @@ public function hasCount(): int public function testCanProxyPublicProperties(): void { - $proxy = new ComputedPropertiesProxy(new class() { + $proxy = new ComputedPropertiesProxy(new class { public $foo = 'bar'; }); @@ -78,7 +78,7 @@ public function testCanProxyPublicProperties(): void public function testCanProxyArrayAccess(): void { - $proxy = new ComputedPropertiesProxy(new class() implements \ArrayAccess { + $proxy = new ComputedPropertiesProxy(new class implements \ArrayAccess { private $array = ['foo' => 'bar']; public function offsetExists(mixed $offset): bool @@ -105,7 +105,7 @@ public function offsetUnset(mixed $offset): void public function testCannotProxyMethodsThatDoNotExist(): void { - $proxy = new ComputedPropertiesProxy(new class() {}); + $proxy = new ComputedPropertiesProxy(new class {}); $this->expectException(\InvalidArgumentException::class); @@ -114,7 +114,7 @@ public function testCannotProxyMethodsThatDoNotExist(): void public function testCannotPassArgumentsToProxiedMethods(): void { - $proxy = new ComputedPropertiesProxy(new class() {}); + $proxy = new ComputedPropertiesProxy(new class {}); $this->expectException(\InvalidArgumentException::class); @@ -123,7 +123,7 @@ public function testCannotPassArgumentsToProxiedMethods(): void public function testCannotProxyMethodsWithRequiredArguments(): void { - $proxy = new ComputedPropertiesProxy(new class() { + $proxy = new ComputedPropertiesProxy(new class { public function getValue(int $value): int { return $value; diff --git a/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php b/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php index cf983f1fb42..6695e064caf 100644 --- a/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php +++ b/src/TwigComponent/tests/Unit/DependencyInjection/TwigComponentExtensionTest.php @@ -98,7 +98,7 @@ private function createContainer() 'kernel.debug' => true, 'kernel.project_dir' => __DIR__, 'kernel.bundles' => [ - 'TwigBundle' => new class() {}, + 'TwigBundle' => new class {}, 'TwigComponentBundle' => TwigComponentBundle::class, ], ])); diff --git a/ux.symfony.com/.php-cs-fixer.dist.php b/ux.symfony.com/.php-cs-fixer.dist.php index 840416cebf3..b52ba19c910 100644 --- a/ux.symfony.com/.php-cs-fixer.dist.php +++ b/ux.symfony.com/.php-cs-fixer.dist.php @@ -30,9 +30,6 @@ '@Symfony' => true, '@Symfony:risky' => true, 'header_comment' => ['header' => $fileHeaderComment], - 'nullable_type_declaration' => true, - // TODO: Remove once the "compiler_optimized" set includes "sprintf" - 'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true], 'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']], ]) ->setRiskyAllowed(true)