如果在声明的命名空间内引起错误,PHP不会报告解析错误

时间:2013-07-07 23:19:44

标签: php namespaces traits

StackOverflowers老板!

我遇到了奇怪的问题。让我写一个简短的描述:

这是我的文件夹层次结构

  • \ sys \ core \ core.php,声明命名空间为sys \ core,类名为core
  • \ sys \ traits \ singleton.php,声明命名空间sys \ traits和trait name singleton
  • \ pub \ index.php(没有声明的命名空间,包括自动加载功能,负责休息 - 基于命名空间声明加载文件)

\ SYS \性状\ singleton.php

trait singleton {

    private static $_instance = false;

    public static function get_instance() {

        if( self::$_instance == false ) {

            self::$_instance = new self();
        }

        return self::$_instance;
    }

}

\ SYS \芯\ core.php中

namespace sys\core;

class core {
    use \sys\traits\singleton;

    public function __construct() {
        $ =; // just an example, it shall produce a nice parse error but it wont :(
    }
}

\ pub \ index.php 我有

error_reporting(E_ALL);

// some constants defined

require('path/to/my/autoload/which/works/correctly.php');

use sys\core\core as core;

$core = core::get_instance();

$core->load_controller();

基本上,除非在命名空间内引起任何类型的错误(parse error / warning etc)。因此,\pub\index.php中的任何错误都会被正确报告(根据需要),但是在具有声明的命名空间的文件中发生的每个错误都会导致白页,并且没有显示错误(尽管error_reporting设置为E_ALL到处都是它是可能的 - 甚至在php.ini中)

我的配置信息:

PHP 5.5.0(来自dotdeb.org的软件包)通过PHP-FPM运行 nginx 1.4.1(来自dotdeb.org的软件包,nginx的error.log也是空的,即使它通常会保存任何类型的PHP错误) 在Debian上运行(测试/ Sid)

任何提示/提示我缺少什么?我会感激任何信息!提前谢谢!

1 个答案:

答案 0 :(得分:0)

问题解决了(无论如何它都没有连接到命名空间)

@之前的include()不是来自include的沉默错误,它会使所包含文件中抛出的所有错误都沉默(我想知道它曾经像以前一样......)

无论如何,问题可以被关闭,利用和遗忘