Skip to content
Permalink
Browse files

Merge pull request #72 from ergebnis/fix/inline

Fix: Inline method
  • Loading branch information
localheinz committed Mar 23, 2020
2 parents f4b5392 + 2295448 commit e5a17021ab8b8cae710cb10827e1567c304b9664
Showing with 19 additions and 36 deletions.
  1. +3 −8 phpstan-baseline.neon
  2. +9 −16 psalm-baseline.xml
  3. +7 −12 src/EntityDef.php
@@ -1,12 +1,12 @@
parameters:
ignoreErrors:
-
message: "#^Method Ergebnis\\\\FactoryBot\\\\EntityDef\\:\\:getFieldDefinitions\\(\\) has no return typehint specified\\.$#"
message: "#^Language construct isset\\(\\) should not be used\\.$#"
count: 1
path: src/EntityDef.php

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

@@ -21,12 +21,7 @@ parameters:
path: src/EntityDef.php

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

-
message: "#^Method Ergebnis\\\\FactoryBot\\\\EntityDef\\:\\:ensureInvokable\\(\\) has parameter \\$fieldDefinition with no typehint specified\\.$#"
message: "#^Parameter \\#1 \\$object of function method_exists expects object\\|string, callable given\\.$#"
count: 1
path: src/EntityDef.php

@@ -1,28 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.9.5@0cfe565d0afbcd31eadcc281b9017b5692911661">
<files psalm-version="3.10.1@eeed5ecccc10131397f0eb7ee6da810c0be3a7fc">
<file src="src/EntityDef.php">
<InvalidArgument occurrences="1">
<code>$fieldDefinition</code>
</InvalidArgument>
<MissingClosureReturnType occurrences="4">
<code>static function () use ($defaultFieldValue) {</code>
<code>static function () {</code>
<code>static function () use ($fieldDefinition) {</code>
<code>static function () use ($fieldDefinition) {</code>
</MissingClosureReturnType>
<MissingParamType occurrences="2">
<code>$fieldDefinition</code>
<MissingParamType occurrences="1">
<code>$fieldDefinition</code>
</MissingParamType>
<MissingPropertyType occurrences="2">
<code>$fieldDefinitions</code>
<code>$configuration</code>
</MissingPropertyType>
<MissingReturnType occurrences="3">
<MissingReturnType occurrences="2">
<code>getFieldDefinitions</code>
<code>normalizeFieldDefinition</code>
<code>ensureInvokable</code>
</MissingReturnType>
<MixedArgument occurrences="1">
<code>$fieldDefinition</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="2">
<code>$fieldName</code>
<code>$fieldName</code>
@@ -31,15 +29,15 @@
<code>$fieldDefinition</code>
<code>$defaultFieldValue</code>
</MixedAssignment>
<MixedFunctionCall occurrences="1">
<code>\call_user_func_array($fieldDefinition, \func_get_args())</code>
</MixedFunctionCall>
<MixedInferredReturnType occurrences="1">
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement occurrences="1">
<code>$this-&gt;configuration</code>
</MixedReturnStatement>
<TypeDoesNotContainType occurrences="1">
<code>\method_exists($fieldDefinition, '__invoke')</code>
</TypeDoesNotContainType>
</file>
<file src="src/FieldDef.php">
<MissingClosureReturnType occurrences="3">
@@ -132,11 +130,6 @@
<code>getAssociationMapping</code>
</MixedMethodCall>
</file>
<file src="test/Fixture/FixtureFactory/Entity/Artist.php">
<MissingConstructor occurrences="1">
<code>$id</code>
</MissingConstructor>
</file>
<file src="test/Fixture/FixtureFactory/Entity/Badge.php">
<MissingConstructor occurrences="1">
<code>$id</code>
@@ -119,22 +119,17 @@ public function getConfiguration()
private function normalizeFieldDefinition($fieldDefinition)
{
if (\is_callable($fieldDefinition)) {
return $this->ensureInvokable($fieldDefinition);
}

return static function () use ($fieldDefinition) {
return $fieldDefinition;
};
}
if (\method_exists($fieldDefinition, '__invoke')) {
return $fieldDefinition;
}

private function ensureInvokable($fieldDefinition)
{
if (\method_exists($fieldDefinition, '__invoke')) {
return $fieldDefinition;
return static function () use ($fieldDefinition) {
return \call_user_func_array($fieldDefinition, \func_get_args());
};
}

return static function () use ($fieldDefinition) {
return \call_user_func_array($fieldDefinition, \func_get_args());
return $fieldDefinition;
};
}
}

0 comments on commit e5a1702

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