1 | <?php |
||
2 | /** |
||
3 | * @link https://github.com/acidwave/yii2-flysystem |
||
4 | * @copyright Copyright (c) 2021 Acid Wave |
||
5 | * @license http://opensource.org/licenses/BSD-3-Clause |
||
6 | */ |
||
7 | |||
8 | namespace Acidwave\Flysystem; |
||
9 | |||
10 | use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider; |
||
11 | use League\Flysystem\ZipArchive\ZipArchiveAdapter; |
||
12 | use Yii; |
||
13 | use yii\base\InvalidConfigException; |
||
14 | |||
15 | /** |
||
16 | * ZipArchiveFilesystem |
||
17 | * |
||
18 | * @author Acid Wave <[email protected]> |
||
19 | */ |
||
20 | class ZipArchiveFilesystem extends Filesystem |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | public $filename; |
||
26 | /** |
||
27 | * @var integer |
||
28 | */ |
||
29 | public $localDirectoryPermissions = 700; |
||
30 | |||
31 | /** |
||
32 | * @inheritdoc |
||
33 | */ |
||
34 | public function init() |
||
35 | { |
||
36 | if ($this->filename === null) { |
||
37 | throw new InvalidConfigException('The "filename" property must be set.'); |
||
38 | } |
||
39 | |||
40 | $this->filename = Yii::getAlias($this->filename); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | parent::init(); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return ZipArchiveAdapter |
||
47 | */ |
||
48 | protected function prepareAdapter() |
||
49 | { |
||
50 | $provider = new FilesystemZipArchiveProvider($this->filename, $this->localDirectoryPermissions); |
||
51 | return new ZipArchiveAdapter($provider); |
||
52 | } |
||
53 | } |
||
54 |
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
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. 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.