Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Update ArrayStack.php #3984

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

smit1562 commented Mar 7, 2013

Array object cannot be defined twice, this is a minor typo because it is not the php ArrayObject that is needed in this, but the Stdlib\ArrayObject.

stack call:
Fatal error: Cannot use ArrayObject as ArrayObject because the name is already in use

error is found with the
skeleton application
doctrine module
doctrine orm module
doctrine dbal

EDIT:
"use ArrayObject;" must be "use Zend\Stdlib\ArrayObject;"

Update ArrayStack.php
Array object cannot be defined twice, this is a minor typo

stack call:
Fatal error: Cannot use ArrayObject as ArrayObject because the name is already in use
Member

DASPRiD commented Mar 7, 2013

Do we actually want the stdlib ArrayObject in here? If not, it should be something like

use ArrayObject as PhpArrayObject;

Member

DASPRiD commented Mar 7, 2013

Oh, and by the way, @weierophinney: what is the difference between our ArrayStack and the SplStack?

Contributor

smit1562 commented Mar 7, 2013

there is no difference, however both are used. but both cannot be declared as ArrayObject. thats the whole point.

it breaks consistency and, for what i have read, the php arrayobject(stdlib) is buggy in 5.3.3 and above

Owner

weierophinney commented Mar 7, 2013

The original intent was to use PHP's native ArrayObject implementation. @smit1562 The bugginess has to do with unsetting nested values only. Since ArrayStack was intended for implementing a stack out of an array, these issues are not present, as the hierarchy we'd be working with is flat.

Please use @DASPRiD 's suggestion of use ArrayObject as PhpArrayObject -- we do this elsewhere in the framework as well (in particular, around DateTime usage), and it's why aliasing is available in PHP.

Contributor

smit1562 commented Mar 7, 2013

then the problem will persist further, my applications heavely rely on doctrine to work.

but somewhere down the line both the native ArrayObject and the Stdlib/ArrayObject are used. since you cannot declare ArrayObject twice, the fatal error pops up.

therefore either the name must change or the Stdlib/Arrayobject must be used at all times.

Owner

weierophinney commented Mar 7, 2013

then the problem will persist further, my applications heavely rely on doctrine to work.

but somewhere down the line both the native ArrayObject and the Stdlib/ArrayObject are used. since you cannot declare ArrayObject twice, the fatal error pops up.

therefore either the name must change or the Stdlib/Arrayobject must be used at all times.

What are you talking about, exactly? And what does Doctrine have to do with this?

A couple of us already recommended changing the alias in the import: use ArrayObject as PhpArrayObject. Import statements affect the current file only. We only need to alias, and then make sure references to ArrayObject in this file are changed to the alias name (PhpArrayObject). Make those changes, and this will work fine.

@smit1562 smit1562 closed this Mar 7, 2013

Owner

weierophinney commented Mar 7, 2013

@smit1562 This is still an issue -- it just needs to be resolved differently than you originally suggested.

@weierophinney weierophinney reopened this Mar 7, 2013

weierophinney added a commit that referenced this pull request Mar 7, 2013

weierophinney added a commit that referenced this pull request Mar 7, 2013

[#3984] Import ArrayObject as PhpArrayObject
- and update class declaration to extend PhpArrayObject

weierophinney added a commit that referenced this pull request Mar 7, 2013

@ghost ghost assigned weierophinney Mar 7, 2013

weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015

weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015

[zendframework/zendframework#3984] Import ArrayObject as PhpArrayObject
- and update class declaration to extend PhpArrayObject

weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015

weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment