I want to something like this:
function __construct (string $todo, array[Tag] $tags) {}
That array[Tag]
caused me a problem with error along the line: Unexpected '['
The main idea is to have strict type checking for an array of an object with Tag
class.
How can I achieve this? And is it necessary for PHP's best practice?
Short answer, you can't. There is some hacky solution if you really need it though.