| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2015-09-23 02:57 UTC] laruence@php.net
 
-Status: Open
+Status: Not a bug
  [2015-09-23 02:57 UTC] laruence@php.net
  [2015-09-25 11:37 UTC] mike@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 02:00:01 2025 UTC | 
Description: ------------ A class that uses a trait that implements __call, and then from an instance method calls a static method that does not exist, ends up calling __call in trait rather than __callStatic. Test script: --------------- trait TestTrait { function __call($name, $args) { echo "instance method '$name' called.\n"; } static function __callStatic($name, $args) { echo "static method '$name' called.\n"; } } class TestClass { use TestTrait; function test() { // this ends up calling __call method in TestTrait ?!?!?! WTF? TestClass::magic_static(); } static function staticTest() { // this calls __callStatic as expected TestClass::magic_static(); } } class TestClass2 { function __call($name, $args) { echo "instance method '$name' called.\n"; } static function __callStatic($name, $args) { echo "static method '$name' called.\n"; } function test() { // this calls __callStatic as expected TestClass::magic_static(); } static function staticTest() { // this calls __callStatic as expected TestClass::magic_static(); } } $t = new TestClass(); $t->test(); $t->staticTest(); $t = new TestClass2(); $t->test(); $t->staticTest(); Expected result: ---------------- See inline comments in sample code Actual result: -------------- See inline comments in sample code