Bug #75752 [Opn->Nab]: function assert callback The namespace is not avail
| From: | requinix@php.net | Date: | Tue, 02 Jan 2018 14:57:25 +0000 |
| Subject: | Bug #75752 [Opn->Nab]: function assert callback The namespace is not avail | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213356@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75752&edit=1
ID: 75752
Updated by: requinix@php.net
Reported by: 742592958 at qq dot com
Summary: function assert callback The namespace is not avail
-Status: Open
+Status: Not a bug
Type: Bug
-Package: *General Issues
+Package: Scripting Engine problem
Operating System: win7
PHP Version: 5.6.32
Block user comment: N
Private report: N
New Comment:
Class and function names in strings need to be fully-qualified.
Config::init(__NAMESPACE__ . '\\test');
Previous Comments:
------------------------------------------------------------------------
[2018-01-02 14:22:54] 742592958 at qq dot com
Description:
------------
PHP Options/Info
Namespace coordination assertion cannot use the callback function
Test script:
---------------
namespace GD\Tool;
class Config
{
public static function init($callback = null)
{
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_BAIL, 1);
if($callback !== null){
assert_options(ASSERT_CALLBACK, $callback);
}
}
public static function assert($assertion,$info = ''){
if((int)PHP_VERSION >= 7 ){
is_object($info) ? : die('not an object');
}else{
is_string($info) ? : die('not an string');
}
return assert($assertion,$info);
}
}
Config::init('test');
function test($file, $line, $code){
die("file:{$file} \n line:{$line} \n code{$code}");
}
Config::assert('1==2');
echo 'success';
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75752&edit=1