Generic types and templates

PHP doesn't support generic types out of the box, but there's a workaround that helps us have a cleaner type interface, and therefore less bugs, which is psalm template annotations. Here's an example:

PHP
    /**
     * @template T of \Illuminate\Notifications\Notification
     * @param class-string<T> $notificationFQCN
     * @return T
     */
    protected function initialize(string $notificationFQCN): Notification
    {
        $reflectionClass = new \ReflectionClass($notificationFQCN);
        $constructor = $reflectionClass->getConstructor();

        // Checks to make sure we can instantiate the object

        return $reflectionClass->newInstance();
    }