Skip to content

Commit 10bf4ee

Browse files
author
Enno Woortmann
committed
cleanup
1 parent deb6df7 commit 10bf4ee

3 files changed

Lines changed: 16 additions & 31 deletions

File tree

.claude/settings.local.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
"Bash(cat:*)",
1919
"Bash(where gh:*)",
2020
"Bash(composer update:*)",
21-
"Bash(./vendor/bin/rector process:*)",
21+
"Bash(./vendor/bin/rector:*)",
2222
"Bash(git checkout:*)",
2323
"Bash(git add:*)",
24-
"Bash(./vendor/bin/rector --version 2>&1 | grep Rector)",
25-
"Bash(./vendor/bin/phpcs --standard=PSR12 --report=summary src/ 2>&1)",
26-
"Bash(./vendor/bin/phpcs --standard=PSR12 --report=source src/)",
27-
"Bash(./vendor/bin/phpcs --standard=PSR12 --report=json src/)",
2824
"Bash(python3 -c \":*)",
29-
"Bash(./vendor/bin/phpcbf --standard=phpcs.xml src/)",
30-
"Bash(./vendor/bin/phpcs --standard=phpcs.xml --report=full src/)",
31-
"Bash(./vendor/bin/phpcs --standard=phpcs.xml src/)",
32-
"Bash(./vendor/bin/phpcs --standard=phpcs.xml --report=summary src/)",
25+
"Bash(./vendor/bin/phpcbf:*)",
26+
"Bash(./vendor/bin/phpcs:*)",
3327
"Bash(git merge:*)",
34-
"Bash(gh api:*)"
28+
"Bash(gh api:*)",
29+
"Bash(git restore:*)",
30+
"Bash(git stash:*)",
31+
"Bash(composer show:*)",
32+
"Bash(php -r \":*)",
33+
"Bash(gh pr:*)",
34+
"Bash(xargs wc:*)"
3535
]
3636
}
3737
}

src/SchemaProcessor/PostProcessor/Internal/CompositionRequiredPromotionPostProcessor.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use PHPModelGenerator\Model\Validator\AbstractComposedPropertyValidator;
1212
use PHPModelGenerator\Model\Validator\ComposedPropertyValidator;
1313
use PHPModelGenerator\Model\Validator\ConditionalPropertyValidator;
14-
use PHPModelGenerator\Model\Validator\PropertyValidatorInterface;
1514
use PHPModelGenerator\PropertyProcessor\ComposedValue\AllOfProcessor;
1615
use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor;
1716

@@ -114,20 +113,12 @@ private function collectFromComposed(ComposedPropertyValidator $validator): arra
114113
*/
115114
private function promoteProperty(Schema $schema, string $propertyName): void
116115
{
117-
$property = null;
118-
119-
foreach ($schema->getProperties() as $candidate) {
120-
if ($candidate->getName() === $propertyName) {
121-
$property = $candidate;
122-
break;
123-
}
124-
}
125-
126-
if ($property === null) {
127-
return;
128-
}
116+
$property = array_find(
117+
$schema->getProperties(),
118+
static fn (PropertyInterface $property): bool => $property->getName() === $propertyName,
119+
);
129120

130-
if ($property->isRequired()) {
121+
if (!$property || $property->isRequired()) {
131122
return;
132123
}
133124

tests/ComposedValue/ComposedRequiredPromotionTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ public function testAllOfPromotedPropertyAbsentUnderImplicitNullCollectsOnlyComp
125125
$className = $this->generateClassFromFile(
126126
'AllOfRequiredInAnyBranch.json',
127127
(new GeneratorConfiguration())->setCollectErrors(true),
128-
false,
129-
true,
130128
);
131129

132130
try {
@@ -371,8 +369,6 @@ public function testOneOfPromotedPropertyAbsentUnderImplicitNullCollectsOnlyComp
371369
$className = $this->generateClassFromFile(
372370
'OneOfRequiredInAllBranches.json',
373371
(new GeneratorConfiguration())->setCollectErrors(true),
374-
false,
375-
true,
376372
);
377373

378374
try {
@@ -491,7 +487,7 @@ public function testPromotionSuppressesNullUnderImplicitNull(): void
491487
{
492488
// With implicitNull=true every non-required property would normally be nullable.
493489
// Promotion must override that and force non-nullable.
494-
$className = $this->generateClassFromFile('AnyOfRequiredInAllBranches.json', null, false, true);
490+
$className = $this->generateClassFromFile('AnyOfRequiredInAllBranches.json');
495491

496492
$this->assertNonNullableStringProperty($className, 'name');
497493
}
@@ -505,8 +501,6 @@ public function testPromotedPropertyAbsentUnderImplicitNullCollectsOnlyCompositi
505501
$className = $this->generateClassFromFile(
506502
'AnyOfRequiredInAllBranches.json',
507503
(new GeneratorConfiguration())->setCollectErrors(true),
508-
false,
509-
true,
510504
);
511505

512506
try {

0 commit comments

Comments
 (0)