|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-05-26 14:26 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 14:00:01 2025 UTC |
Description: ------------ Static functions don't behave properly at all. They can be called from an object-context and provide no means to even confirm from within the function if it has been called from a static context or not. I understand that static methods should never have access to $this regardless of context, but unless the engine enforces a restriction on calling static functions from an object context this behavior is completely counter-intuitive and inconsistent. Not only does the engine not catch this, but the developer cannot either. Reproduce code: --------------- <?php error_reporting(E_ALL); class Staticexample { const a = 10; static function test() { var_dump(isset($this)); } } $b = new Staticexample(); Staticexample::test(); $b->test(); ?> Expected result: ---------------- bool(false) bool(true) Actual result: -------------- bool(false) bool(false)