php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68910 Fatal error in case of using multiple namespaces with curly brackets.
Submitted: 2015-01-25 15:08 UTC Modified: 2015-01-25 15:20 UTC
From: yajenyak at yandex dot ru Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6.5 OS: Fedora 21
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yajenyak at yandex dot ru
New email:
PHP Version: OS:

 

 [2015-01-25 15:08 UTC] yajenyak at yandex dot ru
Description:
------------
Please try to run the following code. As result the following error will be displayed:
"Fatal error: Class 'Monolog\Handler\MailHandler' not found in /home/user/project/test/index.php on line 6"

If you will try to remove the " extends AbstractProcessingHandler" part the error will not be displayed.

This error prevents us to combine multiple classes to single file for performance optimization.

Test script:
---------------
<?php
namespace My\Logger {
    use Monolog\Handler\MailHandler as BaseMailHandler;

    class MailHandler extends BaseMailHandler
    {
    }
}
namespace Monolog\Handler {
    abstract class MailHandler extends AbstractProcessingHandler
    {
    }
}
namespace Monolog\Handler {
    abstract class AbstractProcessingHandler
    {
    }
}


Expected result:
----------------
No error

Actual result:
--------------
Fatal error: Class 'Monolog\Handler\MailHandler' not found in /home/user/project/test/index.php on line 6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-25 15:20 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2015-01-25 15:20 UTC] nikic@php.net
This has nothing to do with namespaces. Your classes are in the wrong order. You're using the Handler\MailHandler class before it is defined.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 12:00:02 2026 UTC