[PSR-5][PSR-19] Improvement ideas for annotation typings

66 views
Skip to first unread message

Marco Perone

unread,
Oct 13, 2018, 10:32:12 AM10/13/18
to PHP Framework Interoperability Group
Hi,

I would like to share some (not very refined) ideas regarding the usage of PHPDoc annotations, to see if they can be of any interest. Since I am quite a fan of types, they all concern the ability of expressing typing information in the documentation.

1) One desirable feature which is missing from the language is the use of generics. It would be nice to provide their usage at the level of documentation. This is already possible for arrays with the `[]` notation. It would be nice to be able to write something like `Collection<User>` to denote that the collection contains `User` objects

2) Another great limitation in the PHP type system is the impossibility to type input and return types of callables. At the moment `callable` is the best documentation which can be provided. It would be nice to introduce a syntax like `callable: User -> string` to document the actual type of the callable.

3) Define the usage of type variables at the level of documentation. This would allow to declare that the types of two different entities are related. For example, one could desire to express that two variables need to have the same type, or that a callable should receive an input of the same type of another variable.

Marco Perone


Robbie Averill

unread,
Oct 13, 2018, 10:50:49 AM10/13/18
to php...@googlegroups.com
Hi Marco,

Regarding point #1, I believe the current spec provides for this with Collections (see 

Cheers
Robbie 

--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/8984c673-629a-40f1-91f3-0d385a5efddb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Robbie Averill | Senior Developer
04 978 7330

Chuck Burgess

unread,
Oct 13, 2018, 11:01:13 AM10/13/18
to php...@googlegroups.com
Regarding #1, please join the discussion at https://github.com/phpDocumentor/fig-standards/pull/81


Marco Perone

unread,
Oct 13, 2018, 12:01:48 PM10/13/18
to php...@googlegroups.com
Thanks Robbie and Chuck for the pointers!

You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/vQfOntge-10/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.

To post to this group, send email to php...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages