php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75752 function assert callback The namespace is not avail
Submitted: 2018-01-02 14:22 UTC Modified: 2018-01-02 14:57 UTC
From: 742592958 at qq dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6.32 OS: win7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: 742592958 at qq dot com
New email:
PHP Version: OS:

 

 [2018-01-02 14:22 UTC] 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';


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-02 14:57 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *General Issues +Package: Scripting Engine problem
 [2018-01-02 14:57 UTC] requinix@php.net
Class and function names in strings need to be fully-qualified.

Config::init(__NAMESPACE__ . '\\test');
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 13:01:33 2025 UTC