forked from phly/PhlyRestfully
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to make psalm and phpstan pass
- Loading branch information
Showing
19 changed files
with
590 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
parameters: | ||
ignoreErrors: | ||
# Type-o in ZF2's docblock | ||
- '#Call to method getTypeString\(\) on an unknown class Zend\\Http\\Header\\Accept\\FieldValuePArt\\AcceptFieldValuePart\.#' | ||
# I think in this case an array won't be returned | ||
- '#Array \(array<Zend\\Stdlib\\CallbackHandler>\) does not accept array\|Zend\\Stdlib\\CallbackHandler\.#' | ||
# These can probably be fixed if static type-hints are ever added | ||
- '#Casting to .+ something that.s already .+\.#' | ||
# This is more of a defensive thing, docblocks only allow specific object type and string | ||
- '#Call to function is_object\(\) will always evaluate to false\.#' | ||
# Internal code never sets $identifierName to false, but does have a setter with no restrictions | ||
- '#Strict comparison using !== between false and string will always evaluate to true\.#' | ||
- '#Strict comparison using === between false and string will always evaluate to false\.#' | ||
# This is a version branch, detected earlier | ||
- '#Parameter \#2 \$listener of method Zend\\EventManager\\SharedEventManagerInterface::detach\(\) expects Zend\\Stdlib\\CallbackHandler, string given\.#' | ||
# ZF2 docblocks aren't correct, does accept an array | ||
- '#Parameter \#1 \$nameOrModel of method Zend\\View\\Renderer\\JsonRenderer::render\(\) expects string\|Zend\\View\\Model\\ModelInterface, array given\.#' | ||
# There's a check earlier that checks if there's an ApiProblem (which checks if apiProblem is null), so won't be null here | ||
- '#Parameter \#1 \$problem of method PhlyRestfully\\View\\RestfulJsonStrategy::getStatusCodeFromApiProblem\(\) expects PhlyRestfully\\ApiProblem, PhlyRestfully\\ApiProblem\|null given\.#' | ||
# Other issues | ||
- '#Parameter \#1 \$collection of class PhlyRestfully\\HalCollection constructor expects array\|Traversable, array\|object given\.#' | ||
- '#Call to function count\(\) with argument type array\|Traversable will always result in number 1\.#' | ||
- '#Parameter \#1 \$hydrator of method PhlyRestfully\\Plugin\\HalLinks::setDefaultHydrator\(\) expects Zend\\Hydrator\\HydratorInterface, object given\.#' | ||
- '#Parameter \#1 \$collection of class PhlyRestfully\\HalCollection constructor expects array\|Traversable, object given\.#' | ||
- '#Cannot call method setItemCountPerPage\(\) on array\|Traversable\.#' | ||
- '#Cannot call method setCurrentPageNumber\(\) on array\|Traversable\.#' | ||
- '#Parameter \#1 \$matches of method PhlyRestfully\\ResourceInterface::setRouteMatch\(\) expects Zend\\Mvc\\Router\\RouteMatch, Zend\\Mvc\\Router\\RouteMatch\|null given\.#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
totallyTyped="false" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config ./vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="./src" /> | ||
</projectFiles> | ||
|
||
<issueHandlers> | ||
<PropertyNotSetInConstructor errorLevel="info" /> | ||
|
||
<InvalidCatch> | ||
<errorLevel type="info"> | ||
<!-- All of the Zend\Uri exceptions extend InvalidArgumentException and implement this interface, so | ||
this is technically allowed --> | ||
<file name="src/Link.php" /> | ||
</errorLevel> | ||
</InvalidCatch> | ||
|
||
<ReservedWord> | ||
<errorLevel type="info"> | ||
<!-- "resource" is a "soft" reserved word as of PHP 7.0: https://secure.php.net/manual/en/reserved.other-reserved-words.php --> | ||
<file name="src/Resource.php" /> | ||
<file name="src/Factory/ResourceControllerFactory.php" /> | ||
</errorLevel> | ||
</ReservedWord> | ||
|
||
<InvalidArgument> | ||
<errorLevel type="info"> | ||
<!-- There is a version check here to use the opposite parameter order depending on which version of | ||
the SharedEventManager is being used --> | ||
<file name="src/Listener/ResourceParametersListener.php" /> | ||
<!-- ZF2's View\Renderer\JsonRenderer has incorrect docblock for this method --> | ||
<file name="src/View/RestfulJsonRenderer.php" /> | ||
</errorLevel> | ||
</InvalidArgument> | ||
|
||
<InvalidPropertyAssignmentValue> | ||
<errorLevel type="info"> | ||
<file name="src/Listener/ResourceParametersListener.php" /> | ||
</errorLevel> | ||
</InvalidPropertyAssignmentValue> | ||
|
||
<UndefinedClass> | ||
<errorLevel type="info"> | ||
<!-- type-o in Zend\Http\Header\AcceptAbstract docblock for match method --> | ||
<file name="src/Listener/ApiProblemListener.php" /> | ||
</errorLevel> | ||
</UndefinedClass> | ||
|
||
<TypeCoercion> | ||
<errorLevel type="info"> | ||
<!-- This one doesn't make any sense to me: | ||
$this->collection expects 'array<mixed, mixed>|Traversable|Zend\Paginator\Paginator', parent type 'array<mixed, mixed>|Traversable|Zend\Paginator\Paginator' provided --> | ||
<file name="src/HalCollection.php" /> | ||
<!-- This comes from a config definition, could inline type it, but maybe hides an error --> | ||
<file name="src/Module.php" /> | ||
<!-- object most likely gets turned into a HalCollection, but isn't guaranteed in the code --> | ||
<file name="src/Plugin/HalLinks.php" /> | ||
</errorLevel> | ||
</TypeCoercion> | ||
|
||
<RedundantCondition> | ||
<errorLevel type="info"> | ||
<!-- Can't type-hint this (union type), so this check is done to prevent invalid type coming in --> | ||
<file name="src/HalResource.php" /> | ||
<file name="src/Plugin/HalLinks.php" /> | ||
</errorLevel> | ||
</RedundantCondition> | ||
|
||
<PossiblyNullArgument> | ||
<errorLevel type="info"> | ||
<!-- this has a check before it that would return false if apiProblem is null --> | ||
<file name="src/View/RestfulJsonStrategy.php" /> | ||
</errorLevel> | ||
</PossiblyNullArgument> | ||
|
||
<MissingConstructor> | ||
<errorLevel type="info"> | ||
<file name="src/View/RestfulJsonRenderer.php" /> | ||
</errorLevel> | ||
</MissingConstructor> | ||
|
||
<PossiblyInvalidMethodCall> | ||
<errorLevel type="info"> | ||
<file name="src/Plugin/HalLinks.php" /> | ||
</errorLevel> | ||
</PossiblyInvalidMethodCall> | ||
|
||
<PossiblyUndefinedMethod> | ||
<errorLevel type="info"> | ||
<file name="src/Plugin/HalLinks.php" /> | ||
</errorLevel> | ||
</PossiblyUndefinedMethod> | ||
|
||
<PossiblyInvalidArgument> | ||
<errorLevel type="info"> | ||
<file name="src/Plugin/HalLinks.php" /> | ||
</errorLevel> | ||
</PossiblyInvalidArgument> | ||
|
||
<MoreSpecificImplementedParamType errorLevel="info" /> | ||
<ImplementedReturnTypeMismatch errorLevel="info" /> | ||
<!-- These are all defensive checks since the parameters aren't php type-hinted --> | ||
<RedundantConditionGivenDocblockType errorLevel="info" /> | ||
<DocblockTypeContradiction errorLevel="info" /> | ||
</issueHandlers> | ||
</psalm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.