Skip to content

Conversation

@pavog
Copy link
Contributor

@pavog pavog commented Jan 5, 2026

The checkIdParam() and checkNameParam() functions (in RequestUtil.php) check that id/name is present and valid in the request parameters. If not, exit() is called. Only if everything is correct is true returned.
This means that only true is returned anyway. So you don't need a return type or an if check when calling the functions.

This PR removes the redundant return true from the functions and the if checks. PHPDoc also makes it clear that the functions call exit() independently if the necessary parameters are not present or are invalid.

This PR helps me prepare for my next planned changes, such as adding a pagination.

@PierreSchwang
Copy link

PierreSchwang commented Jan 5, 2026

I'm unsure if it wouldn't be much cleaner to replace the two methods with something like getNameOrExit / getIdOrExit. Normally, if checking for the presence of a parameter, the parameter will be used later on anyway. Even if it's not used, the return value could simply be not assigned to a variable.
That's at least something I noticed when working on my PR - not sure if there are any exceptions that need to be kept in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants