[PHP-BUG] Bug #62808 [NEW]: Using derived autoloader classes doesn't work

2012-08-13 Thread michaelduff2 at yahoo dot com
From: michaelduff2 at yahoo dot com
Operating system: RedHat
PHP version:  5.4.5
Package:  SPL related
Bug Type: Bug
Bug description:Using derived autoloader classes doesn't work

Description:

This case breaks autoloading, because of an apparent assumption in the way
spl_autoload processes its registered functions:

namespace BaseLibrary
{
class Loader
{
 protected static $ns=__NAMESPACE__;
 protected static $dir=__DIR__;

 function Load($class_name)
 {
 // ...fully tested code for autoloading classes
 // using static::$ns and static:$dir...
 }
}

class SomeClass
{
}
}

namespace DerivedLibrary
{
class Loader extends \BaseLibrary\Loader
{
protected static $ns=__NAMESPACE__;
protected static $dir=__DIR__;
}

class SomeClass extends \BaseLibrary\SomeClass
{
}
}

When an attempt is made to load \DerivedLibrary\SomeClass, spl_autoload
finds it correctly, include()s the file, but then never calls
\BaseLibrary\Loader::Load('\BaseLibrary\SomeClass') -- which is necessary
because \DerivedLibrary\SomeClass extends \BaseLibrary\SomeClass and
\DerivedLibrary\Loader extends \BaseLibrary\Loader.

It simply throws "Class does not exist."

My guess is that the spl_autoload queue uses globally scoped data rather
than function-scoped (stack) data to manage its traversal of the autoload
functions, OR because spl_autoload peeks at the function call stack to
ascertain which autoloaders it has already called (probably to avoid
loops).

If \DerivedLibrary\Loader is made into a verbatim copy of
\BaseLibrary\Loader (i.e., copying the file and changing only the namespace
declaration -- thereby implicitly removing the 'extends
\BaseLibrary\Loader') ... then immediately everything works!


-- 
Edit bug report at https://bugs.php.net/bug.php?id=62808&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62808&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62808&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=62808&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62808&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62808&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62808&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=62808&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=62808&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=62808&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=62808&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=62808&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=62808&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=62808&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62808&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=62808&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=62808&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=62808&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=62808&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=62808&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=62808&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=62808&r=mysqlcfg



[PHP-BUG] Req #62859 [NEW]: Give __construct() the respect it deserves

2012-08-18 Thread michaelduff2 at yahoo dot com
From: michaelduff2 at yahoo dot com
Operating system: 
PHP version:  Irrelevant
Package:  *General Issues
Bug Type: Feature/Change Request
Bug description:Give __construct() the respect it deserves 

Description:

Here's a PHP6 -- or PHP7 ;) request for you; many will scream
N, but hear me out:

Make it possible to return an object from __construct().

Yeah, I said it. Sounds crazy, but this would make factories more abstract,
and enables all sorts of magic without user code being any wiser (unless
they Reflect upon it, I suppose.)

For type safety, the object returned should probably be an instanceof
__CLASS__.

If no return() exists, then normal 'new' semantics would apply.

Discuss.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=62859&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62859&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62859&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=62859&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62859&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62859&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62859&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=62859&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=62859&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=62859&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=62859&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=62859&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=62859&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=62859&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62859&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=62859&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=62859&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=62859&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=62859&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=62859&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=62859&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=62859&r=mysqlcfg



[PHP-BUG] Req #62860 [NEW]: Moar magic methods! __constructStatic(), __getStatic(), __setStatic(), __get

2012-08-18 Thread michaelduff2 at yahoo dot com
From: michaelduff2 at yahoo dot com
Operating system: 
PHP version:  Irrelevant
Package:  *General Issues
Bug Type: Feature/Change Request
Bug description:Moar magic methods! __constructStatic(), __getStatic(), 
__setStatic(), __get

Description:

__constructStatic() - executed automatically on class definition

__getStatic() - executed when ClassName::$inaccessible_property is fetched

__setStatic() - executed when ClassName::$inaccessible_property is
modified


The particular use case I have for this is self-loading configuration
registry singletons:



Currently, I accomplish this with __callStatic() which needs the extra
open-close parenthesis.  Ideally, we could get rid of the '$' too, but that
would need some __getConst() magic, which is just madness.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=62860&edit=1
-- 
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=62860&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=62860&r=trysnapshot53
Try a snapshot (trunk):  
https://bugs.php.net/fix.php?id=62860&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=62860&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=62860&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=62860&r=alreadyfixed
Need backtrace:  
https://bugs.php.net/fix.php?id=62860&r=needtrace
Need Reproduce Script:   
https://bugs.php.net/fix.php?id=62860&r=needscript
Try newer version:   
https://bugs.php.net/fix.php?id=62860&r=oldversion
Not developer issue: 
https://bugs.php.net/fix.php?id=62860&r=support
Expected behavior:   
https://bugs.php.net/fix.php?id=62860&r=notwrong
Not enough info: 
https://bugs.php.net/fix.php?id=62860&r=notenoughinfo
Submitted twice: 
https://bugs.php.net/fix.php?id=62860&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=62860&r=globals
PHP 4 support discontinued:  
https://bugs.php.net/fix.php?id=62860&r=php4
Daylight Savings:https://bugs.php.net/fix.php?id=62860&r=dst
IIS Stability:   
https://bugs.php.net/fix.php?id=62860&r=isapi
Install GNU Sed: 
https://bugs.php.net/fix.php?id=62860&r=gnused
Floating point limitations:  
https://bugs.php.net/fix.php?id=62860&r=float
No Zend Extensions:  
https://bugs.php.net/fix.php?id=62860&r=nozend
MySQL Configuration Error:   
https://bugs.php.net/fix.php?id=62860&r=mysqlcfg