? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
11 Oct 2020

Summary of Changes

Return value type is not compatible with declared type in doc

Testing Instructions

Code review

avatar PhilETaylor PhilETaylor - open - 11 Oct 2020
avatar PhilETaylor PhilETaylor - change - 11 Oct 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Oct 2020
Category Modules Front End
avatar HLeithner
HLeithner - comment - 11 Oct 2020

void as return "value" doesn't exists and in case of php this is always NULL and that's actually expected in

maybe you can update the function that it return null please?

avatar PhilETaylor
PhilETaylor - comment - 11 Oct 2020

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

avatar PhilETaylor PhilETaylor - change - 11 Oct 2020
Labels Added: ?
avatar HLeithner
HLeithner - comment - 11 Oct 2020

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"

avatar PhilETaylor
PhilETaylor - comment - 11 Oct 2020

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

avatar PhilETaylor
PhilETaylor - comment - 11 Oct 2020

Updated.

avatar HLeithner
HLeithner - comment - 11 Oct 2020

Thanks

avatar HLeithner HLeithner - close - 11 Oct 2020
avatar HLeithner HLeithner - merge - 11 Oct 2020
avatar HLeithner HLeithner - change - 11 Oct 2020
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2020-10-11 19:06:36
Closed_By HLeithner

Add a Comment

Login with GitHub to post a comment