Skip to content
Permalink
Browse files

Merge pull request #56 from ergebnis/fix/type

Fix: Remove unnecessary constructor parameter and field
  • Loading branch information
localheinz committed Mar 16, 2020
2 parents 66a9f9b + 5a04efd commit e4ac3dff8a6a26b9fc2894fe1208d229e8e96cc5
Showing with 8 additions and 27 deletions.
  1. +0 −10 phpstan-baseline.neon
  2. +5 −10 psalm-baseline.xml
  3. +3 −6 src/EntityDef.php
  4. +0 −1 src/FixtureFactory.php
@@ -1,15 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Property Ergebnis\\\\FactoryBot\\\\EntityDef\\:\\:\\$entityType has no typehint specified\\.$#"
count: 1
path: src/EntityDef.php

-
message: "#^Method Ergebnis\\\\FactoryBot\\\\EntityDef\\:\\:__construct\\(\\) has parameter \\$type with no typehint specified\\.$#"
count: 1
path: src/EntityDef.php

-
message: "#^Method Ergebnis\\\\FactoryBot\\\\EntityDef\\:\\:getFieldDefs\\(\\) has no return typehint specified\\.$#"
count: 1
@@ -7,13 +7,11 @@
<code>static function () use ($def) {</code>
<code>static function () use ($f) {</code>
</MissingClosureReturnType>
<MissingParamType occurrences="3">
<code>$type</code>
<MissingParamType occurrences="2">
<code>$def</code>
<code>$f</code>
</MissingParamType>
<MissingPropertyType occurrences="3">
<code>$entityType</code>
<MissingPropertyType occurrences="2">
<code>$fieldDefs</code>
<code>$config</code>
</MissingPropertyType>
@@ -22,8 +20,7 @@
<code>normalizeFieldDef</code>
<code>ensureInvokable</code>
</MissingReturnType>
<MixedArgument occurrences="2">
<code>$this-&gt;entityType</code>
<MixedArgument occurrences="1">
<code>$f</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="2">
@@ -37,12 +34,10 @@
<MixedFunctionCall occurrences="1">
<code>\call_user_func_array($f, \func_get_args())</code>
</MixedFunctionCall>
<MixedInferredReturnType occurrences="2">
<code>string</code>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="2">
<code>$this-&gt;entityType</code>
<MixedReturnStatement occurrences="1">
<code>$this-&gt;config</code>
</MixedReturnStatement>
</file>
@@ -25,16 +25,13 @@ final class EntityDef
*/
private $metadata;

private $entityType;

private $fieldDefs;

private $config;

public function __construct(ORM\Mapping\ClassMetadata $metadata, $type, array $fieldDefs, array $config)
public function __construct(ORM\Mapping\ClassMetadata $metadata, array $fieldDefs, array $config)
{
$this->metadata = $metadata;
$this->entityType = $type;
$this->fieldDefs = [];
$this->config = $config;

@@ -49,7 +46,7 @@ public function __construct(ORM\Mapping\ClassMetadata $metadata, $type, array $f
*/
public function getEntityType()
{
return $this->entityType;
return $this->metadata->getName();
}

/**
@@ -86,7 +83,7 @@ private function readFieldDefs(array $params): void
if (!$this->metadata->hasField($key) && !$this->metadata->hasAssociation($key)) {
throw new \Exception(\sprintf(
'No such field in %s: %s',
$this->entityType,
$this->getEntityType(),
$key
));
}
@@ -239,7 +239,6 @@ public function defineEntity($name, array $fieldDefs = [], array $config = [])

$this->entityDefs[$name] = new EntityDef(
$metadata,
$type,
$fieldDefs,
$config
);

0 comments on commit e4ac3df

Please sign in to comment.
You can’t perform that action at this time.