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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 21:01:29 2024 UTC