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

Update method signatures in Client in order to respect its parent #507

Merged
merged 2 commits into from
Mar 15, 2019

Conversation

phansys
Copy link
Contributor

@phansys phansys commented Mar 14, 2019

Q A
Branch 2.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

@phansys
Copy link
Contributor Author

phansys commented Mar 14, 2019

BTW, is there any reason for not using __call() magic method instead of rewrite every parent method? https://3v4l.org/NXUcf

@B-Galati
Copy link
Collaborator

@phansys I have no idea ^^

@phansys
Copy link
Contributor Author

phansys commented Mar 14, 2019

It's fine for you if I implement __call(), removing all the proxied methods? I think it is more scalable since we can forget about the responsibility to keep track for the changes on Redis class.

@B-Galati
Copy link
Collaborator

B-Galati commented Mar 14, 2019

In fact I guess it's because Client class inherits from \Redis so __call would never be called. It is called only on not accessible method.

__call() is triggered when invoking inaccessible methods in an object context.

Perhaps all of these is done on purpose, not sure.

Perhaps @snc or @curry684 @Seldaek know?

@B-Galati
Copy link
Collaborator

@phansys I think it would not work but you can try and let me know.

Another option would require not to extend from \Redis and but that is not ok as it would be a major BC break.

@phansys
Copy link
Contributor Author

phansys commented Mar 14, 2019

You're right, I was omitting that the methods on Redis are accessible. I don't have a better idea then.

@B-Galati
Copy link
Collaborator

B-Galati commented Mar 14, 2019

Ok for me but I would like another feedback.

@curry684
Copy link
Collaborator

Yes, __call could not work since it is only invoked for unknown methods. The inheritance model is a compromise between being a drop in replacement and still being able to "hook" into all methods for logging purposes.

The fundamental problem with the approach has caused severe issues the past few months because the inheritance model breaks when function signatures do no match up exactly. We should actually, to achieve the same effect, generate the proxy at runtime based on the actual RTTI from the \Redis class exposed by the module, but that is quite.... 'tricky' to implement, especially given that PHP was apparently bugged in exposing that info right after the phpRedis 4 release.

@curry684
Copy link
Collaborator

#399 is the tracker issue for the proxy approach and may contain some useful insights.

@curry684
Copy link
Collaborator

Out of curiosity - what issue is this PR trying to solve?

Unless we're really fixing something I'm 👎 on this one as I've just benchmarked my suspicion that using the inline constants is actually about 10% faster than using __FUNCTION__.

@phansys
Copy link
Contributor Author

phansys commented Mar 15, 2019

The issue which triggered this PR is exposed in the build of #505:

Declaration of Snc\RedisBundle\Client\Phpredis\Client::append() should be compatible with Redis::append($key, $value)

The usage of __FUNCTION__ is just laziness on my side. Given your benchmark, I can change them by the proper method names.

@curry684
Copy link
Collaborator

Ah I see, in that case I'm fine with it like this 👍

@B-Galati
Copy link
Collaborator

@curry684 Thanks for your enlightenment!

What do you use to benchmark that case? I am really interested :-)

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.

3 participants