Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove unnecessary is_countable() check in getMethodParams() #9206

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

datamweb
Copy link
Contributor

@datamweb datamweb commented Oct 1, 2024

Description
This PR optimizes the getMethodParams method by removing the unnecessary is_countable() check.

The preg_match_all() function guarantees that $matches will always be an array.
If no matches are found, $matches[0] will be an empty array, and the function will return 0.

See : https://github.com/codeigniter4/CodeIgniter4/actions/runs/11033764630/job/30645688529?pr=9202

 ------ --------------------------------------------------------------------- 
  Line   system/Router/RouteCollection.php                                    
 ------ --------------------------------------------------------------------- 
  1614   Call to function is_countable() with array<int, string> will always  
         evaluate to true.                                                    
         🪪  function.alreadyNarrowedType      

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@datamweb
Copy link
Contributor Author

datamweb commented Oct 1, 2024

@samsonasik Does Rector have any specific rules or guidelines regarding this matter?

@samsonasik
Copy link
Member

@datamweb not yet afaik

@kenjis kenjis added the refactor Pull requests that refactor code label Oct 3, 2024
@kenjis kenjis merged commit ba8e97a into codeigniter4:develop Oct 3, 2024
40 of 41 checks passed
@datamweb datamweb deleted the refctor-RouteCollection branch October 3, 2024 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants