Fixes the following warnings that were emitted by `composer install`:
```
Generating optimized autoload files
Class Psalm\Tests\KeyOfTemplateTest located in ./tests/Template/KeyOfTemplateTest.php does not comply with psr-4 autoloading standard. Skipping.
Class Psalm\Tests\ValueOfTemplateTest located in ./tests/Template/ValueOfTemplateTest.php does not comply with psr-4 autoloading standard. Skipping.
```
Not in all cases the TemplateParam gets replaced before type checking,
in these cases, use the defined `as` type.
Refactor to extract key/value type of array union to method.