Req #55128 [Com]: SplFixedArray::fromArray() does not use extended class

From: Date: Tue, 26 Jul 2011 09:49:52 +0000
Subject: Req #55128 [Com]: SplFixedArray::fromArray() does not use extended class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-162177@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55128&edit=1

 ID:                 55128
 Comment by:         laruence@php.net
 Reported by:        ar at ez dot no
 Summary:            SplFixedArray::fromArray() does not use extended
                     class
 Status:             Analyzed
 Type:               Feature/Change Request
 Package:            SPL related
 Operating System:   *
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

hmm, that's a really problem, if we want to provide this feature, we should make
fixedarray::__construct final.


Previous Comments:
------------------------------------------------------------------------
[2011-07-26 08:36:08] cataphract@php.net

What if FixedCollection has a constructor?

------------------------------------------------------------------------
[2011-07-26 05:35:55] laruence@php.net

The following patch has been added/updated:

Patch Name: php-5-3-splfixedarray-fromarray-should-return-call-scope-instance
Revision:   1311658555
URL:        https://bugs.php.net/patch-display.php?bug=55128&patch=php-5-3-splfixedarray-fromarray-should-return-call-scope-instance&revision=1311658555

------------------------------------------------------------------------
[2011-07-04 09:50:10] ar at ez dot no

Description:
------------
It would be nice if SplFixedArray::fromArray() returned the child class instance 
instead of SplFixedArray instance.

Test script:
---------------
class FixedCollection extends SplFixedArray {
    // impl
}

$collection = FixedCollection::fromArray( array( 22, 42 ) );

if ( 'FixedCollection' !== get_class( $collection ) )
    trigger_error( "fromArray() does not use 'new static'" )



Expected result:
----------------
I would have expected that function returned an instance of FixedCollection.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55128&edit=1


Thread (10 messages)

« previous php.bugs (#162177) next »