These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace yiicod\systemparams; |
||
| 4 | |||
| 5 | use Yii; |
||
| 6 | use yii\base\BootstrapInterface; |
||
| 7 | use yii\base\Component; |
||
| 8 | use yii\helpers\ArrayHelper; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * Cms extension settings. |
||
| 12 | * |
||
| 13 | * @author Orlov Alexey <[email protected]> |
||
| 14 | */ |
||
| 15 | class SystemParams extends Component implements BootstrapInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var bool |
||
| 19 | */ |
||
| 20 | public $commandMap = []; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var array table settings |
||
| 24 | */ |
||
| 25 | public $modelMap = []; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Cache durations. |
||
| 29 | * |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | public $cacheDuration; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * System params service instance |
||
| 36 | * |
||
| 37 | * @var null |
||
| 38 | */ |
||
| 39 | private static $service; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Init components, Merge config. |
||
| 43 | */ |
||
| 44 | public function bootstrap($app) |
||
| 45 | { |
||
| 46 | //Merge main extension config with local extension config |
||
| 47 | $config = include dirname(__FILE__) . '/config/main.php'; |
||
| 48 | |||
| 49 | foreach ($config as $key => $value) { |
||
| 50 | if (is_array($value)) { |
||
| 51 | $this->{$key} = ArrayHelper::merge($value, $this->{$key}); |
||
| 52 | } elseif (null === $this->{$key}) { |
||
| 53 | $this->{$key} = $value; |
||
| 54 | } |
||
| 55 | } |
||
| 56 | |||
| 57 | self::$service = Yii::createObject([ |
||
|
0 ignored issues
–
show
|
|||
| 58 | 'class' => SystemParamsService::class, |
||
| 59 | 'cacheDuration' => $this->cacheDuration, |
||
| 60 | ]); |
||
| 61 | |||
| 62 | //Merge commands map |
||
| 63 | if (Yii::$app instanceof \yii\console\Application) { |
||
| 64 | Yii::$app->controllerMap = ArrayHelper::merge($this->commandMap, Yii::$app->controllerMap); |
||
| 65 | Yii::$app->controllerMap = array_filter(Yii::$app->controllerMap); |
||
| 66 | } |
||
| 67 | |||
| 68 | Yii::setAlias('@yiicod', realpath(dirname(__FILE__) . '/..')); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Get parameter |
||
| 73 | * |
||
| 74 | * @param string $param |
||
| 75 | * @param mixed $default |
||
| 76 | * |
||
| 77 | * @return mixed |
||
| 78 | */ |
||
| 79 | public static function getParam(string $param, $default = null) |
||
| 80 | { |
||
| 81 | $value = self::$service->getParam($param); |
||
|
0 ignored issues
–
show
|
|||
| 82 | |||
| 83 | return null === $value ? $default : $value; |
||
| 84 | } |
||
| 85 | } |
||
| 86 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..