These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Asset Packagist. |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/asset-packagist |
||
6 | * @package asset-packagist |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\assetpackagist\commands; |
||
12 | |||
13 | use hiqdev\assetpackagist\models\AssetPackage; |
||
14 | use hiqdev\assetpackagist\repositories\PackageRepository; |
||
15 | use Yii; |
||
16 | use yii\base\Component; |
||
17 | use zhuravljov\yii\queue\Job; |
||
18 | |||
19 | abstract class AbstractPackageCommand extends Component implements Job |
||
20 | { |
||
21 | const EVENT_BEFORE_RUN = 'beforeRun'; |
||
22 | const EVENT_AFTER_RUN = 'afterRun'; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $fullName; |
||
28 | |||
29 | /** |
||
30 | * @var AssetPackage |
||
31 | */ |
||
32 | protected $package; |
||
33 | |||
34 | /** |
||
35 | * @var PackageRepository |
||
36 | */ |
||
37 | protected $packageRepository; |
||
38 | |||
39 | /** |
||
40 | * Triggers event before run. |
||
41 | */ |
||
42 | public function beforeRun() |
||
43 | { |
||
44 | $this->trigger(self::EVENT_BEFORE_RUN); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Triggers event after run. |
||
49 | */ |
||
50 | public function afterRun() |
||
51 | { |
||
52 | $this->trigger(self::EVENT_AFTER_RUN); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * CollectDependenciesCommand constructor. |
||
57 | * @param AssetPackage $package |
||
58 | * @param PackageRepository $packageRepository |
||
59 | * @param array $config |
||
60 | */ |
||
61 | public function __construct(AssetPackage $package, PackageRepository $packageRepository, $config = []) |
||
62 | { |
||
63 | parent::__construct($config); |
||
64 | |||
65 | $this->fullName = $package->getFullName(); |
||
66 | $this->package = $package; |
||
67 | $this->packageRepository = $packageRepository; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Serialize only the name of package for more performance. |
||
72 | * |
||
73 | * @void |
||
74 | */ |
||
75 | public function __sleep() |
||
76 | { |
||
77 | return ['fullName']; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Reloads package on wake up to ensure it is up to date. |
||
82 | * |
||
83 | * @void |
||
84 | */ |
||
85 | public function __wakeup() |
||
86 | { |
||
87 | if ($this->fullName) { |
||
88 | $this->package = AssetPackage::fromFullName($this->fullName); |
||
89 | } |
||
90 | $this->package->load(); |
||
0 ignored issues
–
show
|
|||
91 | $this->packageRepository = Yii::createObject(PackageRepository::class); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return AssetPackage |
||
96 | */ |
||
97 | public function getPackage() |
||
98 | { |
||
99 | return $this->package; |
||
100 | } |
||
101 | } |
||
102 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: