-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend deprecation notices to is_callable($foo) and callable $foo
Implements https://wiki.php.net/rfc/partially-supported-callables-expand-deprecation-notices so that uses of "self" and "parent" in is_callable() and callable type constraints now raise a deprecation notice, independent of the one raised when and if the callable is actually invoked. A new flag is added to the existing check_flags parameter of zend_is_callable / zend_is_callable_ex, for use in internal calls that would otherwise repeat the notice multiple times. In particular, arguments to internal function calls are checked first based on arginfo, and then again during ZPP, so the former suppresses the deprecation notice. Some existing tests which raised this deprecation have been updated to avoid the syntax, but the existing version retained for maximum regression coverage until it is made an error. With thanks to Juliette Reinders Folmer for the RFC and initial investigation. Closes GH-8823.
- Loading branch information
Showing
22 changed files
with
409 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
Bug #48899 (is_callable returns true even if method does not exist in parent class) [original test with deprecated syntax] | ||
--FILE-- | ||
<?php | ||
|
||
class ParentClass { } | ||
|
||
class ChildClass extends ParentClass { | ||
public function testIsCallable() { | ||
var_dump(is_callable(array($this, 'parent::testIsCallable'))); | ||
} | ||
public function testIsCallable2() { | ||
var_dump(is_callable(array($this, 'static::testIsCallable2'))); | ||
} | ||
} | ||
|
||
$child = new ChildClass(); | ||
$child->testIsCallable(); | ||
$child->testIsCallable2(); | ||
|
||
?> | ||
--EXPECTF-- | ||
Deprecated: Callables of the form ["ChildClass", "parent::testIsCallable"] are deprecated in %s on line %d | ||
bool(false) | ||
|
||
Deprecated: Callables of the form ["ChildClass", "static::testIsCallable2"] are deprecated in %s on line %d | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.