On Tue, Oct 25, 2011 at 12:49 PM, Benjamin Eberlei <kont...@beberlei.de>wrote:

> I think the following two requirements should be covered by configuration
> aswell:
>
> 1. Have the autoloader be silent, i.e. doing a file_exists() check. API
> idea
> $loader = new SplClassLoader(..., SplClassLoader::SILENT);
> 2. Have a ASSERT_CLASS_EXISTS mode, i.e. after the require an
> "if(!class_exists($class))" => throw new LogicException("SplClassLoader
> expects class $class to be in $file, but after requiring the file this
> class
> is still not loaded."); API here aswell "new SplCloassLoader(...,
> SplClassLoader::ASSERT_CLASS_EXISTS)"
>


What if 5.4 enhanced class_exists() to send a second true argument (an
optional argument, where default should be false) to autoloaders, then users
wouldn't have to deal with silent vs noisy modes at all.

So signature of autoload functions becomes:
    function load( string $className, bool $checkExistence = false );

In the case of splClassLoader, $checkExistence = false would for instance
mean you would get a *E_COMPILE_ERROR *(requrie) if the class does not exist
but does match the configured root name spaced to be handled, if the
argument is true, then a bool is returned.




>
> greetings,
> Benjamin
>
> On Tue, Oct 25, 2011 at 4:39 AM, guilhermebla...@gmail.com <
> guilhermebla...@gmail.com> wrote:
>
> > Hi internals,
> >
> > For all those interested, I have updated the RFC with better
> > explanation, included example implementation and also example usage.
> > If you have any other wishes, doubts, etc, feel free to ask on this
> > thread and I'll quickly answer here and also update the RFC
> > accordingly.
> >
> > The url for the RFC is: https://wiki.php.net/rfc/splclassloader
> >
> > Cheers,
> >
> > On Mon, Oct 24, 2011 at 7:55 PM, David Coallier <dav...@php.net> wrote:
> > >>
> > >> Could you open a FR at bugs.php.net and attach the patch to it
> please?
> > >> Could be easier to track  (and the # to the RFC too :)
> > >>
> > >
> > > Yeah I'll do that once I have the tests adjusted and once I know the
> > > patch actually works as expected.
> > >
> > > --
> > > David Coallier
> > >
> > > --
> > > PHP Internals - PHP Runtime Development Mailing List
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> >
> > --
> > Guilherme Blanco
> > Mobile: +55 (11) 8118-4422
> > MSN: guilhermebla...@hotmail.com
> > São Paulo - SP/Brazil
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

Reply via email to