php-ds / ext-ds

An extension providing efficient data structures for PHP 7
https://medium.com/p/9dda7af674cd
MIT License
2.11k stars 95 forks source link

Adjust and document types #137

Closed Majkl578 closed 5 years ago

Majkl578 commented 5 years ago

Add voids and document parameter/return types.

Majkl578 commented 5 years ago

My only concern with explicit void types is that they restrict the ability to create immutable structures that implement the base ones.

I generally disagree with this, you can't have a reliable interface for both mutable and immutable structure. Consumers of the interface wouldn't know how to handle the interface and whether it's mutable or not. If you want mutable and immutable structures side by side, it should come as two separate trees with only sharing read methods, not by inheritance hack that would break expectations for consumers.

rtheunissen commented 5 years ago

My only concern with explicit void types is that they restrict the ability to create immutable structures that implement the base ones.

I generally disagree with this, you can't have a reliable interface for both mutable and immutable structure. Consumers of the interface wouldn't know how to handle the interface and whether it's mutable or not. If you want mutable and immutable structures side by side, it should come as two separate trees with only sharing read methods, not by inheritance hack that would break expectations for consumers.

Good call, agreed. :+1: