contao / manager-plugin

Contao Manager Plugin
GNU Lesser General Public License v3.0
4 stars 9 forks source link

Improve type docs #43

Closed dmolineus closed 2 years ago

dmolineus commented 2 years ago

This pull request improves some type documentations. When working with static analysis tools like psalm in a strict level Contao type docs are a bit cumbersome on many places.

m-vo commented 2 years ago

Just out of interest:

list<x> means [a_of_x, b_of_x, …] which, in PHP, is non-distinguishable from [0 => a_of_x, 1 => b_of_x. …], i.e. a associative array with zero based numeric keys with no gaps. So is using list<x> over array<x> or array<int, x> purely there for semantics or does it guarantee that keys are indeed canonical?

discordier commented 2 years ago

does it guarantee that keys are indeed canonical?

Yep, that's the definition (according to psalm), array_values returns a list of elements. See also https://psalm.dev/docs/annotating_code/type_syntax/array_types/

dmolineus commented 2 years ago

Is there anything missing or should be improved here?

aschempp commented 2 years ago

ping @dmolineus

dmolineus commented 2 years ago

::class on objects is only supported as of PHP 8.0, however, the plugin supports PHP 7.1+ as well. We have to keep the \get_class() calls therefore.

I adjusted the coding standard and removed the ::class usages

leofeyer commented 2 years ago

Thank you @dmolineus.