Bug #67620 [NEW]: is_callable and self

From: Date: Tue, 15 Jul 2014 08:35:11 +0000
Subject: Bug #67620 [NEW]: is_callable and self
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186617@lists.php.net to get a copy of this message
From:             remyfox at hotmail dot com
Operating system: windows 7
PHP version:      5.4Git-2014-07-15 (Git)
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:is_callable and self

Description:
------------
PHP 5.4.7

When "self" is provided to is_callable, while inside a class that
doesn't contain the method nor has a parent with the method, it will
behave as $this.

Subsequent calling of the method which had been falsely declared
callable, will result in 

Fatal error: Call to undefined method A::y() in *__FILE__* on line 5

Test script:
---------------
<?php
	class A {
		public function x() {
			if (is_callable(array($this, "y"))) $this::y();
			if (is_callable(array("self", "y"))) self::y();
		}
	}
	
	class B extends A {
		public function y() {}
	}
	
	(new B())->x();
?>

Expected result:
----------------
Self should behalve like __CLASS__ in the example above and the fatal
error should be avoided.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=67620&edit=1
-- 



Thread (3 messages)

« previous php.bugs (#186617) next »