proget-hq / phpstan-yii2

Yii2 extension for PHPStan
MIT License
52 stars 18 forks source link

Use generics to simplify extension #26

Open b1rdex opened 4 years ago

b1rdex commented 4 years ago

This file can be included in phpstan config using stubFiles directive.

namespace yii\db {
    class ActiveRecord {
        /**
         * @phpstan-return ActiveQuery<static>
         */
        public static function find();
    }

    /**
     * @template T of ActiveRecord
     */
    class ActiveQuery {
        /**
         * @phpstan-return T[]
         */
        public function all($db = null);

        /**
         * @phpstan-return T|null
         */
        public function one($db = null);
    }
}