php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64201 Resource Identification in Autoload Callback
Submitted: 2013-02-13 06:05 UTC Modified: 2013-02-13 14:33 UTC
From: savinger at sc dot rr dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.11 OS: OSX
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: savinger at sc dot rr dot com
New email:
PHP Version: OS:

 

 [2013-02-13 06:05 UTC] savinger at sc dot rr dot com
Description:
------------
Is there any way for me to differentiate between traits and classes in my autoload 
function? Say I have a folder of classes and a folder of traits; it would be nice 
to be able to do something like...

Test script:
---------------
spl_autoload_register(function($resource) {
  if ( /* $resource is class */ ) {
    include 'classes/'.$resource.'.php';
  } 
  if ( /* $resource is trait */ ) {
    include 'traits/'.$resource.'.php';
  }
});


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-13 06:08 UTC] savinger at sc dot rr dot com
wrong package
 [2013-02-13 06:08 UTC] savinger at sc dot rr dot com
-Package: Dynamic loading +Package: *General Issues
 [2013-02-13 14:33 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2013-02-13 14:33 UTC] johannes@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

No this is not possible, especially as there are situations where we can't see the difference. (Especially if you also think about interfaces) You have to use a custom naming scheme or such.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 19:00:01 2025 UTC