php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33525 __autoload() for interfaces and functions
Submitted: 2005-06-30 16:49 UTC Modified: 2005-06-30 22:11 UTC
From: sr at brightlight dot ch Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sr at brightlight dot ch
New email:
PHP Version: OS:

 

 [2005-06-30 16:49 UTC] sr at brightlight dot ch
Description:
------------
__autoload() is very nice, but classes are not the only 
problem.
Please add a parameter $type to allow functions and interfaces 
become autoloaded as well.
Even more convenient if there were not only the types 'class', 
'interface' and 'function', but also 'method' to autoload 
methods of classes.
Example given.

Reproduce code:
---------------
function __autoload($name, $type)
{
    // $type would be 'class', 'interface', 'function' or 'method'
    require_once("$type.$name.inc");
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-30 20:44 UTC] helly@php.net
It already works for Interfaces.

And it will never work for functions.
 [2005-06-30 22:11 UTC] sr at brightlight dot ch
Yes, it works for interfaces, but you don't know whether you 
autoload an interface or a class.
This plays a role when you have a naming scheme which 
differs for classes and interfaces. Since interfaces are 
many to many it makes sense to place interfaces in separate 
files and a naming scheme is never bad idea.
E.g. I have a naming scheme interface.{name}.inc and class.
{name}.inc

Functions: why not? Is it a technical reason? Or you just 
don't like the idea?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 20:01:32 2024 UTC