Skip to content

Commit

Permalink
Document callable as possible
Browse files Browse the repository at this point in the history
Custom string functions can either be a class string or a callable
returning the function.
  • Loading branch information
greg0ire committed May 23, 2022
1 parent 8f77012 commit 1455c9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function addCustomStringFunction($name, $className)
* @param string $name
*
* @return string|null
* @psalm-return ?class-string
* @psalm-return ?class-string|callable
*/
public function getCustomStringFunction($name)
{
Expand All @@ -625,8 +625,7 @@ public function getCustomStringFunction($name)
*
* Any previously added string functions are discarded.
*
* @psalm-param array<string, class-string> $functions The map of custom
* DQL string functions.
* @psalm-param array<string, class-string|callable> $functions The map of custom DQL string functions.
*
* @return void
*/
Expand Down
9 changes: 5 additions & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2061,8 +2061,7 @@
<ArgumentTypeCoercion occurrences="1">
<code>$stringPattern</code>
</ArgumentTypeCoercion>
<DocblockTypeContradiction occurrences="3">
<code>call_user_func($functionClass, $functionName)</code>
<DocblockTypeContradiction occurrences="2">
<code>call_user_func($functionClass, $functionName)</code>
<code>call_user_func($functionClass, $functionName)</code>
</DocblockTypeContradiction>
Expand Down Expand Up @@ -2117,6 +2116,9 @@
<code>$this-&gt;lexer-&gt;token['value']</code>
<code>$this-&gt;lexer-&gt;token['value']</code>
</InvalidScalarArgument>
<InvalidStringClass occurrences="1">
<code>new $functionClass($functionName)</code>
</InvalidStringClass>
<LessSpecificReturnStatement occurrences="4">
<code>$function</code>
<code>$function</code>
Expand Down Expand Up @@ -2250,11 +2252,10 @@
<PossiblyUndefinedVariable occurrences="1">
<code>$args</code>
</PossiblyUndefinedVariable>
<RedundantConditionGivenDocblockType occurrences="4">
<RedundantConditionGivenDocblockType occurrences="3">
<code>$AST instanceof AST\SelectStatement</code>
<code>is_string($functionClass)</code>
<code>is_string($functionClass)</code>
<code>is_string($functionClass)</code>
</RedundantConditionGivenDocblockType>
<UnsafeInstantiation occurrences="3">
<code>new $funcClass($funcNameLower)</code>
Expand Down

0 comments on commit 1455c9f

Please sign in to comment.