Skip to content

Commit 211ee5b

Browse files
committed
minor #2079 [LiveComponent] Fix PHP8.4 errors + deprecations (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [LiveComponent] Fix PHP8.4 errors + deprecations First patch of fixes (thanks to the PHP 8.4 tesst) Commits ------- 0a862d7 [LiveComponent] Fix PHP8.4 errors + deprecations
2 parents b083b76 + 0a862d7 commit 211ee5b

19 files changed

+125
-151
lines changed

src/Icons/tests/Integration/Command/SearchIconCommandTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@ final class SearchIconCommandTest extends KernelTestCase
2323

2424
public function testSearchWithPrefix(): void
2525
{
26-
$this->consoleCommand('ux:icons:search lucide')
26+
$this->consoleCommand('ux:icons:search iconoir')
2727
->execute()
2828
->assertSuccessful()
2929
->assertOutputContains('Icon set')
30-
->assertOutputContains('Lucide')
30+
->assertOutputContains('Iconoir')
3131
->assertOutputContains('Icons')
3232
->assertOutputContains('License')
33-
->assertOutputContains('ISC')
33+
->assertOutputContains('MIT')
3434
->assertOutputContains('Prefix')
35-
->assertOutputContains('lucide')
35+
->assertOutputContains('iconoir')
3636
->assertOutputContains('Example')
37-
->assertOutputContains('lucide:')
38-
->assertOutputContains('php bin/console ux:icons:search lucide');
37+
->assertOutputContains('iconoir:')
38+
->assertOutputContains('php bin/console ux:icons:search iconoir')
39+
->assertStatusCode(0);
3940
}
4041

4142
public function testSearchWithPrefixMatchingMultipleSet(): void

src/LiveComponent/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
5252
"symfony/validator": "^5.4|^6.0|^7.0",
5353
"zenstruck/browser": "^1.2.0",
54-
"zenstruck/foundry": "1.37.*"
54+
"zenstruck/foundry": "^2.0"
5555
},
5656
"conflict": {
5757
"symfony/config": "<5.4.0"

src/LiveComponent/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<server name="KERNEL_CLASS" value="Symfony\UX\LiveComponent\Tests\Fixtures\Kernel"/>
1919
<server name="DATABASE_URL" value="sqlite:///%kernel.project_dir%/var/data.db"/>
2020
<env name="SHELL_VERBOSITY" value="-1"/>
21-
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;ignoreFile=./tests/baseline-ignore"/>
21+
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0&amp;quiet[]=indirect&amp;quiet[]=other"/>
2222
</php>
2323

2424
<testsuites>

src/LiveComponent/tests/Fixtures/Dto/HoldsArrayOfDtos.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the Symfony package.
7+
*
8+
* (c) Fabien Potencier <fabien@symfony.com>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
514
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Dto;
615

716
final class HoldsArrayOfDtos
817
{
918
/**
10-
* @var Address[] $addresses
19+
* @var Address[]
1120
*/
1221
public array $addresses;
1322
}

src/LiveComponent/tests/Fixtures/Entity/TodoItemFixtureEntity.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ class TodoItemFixtureEntity
2424
public $id;
2525

2626
#[ORM\Column(type: 'string')]
27-
private ?string $name = null;
27+
private ?string $name;
2828

2929
#[ORM\ManyToOne(targetEntity: TodoListFixtureEntity::class, inversedBy: 'todoItems')]
3030
private TodoListFixtureEntity $todoList;
3131

32-
/**
33-
* @param string $name
34-
*/
35-
public function __construct(string $name = null)
32+
public function __construct(?string $name = null)
3633
{
3734
$this->name = $name;
3835
}

src/LiveComponent/tests/Fixtures/Factory/CompositeIdEntityFactory.php

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,20 @@
1111

1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

14-
use Doctrine\ORM\EntityRepository;
1514
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\CompositeIdEntity;
16-
use Zenstruck\Foundry\ModelFactory;
17-
use Zenstruck\Foundry\Proxy;
18-
use Zenstruck\Foundry\RepositoryProxy;
15+
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
1916

2017
/**
21-
* @extends ModelFactory<CompositeIdEntity>
22-
*
23-
* @method static CompositeIdEntity|Proxy createOne(array $attributes = [])
24-
* @method static CompositeIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
25-
* @method static CompositeIdEntity|Proxy find(object|array|mixed $criteria)
26-
* @method static CompositeIdEntity|Proxy findOrCreate(array $attributes)
27-
* @method static CompositeIdEntity|Proxy first(string $sortedField = 'id')
28-
* @method static CompositeIdEntity|Proxy last(string $sortedField = 'id')
29-
* @method static CompositeIdEntity|Proxy random(array $attributes = [])
30-
* @method static CompositeIdEntity|Proxy randomOrCreate(array $attributes = []))
31-
* @method static CompositeIdEntity[]|Proxy[] all()
32-
* @method static CompositeIdEntity[]|Proxy[] findBy(array $attributes)
33-
* @method static CompositeIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
34-
* @method static CompositeIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
35-
* @method static EntityRepository|RepositoryProxy repository()
36-
* @method CompositeIdEntity|Proxy create(array|callable $attributes = [])
18+
* @extends PersistentProxyObjectFactory<CompositeIdEntity>
3719
*/
38-
class CompositeIdEntityFactory extends ModelFactory
20+
class CompositeIdEntityFactory extends PersistentProxyObjectFactory
3921
{
40-
protected static function getClass(): string
22+
public static function class(): string
4123
{
4224
return CompositeIdEntity::class;
4325
}
4426

45-
protected function getDefaults(): array
27+
protected function defaults(): array
4628
{
4729
return [
4830
'firstIdPart' => rand(1, \PHP_INT_MAX),

src/LiveComponent/tests/Fixtures/Factory/ForeignKeyIdEntityFactory.php

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,23 @@
1111

1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Factory;
1313

14-
use Doctrine\ORM\EntityRepository;
1514
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\Entity1;
1615
use Symfony\UX\LiveComponent\Tests\Fixtures\Entity\ForeignKeyIdEntity;
17-
use Zenstruck\Foundry\ModelFactory;
18-
use Zenstruck\Foundry\Proxy;
19-
use Zenstruck\Foundry\RepositoryProxy;
16+
use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory;
2017

2118
use function Zenstruck\Foundry\lazy;
2219

2320
/**
24-
* @extends ModelFactory<ForeignKeyIdEntity>
25-
*
26-
* @method static ForeignKeyIdEntity|Proxy createOne(array $attributes = [])
27-
* @method static ForeignKeyIdEntity[]|Proxy[] createMany(int $number, array|callable $attributes = [])
28-
* @method static ForeignKeyIdEntity|Proxy find(object|array|mixed $criteria)
29-
* @method static ForeignKeyIdEntity|Proxy findOrCreate(array $attributes)
30-
* @method static ForeignKeyIdEntity|Proxy first(string $sortedField = 'id')
31-
* @method static ForeignKeyIdEntity|Proxy last(string $sortedField = 'id')
32-
* @method static ForeignKeyIdEntity|Proxy random(array $attributes = [])
33-
* @method static ForeignKeyIdEntity|Proxy randomOrCreate(array $attributes = []))
34-
* @method static ForeignKeyIdEntity[]|Proxy[] all()
35-
* @method static ForeignKeyIdEntity[]|Proxy[] findBy(array $attributes)
36-
* @method static ForeignKeyIdEntity[]|Proxy[] randomSet(int $number, array $attributes = []))
37-
* @method static ForeignKeyIdEntity[]|Proxy[] randomRange(int $min, int $max, array $attributes = []))
38-
* @method static EntityRepository|RepositoryProxy repository()
39-
* @method ForeignKeyIdEntity|Proxy create(array|callable $attributes = [])
21+
* @extends PersistentProxyObjectFactory<ForeignKeyIdEntity>
4022
*/
41-
class ForeignKeyIdEntityFactory extends ModelFactory
23+
class ForeignKeyIdEntityFactory extends PersistentProxyObjectFactory
4224
{
43-
protected static function getClass(): string
25+
public static function class(): string
4426
{
4527
return ForeignKeyIdEntity::class;
4628
}
4729

48-
protected function getDefaults(): array
30+
protected function defaults(): array
4931
{
5032
return ['id' => lazy(static fn () => new Entity1())];
5133
}

src/LiveComponent/tests/Fixtures/Kernel.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public function index(): Response
5151
return new Response('index');
5252
}
5353

54-
public function renderTemplate(string $template, Environment $twig = null): Response
54+
public function renderTemplate(string $template, ?Environment $twig = null): Response
5555
{
5656
$twig ??= $this->container->get('twig');
5757

5858
return new Response($twig->render("{$template}.html.twig"));
5959
}
6060

61-
public function renderNamespacedTemplate(string $template, Environment $twig = null): Response
61+
public function renderNamespacedTemplate(string $template, ?Environment $twig = null): Response
6262
{
6363
$twig ??= $this->container->get('twig');
6464

@@ -171,6 +171,7 @@ protected function configureContainer(ContainerConfigurator $c): void
171171
],
172172
],
173173
];
174+
174175
if (null !== $doctrineBundleVersion = InstalledVersions::getVersion('doctrine/doctrine-bundle')) {
175176
if (version_compare($doctrineBundleVersion, '2.8.0', '>=')) {
176177
$doctrineConfig['orm']['enable_lazy_ghost_objects'] = true;
@@ -181,14 +182,13 @@ protected function configureContainer(ContainerConfigurator $c): void
181182
$doctrineConfig['orm']['validate_xml_mapping'] = true;
182183
$doctrineConfig['dbal']['schema_manager_factory'] = 'doctrine.dbal.default_schema_manager_factory';
183184
}
185+
if (version_compare($doctrineBundleVersion, '2.12.0', '>=')) {
186+
$doctrineConfig['orm']['controller_resolver']['auto_mapping'] = false;
187+
}
184188
}
185189

186190
$c->extension('doctrine', $doctrineConfig);
187191

188-
$c->extension('zenstruck_foundry', [
189-
'auto_refresh_proxies' => false,
190-
]);
191-
192192
$c->services()
193193
->defaults()
194194
->autowire()

src/LiveComponent/tests/Fixtures/Serializer/Entity2Normalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function supportsNormalization(mixed $data, string $format = null, array
4747
return $data instanceof Entity2;
4848
}
4949

50-
public function getSupportedTypes(?string $format): array
50+
public function getSupportedTypes(?string $format = null): array
5151
{
5252
return [Entity2::class => true];
5353
}

src/LiveComponent/tests/Fixtures/Serializer/MoneyNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function supportsNormalization(mixed $data, string $format = null, array
3737
return $data instanceof Money;
3838
}
3939

40-
public function getSupportedTypes(?string $format): array
40+
public function getSupportedTypes(string $format = null): array
4141
{
4242
return [Money::class => true];
4343
}

src/LiveComponent/tests/Functional/EventListener/LiveComponentSubscriberTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Zenstruck\Foundry\Test\Factories;
2323
use Zenstruck\Foundry\Test\ResetDatabase;
2424

25-
use function Zenstruck\Foundry\create;
25+
use function Zenstruck\Foundry\Persistence\persist;
2626

2727
/**
2828
* @author Kevin Bond <kevinbond@gmail.com>
@@ -48,7 +48,7 @@ final class LiveComponentSubscriberTest extends KernelTestCase
4848
public function testCanRenderComponentAsHtml(): void
4949
{
5050
$component = $this->mountComponent('component1', [
51-
'prop1' => $entity = create(Entity1::class)->object(),
51+
'prop1' => $entity = persist(Entity1::class),
5252
'prop2' => $date = new \DateTime('2021-03-05 9:23'),
5353
'prop3' => 'value3',
5454
'prop4' => 'value4',

src/LiveComponent/tests/Functional/LiveResponderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\LiveComponent\Tests\Functional\EventListener;
12+
namespace Symfony\UX\LiveComponent\Tests\Functional;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;

src/LiveComponent/tests/Functional/ValidatableComponentTraitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\LiveComponent\Tests\Functional\Form;
12+
namespace Symfony\UX\LiveComponent\Tests\Functional;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\UX\LiveComponent\Tests\LiveComponentTestHelper;

src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\LiveComponent\Tests\Integration;
12+
namespace Symfony\UX\LiveComponent\Tests\Integration\EventListener;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\Component\HttpFoundation\Request;

src/LiveComponent/tests/Integration/Hydration/DoctrineEntityHydrationExtensionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\LiveComponent\Tests\Unit\Hydration;
12+
namespace Symfony\UX\LiveComponent\Tests\Integration\Hydration;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\UX\LiveComponent\Hydration\DoctrineEntityHydrationExtension;
@@ -27,7 +27,7 @@ class DoctrineEntityHydrationExtensionTest extends KernelTestCase
2727

2828
public function testCompositeId(): void
2929
{
30-
$compositeIdEntity = CompositeIdEntityFactory::createOne()->save()->object();
30+
$compositeIdEntity = CompositeIdEntityFactory::createOne()->_real();
3131

3232
/** @var DoctrineEntityHydrationExtension $extension */
3333
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');
@@ -40,7 +40,7 @@ public function testCompositeId(): void
4040

4141
public function testForeignKeyId(): void
4242
{
43-
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne()->save()->object();
43+
$foreignKeyIdEntity = ForeignKeyIdEntityFactory::createOne()->_real();
4444

4545
/** @var DoctrineEntityHydrationExtension $extension */
4646
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');

0 commit comments

Comments
 (0)