Skip to content

Commit a4c22e8

Browse files
authored
chore(v3): remove deprecated configs (#1096)
1 parent e9442d1 commit a4c22e8

29 files changed

+21
-695
lines changed

.github/workflows/benchmarks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Checkout
5353
uses: actions/checkout@v4
5454
with:
55-
ref: 2.x
55+
ref: 3.x
5656
fetch-depth: 1
5757

5858
- name: Install dependencies
@@ -71,7 +71,7 @@ jobs:
7171
bin/tools/phpbench/vendor/phpbench/phpbench/bin/phpbench run \
7272
tests/Benchmark \
7373
--report=aggregate \
74-
--tag=2.x \
74+
--tag=3.x \
7575
--iterations=5 \
7676
--progress=plain \
7777
--retry-threshold=10
@@ -99,7 +99,7 @@ jobs:
9999
bin/tools/phpbench/vendor/phpbench/phpbench/bin/phpbench run \
100100
tests/Benchmark \
101101
--report=aggregate \
102-
--ref=2.x \
102+
--ref=3.x \
103103
--iterations=5 \
104104
--progress=plain \
105105
--retry-threshold=10 \

config/makers.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
->set('.zenstruck_foundry.maker.factory.generator', FactoryGenerator::class)
8282
->args([
8383
service('.zenstruck_foundry.persistence_manager')->nullOnInvalid(),
84-
service('kernel'),
8584
tagged_iterator('foundry.make_factory.default_properties_guesser'),
8685
service('.zenstruck_foundry.maker.factory.factory_class_map'),
8786
service('.zenstruck_foundry.maker.namespace_guesser'),

config/services.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
->set('.zenstruck_foundry.faker.adapter', FakerAdapter::class)
3939
->args([
4040
service('.zenstruck_foundry.faker'),
41-
param('zenstruck_foundry.faker.seed'),
4241
env('default::int:FOUNDRY_FAKER_SEED'),
4342
param('zenstruck_foundry.faker.manage_seed'),
4443
])
@@ -50,7 +49,6 @@
5049
service('.zenstruck_foundry.instantiator'),
5150
service('.zenstruck_foundry.story_registry'),
5251
service('.zenstruck_foundry.persistence_manager')->nullOnInvalid(),
53-
param('zenstruck_foundry.persistence.flush_once'),
5452
service('.zenstruck_foundry.in_memory.repository_registry'),
5553
service('.foundry.persistence.objects_tracker')->nullOnInvalid(),
5654
param('zenstruck_foundry.enable_auto_refresh_with_lazy_objects'),

phpstan.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ parameters:
4949
- identifier: missingType.generics
5050
path: src/Maker/Factory/
5151

52-
# not relevant for factories generated by maker
53-
- identifier: missingType.callable
54-
path: tests/Fixture/Maker/expected/
55-
5652
# not relevant for files outside from Foundry's namespace
5753
- identifier: classConstant.internalClass
5854
path: config/

skeleton/Factory.tpl.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@
1010

1111
/**
1212
* @extends <?php echo $makeFactoryData->getFactoryClassShortName(); ?><<?php echo $makeFactoryData->getObjectShortName(); ?>>
13-
<?php
14-
if (count($makeFactoryData->getMethodsPHPDoc())) {
15-
echo " *\n";
16-
foreach ($makeFactoryData->getMethodsPHPDoc() as $methodPHPDoc) {
17-
echo "{$methodPHPDoc->toString()}\n";
18-
}
19-
20-
echo " *\n";
21-
22-
foreach ($makeFactoryData->getMethodsPHPDoc() as $methodPHPDoc) {
23-
echo "{$methodPHPDoc->toString($makeFactoryData->staticAnalysisTool())}\n";
24-
}
25-
}
26-
?>
2713
*/
2814
final class <?php echo $class_name; ?> extends <?php echo $makeFactoryData->getFactoryClassShortName(); ?>
2915
{

src/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public function __construct(
5656
callable $instantiator,
5757
public readonly StoryRegistry $stories,
5858
private readonly ?PersistenceManager $persistence = null,
59-
public readonly bool $flushOnce = false,
6059
public readonly ?InMemoryRepositoryRegistry $inMemoryRepositoryRegistry = null,
6160
public readonly ?PersistedObjectsTracker $persistedObjectsTracker = null,
6261
private readonly bool $enableAutoRefreshWithLazyObjects = false,

src/FactoryCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function create(array|callable $attributes = []): array
147147
{
148148
$factories = $this->all();
149149

150-
if (Configuration::instance()->flushOnce && $this->isRootFactory && $this->factory instanceof PersistentObjectFactory && $this->factory->isPersisting()) {
150+
if ($this->isRootFactory && $this->factory instanceof PersistentObjectFactory && $this->factory->isPersisting()) {
151151
$lastFactory = \array_pop($factories);
152152
// @phpstan-ignore method.notFound (phpstan does not understand that we only have persistent factories here)
153153
$factories = \array_map(static fn(Factory $f) => $f->notRootFactory(), $factories);

src/FakerAdapter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
final class FakerAdapter
2222
{
2323
private static ?int $fakerSeed = null;
24-
private ?int $forcedFakerSeed;
2524

2625
private static bool $fakerSeedHasBeenSet = false;
2726

2827
public function __construct(
2928
private readonly Faker\Generator $faker,
30-
?int $forcedFakerSeedFromConfig = null,
31-
?int $forcedFakerSeedFromEnv = null,
29+
private ?int $forcedFakerSeed = null,
3230
private bool $manageFakerSeed = true,
3331
) {
34-
$this->forcedFakerSeed = $forcedFakerSeedFromEnv ?? $forcedFakerSeedFromConfig;
3532
}
3633

3734
public static function fakerSeed(): ?int

src/Maker/Factory/FactoryGenerator.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@
2929
*/
3030
final class FactoryGenerator
3131
{
32-
public const PHPSTAN_PATH = '/vendor/phpstan/phpstan/phpstan';
33-
public const PSALM_PATH = '/vendor/vimeo/psalm/psalm';
34-
3532
/** @param \Traversable<int, DefaultPropertiesGuesser> $defaultPropertiesGuessers */
3633
public function __construct(
3734
private ?PersistenceManager $persistenceManager,
38-
private KernelInterface $kernel,
3935
private \Traversable $defaultPropertiesGuessers,
4036
private FactoryClassMap $factoryClassMap,
4137
private NamespaceGuesser $namespaceGuesser,
@@ -148,20 +144,9 @@ private function createMakeFactoryData(Generator $generator, string $class, Make
148144
$object,
149145
$factory,
150146
$repository ?? null,
151-
$this->staticAnalysisTool(),
152147
$persisted ?? false,
153-
$makeFactoryQuery->addPhpDoc(),
154148
$this->forceProperties,
155149
$makeFactoryQuery->shouldAddHints(),
156150
);
157151
}
158-
159-
private function staticAnalysisTool(): string
160-
{
161-
return match (true) {
162-
\file_exists($this->kernel->getProjectDir().self::PHPSTAN_PATH) => MakeFactoryData::STATIC_ANALYSIS_TOOL_PHPSTAN,
163-
\file_exists($this->kernel->getProjectDir().self::PSALM_PATH) => MakeFactoryData::STATIC_ANALYSIS_TOOL_PSALM,
164-
default => MakeFactoryData::STATIC_ANALYSIS_TOOL_NONE,
165-
};
166-
}
167152
}

src/Maker/Factory/MakeFactoryData.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,18 @@
2525
*/
2626
final class MakeFactoryData
2727
{
28-
public const STATIC_ANALYSIS_TOOL_NONE = 'none';
29-
public const STATIC_ANALYSIS_TOOL_PHPSTAN = 'phpstan';
30-
public const STATIC_ANALYSIS_TOOL_PSALM = 'psalm';
31-
3228
private static ?ReflectionExtractor $propertyInfo = null;
3329

3430
/** @var list<string> */
3531
private array $uses;
3632
/** @var array<string, string> */
3733
private array $defaultProperties = [];
38-
/** @var list<MakeFactoryPHPDocMethod> */
39-
private array $methodsInPHPDoc;
4034

4135
public function __construct(
4236
private \ReflectionClass $object,
4337
private ClassNameDetails $factoryClassNameDetails,
4438
private ?\ReflectionClass $repository,
45-
private string $staticAnalysisTool,
4639
private bool $persisted,
47-
bool $withPhpDoc,
4840
private bool $forceProperties,
4941
private bool $addHints,
5042
) {
@@ -60,8 +52,6 @@ public function __construct(
6052
$this->uses[] = \is_a($repository->getName(), DocumentRepository::class, allow_string: true) ? DocumentRepository::class : EntityRepository::class;
6153
}
6254
}
63-
64-
$this->methodsInPHPDoc = $withPhpDoc ? MakeFactoryPHPDocMethod::createAll($this) : [];
6555
}
6656

6757
// @phpstan-ignore-next-line
@@ -109,16 +99,6 @@ public function isPersisted(): bool
10999
return $this->persisted;
110100
}
111101

112-
public function staticAnalysisTool(): string
113-
{
114-
// if none was detected, let's fallback on phpstan: both psalm and phpstan can read `@phpstan` annotations
115-
if (self::STATIC_ANALYSIS_TOOL_NONE === $this->staticAnalysisTool) {
116-
return self::STATIC_ANALYSIS_TOOL_PHPSTAN;
117-
}
118-
119-
return $this->staticAnalysisTool;
120-
}
121-
122102
/** @param class-string $use */
123103
public function addUse(string $use): void
124104
{
@@ -175,18 +155,6 @@ public function getDefaultProperties(): array
175155
return $defaultProperties;
176156
}
177157

178-
/** @return list<MakeFactoryPHPDocMethod> */
179-
public function getMethodsPHPDoc(): array
180-
{
181-
$methodsInPHPDoc = $this->methodsInPHPDoc;
182-
\usort(
183-
$methodsInPHPDoc,
184-
static fn(MakeFactoryPHPDocMethod $m1, MakeFactoryPHPDocMethod $m2) => $m1->sortValue() <=> $m2->sortValue(),
185-
);
186-
187-
return $methodsInPHPDoc;
188-
}
189-
190158
public function addEnumDefaultProperty(string $propertyName, string $enumClass): void
191159
{
192160
if (\PHP_VERSION_ID < 80100) {

0 commit comments

Comments
 (0)