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

Code refacto #16

Open
andrelec1 opened this issue Apr 17, 2024 · 3 comments
Open

Code refacto #16

andrelec1 opened this issue Apr 17, 2024 · 3 comments

Comments

@andrelec1
Copy link

public function __call($method, $args)

This look like bad code for me...
But this is not the first time i see this in random php project.

So some one can explain why using this pattern ?

@tgeorgel
Copy link
Contributor

tgeorgel commented Apr 17, 2024

Are you talking about the __call() magic method or the inner switch statement ?

@andrelec1
Copy link
Author

I talk about the inner switch ....

The switch case statement is here to avoid the poor perf of call_user_func_array ...
But all this code can be replaced by this single line :
$this->req = $this->req->$method(...$args);

( Argument Unpacking have been implemented in php 5.6 ... lib require php 7.4 so... why not using it ? )

@tgeorgel
Copy link
Contributor

Well it is just a matter of habit, unpacking is indeed a nicest way to do so :)

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

No branches or pull requests

2 participants