? PR-5.0-dev Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
8 Sep 2023

Summary of Changes

else after return creates additional complexity and doesn't have sense.

Testing Instructions

Apply patch.

Actual result BEFORE applying this Pull Request

Strange code.

Expected result AFTER applying this Pull Request

Nice code.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar joomla-cms-bot joomla-cms-bot - change - 8 Sep 2023
Category Administration com_banners com_categories com_content com_contenthistory com_fields com_finder com_installer com_joomlaupdate com_menus com_messages com_modules com_newsfeeds com_plugins com_redirect com_tags com_templates com_users
avatar Denitz Denitz - open - 8 Sep 2023
avatar Denitz Denitz - change - 8 Sep 2023
Status New Pending
avatar Denitz Denitz - change - 8 Sep 2023
Labels Added: PR-5.0-dev
avatar laoneo
laoneo - comment - 9 Sep 2023

Did you make this manually or with a tool?

avatar Denitz
Denitz - comment - 10 Sep 2023

The tool found the problems, next I manually updated the code.

avatar laoneo
laoneo - comment - 10 Sep 2023

Which tool?

avatar laoneo
laoneo - comment - 10 Sep 2023

I would rather add the tool to our CI pipeline instead of manually improving our code base.

avatar Denitz
Denitz - comment - 11 Sep 2023

It's Php Inspections (EA Extended) for PhpStorm plugin, not a case for CI here.

avatar laoneo
laoneo - comment - 12 Sep 2023

Can yo add the no useless else rule to the cs definition file.

avatar Denitz
Denitz - comment - 12 Sep 2023

Sorry, I am not a huge expert in cs files, all other changes applied.

avatar Denitz Denitz - change - 12 Sep 2023
Labels Added: ?
avatar laoneo
laoneo - comment - 12 Sep 2023

You don't need to be an expert, just add the rule to the file I posted.

avatar joomla-cms-bot joomla-cms-bot - change - 12 Sep 2023
Category Administration com_banners com_categories com_content com_contenthistory com_fields com_finder com_installer com_joomlaupdate com_menus com_messages com_modules com_newsfeeds com_plugins com_redirect com_tags com_templates com_users Administration com_banners com_categories com_content com_contenthistory com_fields com_finder com_installer com_joomlaupdate com_menus com_messages com_modules com_newsfeeds com_plugins com_redirect com_tags com_templates
avatar Denitz
Denitz - comment - 12 Sep 2023

@laoneo Done, please check 89ef08c

avatar laoneo
laoneo - comment - 12 Sep 2023

Nice, now the checker found 3 more occurrences. Can you fix them as well?

avatar laoneo
laoneo - comment - 12 Sep 2023

You are almost there

avatar HLeithner HLeithner - change - 12 Sep 2023
Title
5.0 Redundant `else` usage
[5.0] Redundant `else` usage
avatar HLeithner HLeithner - edited - 12 Sep 2023
avatar Denitz
Denitz - comment - 13 Sep 2023

@laoneo all done!

avatar laoneo
laoneo - comment - 13 Sep 2023

There is now a conflict. Beside that looks good to me. Didn't do a full review. But leave it up to @HLeithner if he wants to add it into 5.0.

avatar Denitz
Denitz - comment - 13 Sep 2023

@laoneo Thanks, conflict solved.

avatar HLeithner
HLeithner - comment - 13 Sep 2023

I need a second pair of eyes on this maybe @wilsonge ?

avatar HLeithner
HLeithner - comment - 17 Sep 2023

I'm merging this before beta2 so it'S a good improvement for readability. One thing that could be improved is to use early return also here

if (\is_scalar($value) || $value === null) {
return $value;
}
if (\is_array($value)) {
$value = new static($value);
} elseif (\is_object($value)) {
$value = new ObjectReadOnlyProxy($value);
}

thanks

avatar HLeithner HLeithner - change - 17 Sep 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-09-17 20:39:34
Closed_By HLeithner
avatar HLeithner HLeithner - close - 17 Sep 2023
avatar HLeithner HLeithner - merge - 17 Sep 2023

Add a Comment

Login with GitHub to post a comment