#32379 [NEW]: type hinting doesn't inforce encapsulation

From: Date: Sat, 19 Mar 2005 23:40:59 +0000
Subject: #32379 [NEW]: type hinting doesn't inforce encapsulation
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75544@lists.php.net to get a copy of this message
From: freebsd at dds dot nl Operating system: FreeBSD PHP version: 5.0.3 PHP Bug Type: Class/Object related Bug description: type hinting doesn't inforce encapsulation Description: ------------ Type hinting doesn't prevent you from calling functions of children that are not defined in the interface or (abstract) class. This mean you could call a function of object x, then create a new class (y) that doesn't implement this function, resulting in an error later on. Basicaly the principle of encapsulation (on class level) isn't enforced. Reproduce code: --------------- <?php interface X { public function fa(); } class Y implements X { public function fa() {} public function fb() { echo "no error / warning?"; } } function f(X $y) { $y->fb(); } f(new Y()); ?> Expected result: ---------------- An error (or at least a warning). Actual result: -------------- n/a -- Edit bug report at http://bugs.php.net/?id=32379&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32379&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32379&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32379&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32379&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32379&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32379&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32379&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32379&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32379&r=support Expected behavior: http://bugs.php.net/fix.php?id=32379&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32379&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32379&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32379&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32379&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32379&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32379&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32379&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32379&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32379&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32379&r=mysqlcfg

« previous php.bugs (#75544) next »