Is there a magic method in PHP which is called each time another method is called? the __callStatic() and __call() magic methods seem to work only when the method doesn’t exist.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. What you’re asking for is called “advice” or aspect oriented programming. I believe there are some experimental extensions to allow this in PHP, but nothing you’d want to use in production.
What you can do, is create a wrapper, that delegates all calls via
__call. E.g.:See also: https://stackoverflow.com/questions/4738282/are-there-any-working-aspect-oriented-php-libraries