Issue #179 Support unwrapping of traversable objects #286

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@shanethehat
Contributor

shanethehat commented Feb 13, 2014

#179

Please see this gist for an example use case: https://gist.github.com/shanethehat/8951398.

@ciaranmcnulty

This comment has been minimized.

Show comment
Hide comment
@ciaranmcnulty

ciaranmcnulty Feb 13, 2014

Member

I'm wary about merging because as we discussed on Skype, there is no guarantee the ArrayAccess implementation is referring to the same data set as the Traversable implementation.

However it probably solves it for the 99% of cases, so what do others think?

Member

ciaranmcnulty commented Feb 13, 2014

I'm wary about merging because as we discussed on Skype, there is no guarantee the ArrayAccess implementation is referring to the same data set as the Traversable implementation.

However it probably solves it for the 99% of cases, so what do others think?

@andytson

This comment has been minimized.

Show comment
Hide comment
@andytson

andytson Feb 13, 2014

@ciaranmcnulty I think the solution we talked about in the internal chat prob the best solution $this->x()->shouldTraverseOver([1,2,3])

That way it's an explicit choice how to act.

@ciaranmcnulty I think the solution we talked about in the internal chat prob the best solution $this->x()->shouldTraverseOver([1,2,3])

That way it's an explicit choice how to act.

@shanethehat

This comment has been minimized.

Show comment
Hide comment
@shanethehat

shanethehat Feb 13, 2014

Contributor

@andytson Forgive my lack of understanding, but would that work for the example I posted where the difficulties are with a prophecy stub? And is it something that would need to be implemented in Prophecy?

Contributor

shanethehat commented Feb 13, 2014

@andytson Forgive my lack of understanding, but would that work for the example I posted where the difficulties are with a prophecy stub? And is it something that would need to be implemented in Prophecy?

@shanethehat

This comment has been minimized.

Show comment
Hide comment
@shanethehat

shanethehat Feb 17, 2014

Contributor

@MarcelloDuarte has showed me that an easy solution to this is to unwrap the objects in the iterator from inside the spec:

$stagingCollection->getIterator()
    ->willReturn(
        new \ArrayIterator(array(
            $staging1->getWrappedObject(),
            $staging2->getWrappedObject(),
        ))
    );
Contributor

shanethehat commented Feb 17, 2014

@MarcelloDuarte has showed me that an easy solution to this is to unwrap the objects in the iterator from inside the spec:

$stagingCollection->getIterator()
    ->willReturn(
        new \ArrayIterator(array(
            $staging1->getWrappedObject(),
            $staging2->getWrappedObject(),
        ))
    );
@ciaranmcnulty

This comment has been minimized.

Show comment
Hide comment
@ciaranmcnulty

ciaranmcnulty Feb 17, 2014

Member

Very nice

Member

ciaranmcnulty commented Feb 17, 2014

Very nice

@ciaranmcnulty

This comment has been minimized.

Show comment
Hide comment
@ciaranmcnulty

ciaranmcnulty Feb 17, 2014

Member

Tell @MarcelloDuarte that stubs returning stubs is a smell ;-)

Member

ciaranmcnulty commented Feb 17, 2014

Tell @MarcelloDuarte that stubs returning stubs is a smell ;-)

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