Skip to content

Commit

Permalink
Merge pull request #83 from ergebnis/fix/inline
Browse files Browse the repository at this point in the history
Fix: Inline method
  • Loading branch information
localheinz authored Mar 26, 2020
2 parents c2733dc + 087ca8e commit 4190aed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
8 changes: 4 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ parameters:
path: src/FixtureFactory.php

-
message: "#^Method Ergebnis\\\\FactoryBot\\\\FixtureFactory\\:\\:getList\\(\\) has no return typehint specified\\.$#"
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: src/FixtureFactory.php

-
message: "#^Method Ergebnis\\\\FactoryBot\\\\FixtureFactory\\:\\:getAsSingleton\\(\\) has no return typehint specified\\.$#"
message: "#^Language construct empty\\(\\) should not be used\\.$#"
count: 1
path: src/FixtureFactory.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
message: "#^Method Ergebnis\\\\FactoryBot\\\\FixtureFactory\\:\\:getList\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/FixtureFactory.php

-
message: "#^Language construct empty\\(\\) should not be used\\.$#"
message: "#^Method Ergebnis\\\\FactoryBot\\\\FixtureFactory\\:\\:getAsSingleton\\(\\) has no return typehint specified\\.$#"
count: 1
path: src/FixtureFactory.php

Expand Down
6 changes: 1 addition & 5 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
<code>getFieldDefinitions</code>
<code>normalizeFieldDefinition</code>
</MissingReturnType>
<MixedArgumentTypeCoercion occurrences="2">
<code>$fieldName</code>
<code>$fieldName</code>
</MixedArgumentTypeCoercion>
<MixedAssignment occurrences="2">
<code>$fieldDefinition</code>
<code>$defaultFieldValue</code>
Expand Down Expand Up @@ -80,11 +76,11 @@
<code>$name</code>
<code>$name</code>
<code>$name</code>
<code>$entityDefinition-&gt;getFieldDefinitions()</code>
<code>$fieldName</code>
<code>$name</code>
<code>$name</code>
<code>$name</code>
<code>$entityDefinition-&gt;getFieldDefinitions()</code>
<code>$fieldName</code>
<code>$entity</code>
<code>$fieldName</code>
Expand Down
27 changes: 11 additions & 16 deletions src/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,17 @@ public function get($name, array $fieldOverrides = [])

$configuration = $entityDefinition->getConfiguration();

$this->checkFieldOverrides($entityDefinition, $fieldOverrides);
$extraFields = \array_diff(\array_keys($fieldOverrides), \array_keys($entityDefinition->getFieldDefinitions()));

\natsort($extraFields);

if (!empty($extraFields)) {
throw new \Exception(\sprintf(
'Field(s) not in %s: \'%s\'',
$entityDefinition->getClassName(),
\implode("', '", $extraFields)
));
}

/** @var ORM\Mapping\ClassMetadata $classMetadata */
$classMetadata = $entityDefinition->getClassMetadata();
Expand Down Expand Up @@ -249,21 +259,6 @@ public function definitions(): array
return $this->entityDefinitions;
}

private function checkFieldOverrides(EntityDef $entityDefinition, array $fieldOverrides): void
{
$extraFields = \array_diff(\array_keys($fieldOverrides), \array_keys($entityDefinition->getFieldDefinitions()));

\natsort($extraFields);

if (!empty($extraFields)) {
throw new \Exception(\sprintf(
'Field(s) not in %s: \'%s\'',
$entityDefinition->getClassName(),
\implode("', '", $extraFields)
));
}
}

private function setField($entity, EntityDef $entityDefinition, $fieldName, $fieldValue): void
{
$classMetadata = $entityDefinition->getClassMetadata();
Expand Down

0 comments on commit 4190aed

Please sign in to comment.