floor12 /
yii2-module-files
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Created by PhpStorm. |
||
| 4 | * User: floor12 |
||
| 5 | * Date: 31.12.2017 |
||
| 6 | * Time: 14:45 |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace floor12\files; |
||
| 10 | |||
| 11 | use Yii; |
||
| 12 | use yii\db\Connection; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Class Module |
||
| 16 | * @package floor12\files |
||
| 17 | * @property string $token_salt |
||
| 18 | * @property string $storage |
||
| 19 | * @property string $controllerNamespace |
||
| 20 | * |
||
| 21 | */ |
||
| 22 | class Module extends \yii\base\Module |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @inheritdoc |
||
| 26 | */ |
||
| 27 | public $controllerNamespace = 'floor12\files\controllers'; |
||
| 28 | |||
| 29 | /** Путь к файловому хранилищу |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | public $storage = '@vendor/../storage'; |
||
| 33 | |||
| 34 | /** Путь к хранилищу кешей |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | public $cache = '@vendor/../storage_cache'; |
||
| 38 | /** |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | public $hostStatic = ''; |
||
| 42 | /** |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | public $ffmpeg = '/usr/bin/ffmpeg'; |
||
| 46 | /** |
||
| 47 | * @var string |
||
| 48 | */ |
||
| 49 | public $token_salt = 'randomString412DDs@#KJH'; |
||
| 50 | /** |
||
| 51 | * @var string |
||
| 52 | */ |
||
| 53 | public $storageFullPath; |
||
| 54 | /** |
||
| 55 | * @var string |
||
| 56 | */ |
||
| 57 | public $cacheFullPath; |
||
| 58 | /** |
||
| 59 | * @var bool |
||
| 60 | */ |
||
| 61 | public $allowOfficePreview = true; |
||
| 62 | /** |
||
| 63 | * @var array |
||
| 64 | */ |
||
| 65 | public $params = ['db' => 'db']; |
||
| 66 | /** |
||
| 67 | * @var Connection |
||
| 68 | */ |
||
| 69 | public $db; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @inheritdoc |
||
| 73 | */ |
||
| 74 | public function init() |
||
| 75 | { |
||
| 76 | $this->registerTranslations(); |
||
| 77 | $this->db = Yii::$app->{$this->params['db']}; |
||
| 78 | $this->storageFullPath = Yii::getAlias($this->storage); |
||
|
0 ignored issues
–
show
|
|||
| 79 | $this->cacheFullPath = Yii::getAlias($this->cache); |
||
|
0 ignored issues
–
show
It seems like
Yii::getAlias($this->cache) can also be of type false. However, the property $cacheFullPath is declared as type string. Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @return void |
||
| 84 | */ |
||
| 85 | public function registerTranslations() |
||
| 86 | { |
||
| 87 | $i18n = Yii::$app->i18n; |
||
| 88 | $i18n->translations['files'] = [ |
||
| 89 | 'class' => 'yii\i18n\PhpMessageSource', |
||
| 90 | 'sourceLanguage' => 'en-US', |
||
| 91 | 'basePath' => '@vendor/floor12/yii2-module-files/src/messages', |
||
| 92 | ]; |
||
| 93 | } |
||
| 94 | |||
| 95 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.