Thanks to visit codestin.com
Credit goes to github.com

Skip to content

URLHelper::get_params() return value#2439

Merged
jarednova merged 10 commits into
2.xfrom
bugfix/url-helper-param-return-value
Apr 17, 2021
Merged

URLHelper::get_params() return value#2439
jarednova merged 10 commits into
2.xfrom
bugfix/url-helper-param-return-value

Conversation

@acobster

Copy link
Copy Markdown
Contributor

PHPStan considers implicit null returns a bug:

 ------ ---------------------------------------------------------------------------------------------------                                                                                                        
  Line   URLHelper.php                                                                                                                                                                                             
 ------ ---------------------------------------------------------------------------------------------------                                                                                                        
  533    Method Timber\URLHelper::get_params() should return array|string but return statement is missing.                                                                                                         
 ------ --------------------------------------------------------------------------------------------------- 

The fix is to always explicitly return, as well as declare the right @return type. I did some cleanup for conciseness, too.

No usage changes or other considerations I'm aware of. Tests still pass.

fix return type annotation per PHPStan error.
Also add @example tag and clean up the code.
@acobster acobster requested review from gchtr and jarednova April 13, 2021 21:44
@acobster acobster self-assigned this Apr 13, 2021
@jarednova jarednova added the 2.0 label Apr 14, 2021
@jarednova

Copy link
Copy Markdown
Member

Much cleaner! Just changed false => null in the function description to match

jarednova
jarednova previously approved these changes Apr 16, 2021
jarednova
jarednova previously approved these changes Apr 16, 2021
@acobster

Copy link
Copy Markdown
Contributor Author

whoops! Yeah I had thought to make it false to make it a little more consistent with other core functions, but null is more appropriate if you're thinking of it as an array. Still on the fence about this though. Thoughts?

@jarednova

Copy link
Copy Markdown
Member

Oh roger, that I thought you had settled on null based on the code. I think this is one of those 51/49 situations, but false would seem to be the more expected value returned (you could imagine using get_params() in conditionals — and I'm never confident about how null behaves in those situations)

@acobster

Copy link
Copy Markdown
Contributor Author

OK, I'll change it to false then. Bringing it up because it's technically a breaking change, although it'll only break code that's checking null === URLHelper::get_params(...) which seems pretty unlikely and edge-casey.

Coby Tamayo added 3 commits April 16, 2021 16:13
…ber/timber into bugfix/url-helper-param-return-value
Corregir un error de ortografía también
@acobster

Copy link
Copy Markdown
Contributor Author

OK @jarednova - done. If you could give another once-over that'd be great.

@jarednova jarednova merged commit 193b1df into 2.x Apr 17, 2021
@jarednova

Copy link
Copy Markdown
Member

Once-overed! Looks good from here

@jarednova jarednova deleted the bugfix/url-helper-param-return-value branch April 17, 2021 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants