PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Gonzalo Ayuso's Blog: Strange behavior in PHP with method visibility

Note: This article was originally published at PHPDeveloper on 29 May 2012.
PHPDeveloper

In his recent post Gonzalo Ayuso shares some "strange behavior" he found with method visibility in his recent development:

Normally I feel very comfortable with PHP, but not all is good. There's some things I don't like. One is the lack of real annotations and another one is this rare behaviour with visibility within the OO. Let me explain this a little bit.

The problem came up as a part of a recent refactor where a protected method, when called from an object injected into another class, threw an "access" error that it was called from the wrong context. He reported it as a bug but was reminded of how PHP handles exposure - on the class level, not the instance of a class level.