nvlad / yii2support

Yii2 Support for PhpStorm / IntelliJ IDEA
https://plugins.jetbrains.com/idea/plugin/9388-yii2-support
Other
295 stars 54 forks source link

AR models: plugin imports columns/attributes from table in service DB `mysql` #284

Open WinterSilence opened 2 years ago

WinterSilence commented 2 years ago

What steps will reproduce the problem?

  1. create user table in database defined in db component:
    CREATE TABLE `user` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `login` VARCHAR(100) NOT NULL,
    `password_hash` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE INDEX `login` (`login`) USING BTREE,
    ) COLLATE='utf8mb4_unicode_ci' ENGINE=InnoDB;

    2 Create model

    <?php
    namespace app\models;
    use yii\db\ActiveRecord;
    /**
    * User model.
    *
    * @property int $id
    * @property string $login
    * @property string $password_hash
    */
    class User extends ActiveRecord
    {
    public static function tableName()
    {
        return '{{user}}';
    }
    }

What is the expected result?

No missed columns/attributes - they declared as @property.

What do you get instead?

Plugin generate "missed attributes" error and try to import attributes from table with same name, but in mysql(not db database). Plugin add @property tags:

Host
User
Select_priv
<...>

Additional info

Q A
IDE Name PhpStorm
IDE Version 2022.2
Plugin version 0.10.58.37
Yii App Template basic