Post #3910915
2026-07-18 12:38 UTC
@nyamsprod@phpc.social This gave me the idea to check if array destructuring works with ArrayAccess. It does. This would allow to support both the destructuring and the “named properties”-based access in an equally convenient way (i.e. without ->asTuple()).
This might be an option for the native Duration class in 8.7 then 🤔
Replies (3)
-
@nyamsprod@phpc.social 2026-07-18 12:58
@timwolla@phpc.social I will refactor my code for v0.3.0 and move asTuple to being a private method
-
@nyamsprod@phpc.social 2026-07-19 09:51
@timwolla@phpc.social https://github.com/bakame-php/tokei/blob/main/src/DivisionResult.php refactored looks nice 💯
-
@nyamsprod@phpc.social 2026-07-18 12:41
@timwolla@phpc.social I tried by implementing Traversable but the result was not convincing ... because it's not an iterable and doiing [] = [...$iterable] was terrible. I did not think about ArrayAccess though good idea