Bug #67620 [Opn]: is_callable and self

From: Date: Fri, 15 Jan 2016 13:08:29 +0000
Subject: Bug #67620 [Opn]: is_callable and self
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-198678@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67620&edit=1

 ID:                 67620
 Updated by:         danack@php.net
 Reported by:        remyfox at hotmail dot com
 Summary:            is_callable and self
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   windows 7
 PHP Version:        5.4Git-2014-07-15 (Git)
-Assigned To:        
+Assigned To:        danack
 Block user comment: N
 Private report:     N

 New Comment:

Assigning to myself. This will require an RFC to change.

https://wiki.php.net/rfc/consistent_callables


Previous Comments:
------------------------------------------------------------------------
[2014-07-15 08:35:10] remyfox at hotmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=67620&edit=1


Thread (3 messages)

« previous php.bugs (#198678) next »