This project reproduces an error we're seeing in a project related to Psalm.
We are using WordPress which has a class WP_REST_Response
. This class extends from WP_HTTP_Response
.
In this project the class Collins\CustomResponse
extends WP_REST_Response
.
The assumption is that all non-private methods on WP_REST_Response
and WP_HTTP_Response
should be visiible/available on CustomResponse
.
However, Psalm does not believe that to be the case:
/**
* ::get_status() is defined by WP_HTTP_Response
*
* Psalm error is UndefinedMethod
*/
$status = $response->get_status();
This produces an UndefinedMethod
error when running psalm
.
UndefinedMethod
Method Collins\CustomResponse::get_status does not exist
For convenience the stubs used for these classes have been extracted and placed in ./sample-stubs.php
:
Psalm in this project is not finding errors that it should be:
- The
@return
ofCustomResponse::custom_method
is declared as@return string
but returns anint
of1
. No error. - The
@param boolean $arg
is declared oncustom_method
but it is being used without an$arg
param and Psalm doesn't care.