User tests: Successful: Unsuccessful:
Return value type is not compatible with declared type in doc
Code review
Status | New | ⇒ | Pending |
Category | ⇒ | Modules Front End |
void as return "value" doesn't exists
Its a type not a value :)
Disagree, and so does phpStorm, and so does https://docs.phpdoc.org/latest/references/phpdoc/types.html ;-)
These types differ from the official PHP definition to be able to represent all kinds of data.
However... PHP 7.1 https://www.php.net/manual/en/migration71.new-features.php
A void return type has been introduced. Functions declared with void as their return type must either omit their return statement altogether, or use an empty return statement. NULL is not a valid return value for a void function.
However, you are right that this method could ALSO return null as well as void and string :-)
if $document->_links
was an empty array the method would return void
as a return type
Labels |
Added:
?
|
Sorry but that's makes it more confusing, that's more worse then having a wrong type.
And actually you can never use the void "type" as part of a union (https://wiki.php.net/rfc/union_types_v2) I know you you don't create a union type here but I think we should follow this rule here too.
I would suggest to add a return null;
in line 46 and remove the void "type"
haha sorry if I made it more confusing - I don't make the rules I just link to them... and you are right about Union Types... I like your quick fix and will apply that...
The joys of dealing with code from * @since 1.5
hahah
Updated.
Thanks
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-10-11 19:06:36 |
Closed_By | ⇒ | HLeithner |
void as return "value" doesn't exists and in case of php this is always NULL and that's actually expected in
joomla-cms/modules/mod_syndicate/mod_syndicate.php
Line 19 in 0587b4d
maybe you can update the function that it return null please?