Skip to content

Commit 2d54d69

Browse files
committed
chore(v3): remove PHP version guards
1 parent 611df04 commit 2d54d69

File tree

6 files changed

+6
-27
lines changed

6 files changed

+6
-27
lines changed

config/persistence.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,11 @@
4040
'command' => 'foundry:load-fixtures|foundry:load-stories|foundry:load-story',
4141
'description' => 'Load stories which are marked with #[AsFixture] attribute.',
4242
])
43-
;
44-
45-
if (\PHP_VERSION_ID >= 80400) {
46-
$container->services()->set('.foundry.persistence.objects_tracker', PersistedObjectsTracker::class)
43+
->set('.foundry.persistence.objects_tracker', PersistedObjectsTracker::class)
4744
->tag('kernel.reset', ['method' => 'refresh'])
4845
->tag('kernel.event_listener', ['event' => TerminateEvent::class, 'method' => 'refresh'])
4946
->tag('kernel.event_listener', ['event' => ConsoleTerminateEvent::class, 'method' => 'refresh'])
5047
->tag('kernel.event_listener', ['event' => WorkerMessageHandledEvent::class, 'method' => 'refresh']) // @phpstan-ignore class.notFound
5148
->tag('foundry.hook', ['class' => null, 'method' => 'afterPersistHook', 'event' => AfterPersist::class])
52-
;
53-
}
49+
;
5450
};

phpstan.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ parameters:
2626
- identifier: missingType.iterableValue
2727
path: tests/
2828

29-
# PHPStan does not understand PHP version checks
30-
- message: '#Comparison operation "(<|>|<=|>=)" between int<80\d+, 80\d+> and 80\d+ is always (false|true).#'
31-
3229
# Hydrator and Factory are annotated @immutable
3330
- identifier: property.readOnlyByPhpDocDefaultValue
3431
paths:

skeleton/Factory.tpl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct()
2222
{
2323
}
2424

25-
<?php endif ?><?php if ($makeFactoryData->shouldAddOverrideAttributes()): ?> #[\Override]<?php endif ?>
25+
<?php endif ?> #[\Override]
2626
public static function class(): string
2727
{
2828
return <?php echo $makeFactoryData->getObjectShortName(); ?>::class;
@@ -33,7 +33,7 @@ public static function class(): string
3333
*
3434
* @todo add your default values here
3535
*/
36-
<?php endif ?><?php if ($makeFactoryData->shouldAddOverrideAttributes()): ?> #[\Override]<?php endif ?>
36+
<?php endif ?> #[\Override]
3737
protected function defaults(): array<?php if ($makeFactoryData->shouldAddHints()): ?>|callable<?php endif ?>
3838
{
3939
return [
@@ -48,7 +48,7 @@ protected function defaults(): array<?php if ($makeFactoryData->shouldAddHints()
4848
<?php if ($makeFactoryData->shouldAddHints()): ?> /**
4949
* @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization
5050
*/
51-
<?php if ($makeFactoryData->shouldAddOverrideAttributes()): ?> #[\Override]<?php endif ?>
51+
#[\Override]
5252
protected function initialize(): static
5353
{
5454
return $this

src/Maker/Factory/MakeFactoryData.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ public function getDefaultProperties(): array
157157

158158
public function addEnumDefaultProperty(string $propertyName, string $enumClass): void
159159
{
160-
if (\PHP_VERSION_ID < 80100) {
161-
throw new \LogicException('Cannot add enum for php version inferior than 8.1');
162-
}
163-
164160
if (!\enum_exists($enumClass)) {
165161
throw new \InvalidArgumentException("Enum of class \"{$enumClass}\" does not exist.");
166162
}
@@ -179,14 +175,6 @@ public function shouldAddHints(): bool
179175
return $this->addHints;
180176
}
181177

182-
/**
183-
* @phpstan-ignore return.tooWideBool
184-
*/
185-
public function shouldAddOverrideAttributes(): bool
186-
{
187-
return \PHP_VERSION_ID >= 80300;
188-
}
189-
190178
private static function propertyInfo(): ReflectionExtractor
191179
{
192180
return self::$propertyInfo ??= new ReflectionExtractor();

src/Maker/Factory/ObjectDefaultPropertiesGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __invoke(SymfonyStyle $io, MakeFactoryData $makeFactoryData, Mak
3939

4040
$value = \sprintf('null, // TODO add %svalue manually', $type ? "{$type} " : '');
4141

42-
if (\PHP_VERSION_ID >= 80100 && \enum_exists($type)) {
42+
if (\enum_exists($type)) {
4343
$makeFactoryData->addEnumDefaultProperty($property->getName(), $type);
4444

4545
continue;

tests/Integration/ArrayFactoryTest.php

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

1212
namespace Zenstruck\Foundry\Tests\Integration;
1313

14-
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
1514
use PHPUnit\Framework\Attributes\Test;
1615
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1716
use Zenstruck\Foundry\LazyValue;
@@ -26,7 +25,6 @@ final class ArrayFactoryTest extends KernelTestCase
2625
* @test
2726
*/
2827
#[Test]
29-
#[IgnoreDeprecations]
3028
public function can_create_with_defaults(): void
3129
{
3230
$this->assertSame(

0 commit comments

Comments
 (0)