Date: 2025-02-25 15:40:15
Score: 0.5
Natty:
Modern PHPDoc can be used like following:
- int[]: an array with only INT values – [1, 4, 6, 8, 9, …]
- array<int, int>: an array with only INT values – [4 => 1, 8 => 4, 12 => 6, …]
- string[]: an array with only STRING values – [„foo“, „bar“, …]
- array<int, string>: an array with only STRING values – [4 => „foo“, 8 => „bar“, …]
- Order[]: an array with only „Order“-Object values – [Order, Order, …]
- array<int|string, Order>: an array with INT or STRING as key and „Order“-Object values – [4 => Order, ‘foo‘ => Order, …]
- array<int|string, mixed>: an array with INT or STRING as key and mixed as values – [1 => 1, 4 => „foo“, 6 => \stdClass, …]
- array<int, array<int, string>>: an array with INT as key and and an array (with INT as key and string as value) as values – [1 => [1 => „foo“], 4 => [1 => 4], …]
- array<int, string[]>: an array with INT as key and and an array (with INT as key and string as value) as values – [1 => [„foo“, „lall“], 4 => [„öäü“, „bar“], …]
- array{output: string, debug: string}: an array with the key „output“ and „debug“, the values are STRING values – [‚output‘ => ‚foo‘, ‚debug‘ => ‚bar‘]
- array<int, array{output: string, debug: string}>: an array with the key „output“ and „debug“, the values are STRING values – [1 => [‚output‘ => ‚foo‘, ‚debug‘ => ‚bar‘], 3 => [‚output‘ => ‚foo‘, ‚debug‘ => ‚bar‘], …]
Examples (only @psalm-): supported by PHPStan & Psalm*
- list<array{output: string, debug: string}>: an array with the key „output“ and „debug“, the values are STRING values – [0 => [‚output‘ => ‚foo‘, ‚debug‘ => ‚bar‘], 1 => [‚output‘ => ‚foo‘, ‚debug‘ => ‚bar‘], …]
More in here
Reasons:
- Long answer (-1):
- No code block (0.5):
- User mentioned (1): @psalm-
Posted by: Md. A. Apu