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 Gaufrette\Adapter; |
||
4 | |||
5 | use Gaufrette\Adapter; |
||
6 | use Gaufrette\Exception\UnsupportedAdapterMethodException; |
||
7 | use League\Flysystem\AdapterInterface; |
||
8 | use League\Flysystem\Util; |
||
9 | |||
10 | class Flysystem implements Adapter, ListKeysAware |
||
11 | { |
||
12 | /** |
||
13 | * @var AdapterInterface |
||
14 | */ |
||
15 | private $adapter; |
||
16 | |||
17 | /** |
||
18 | * @var Config |
||
19 | */ |
||
20 | private $config; |
||
21 | |||
22 | /** |
||
23 | * @param AdapterInterface $adapter |
||
24 | * @param Config|array|null $config |
||
25 | */ |
||
26 | public function __construct(AdapterInterface $adapter, $config = null) |
||
27 | { |
||
28 | $this->adapter = $adapter; |
||
29 | $this->config = Util::ensureConfig($config); |
||
0 ignored issues
–
show
|
|||
30 | } |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public function read($key) |
||
36 | { |
||
37 | return $this->adapter->read($key)['contents']; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function write($key, $content) |
||
44 | { |
||
45 | return $this->adapter->write($key, $content, $this->config); |
||
0 ignored issues
–
show
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function exists($key) |
||
52 | { |
||
53 | return (bool) $this->adapter->has($key); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function keys() |
||
60 | { |
||
61 | return array_map(function ($content) { |
||
62 | return $content['path']; |
||
63 | }, $this->adapter->listContents()); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function listKeys($prefix = '') |
||
70 | { |
||
71 | $dirs = []; |
||
72 | $keys = []; |
||
73 | |||
74 | foreach ($this->adapter->listContents() as $content) { |
||
75 | if (empty($prefix) || 0 === strpos($content['path'], $prefix)) { |
||
76 | if ('dir' === $content['type']) { |
||
77 | $dirs[] = $content['path']; |
||
78 | } else { |
||
79 | $keys[] = $content['path']; |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | |||
84 | return [ |
||
85 | 'keys' => $keys, |
||
86 | 'dirs' => $dirs, |
||
87 | ]; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * {@inheritdoc} |
||
92 | */ |
||
93 | public function mtime($key) |
||
94 | { |
||
95 | return $this->adapter->getTimestamp($key); |
||
0 ignored issues
–
show
|
|||
96 | } |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function delete($key) |
||
102 | { |
||
103 | return $this->adapter->delete($key); |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function rename($sourceKey, $targetKey) |
||
110 | { |
||
111 | return $this->adapter->rename($sourceKey, $targetKey); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function isDirectory($key) |
||
118 | { |
||
119 | throw new UnsupportedAdapterMethodException('isDirectory is not supported by this adapter.'); |
||
120 | } |
||
121 | } |
||
122 |
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..