Skip to content

Implement Iterator or IteratorAggregate in Session class #10

@yani

Description

@yani

A correct array implementation should also implement Iterator or IteratorAggregate.
https://www.php.net/manual/en/class.iterator.php
https://www.php.net/manual/en/class.iteratoraggregate.php

I had to add to implement Iterator it into the Session class so it could be used with slim/csrf for example. The lib normally operates on $_SESSION but you can substitute it for a custom array. It checks for ArrayAccess, Countable, Iterator. Its possible that slim/csrf should instead extend the Traversable interface because only checking for Iterator means IteratorAggregate implementations would not work. I'll have to look into it if PHP considers these to be magically the same.

There's also Serializable which I think could be needed by some libraries.
https://www.php.net/manual/en/class.serializable.php

I can continue working on this.
Sorry for raising these issues 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions