Skip to content

Commit 01c57b8

Browse files
author
Hwashiang Yu
committed
MC-36640: Validation Update
- Fixed static test failure.
1 parent f11a438 commit 01c57b8

File tree

1 file changed

+26
-14
lines changed
  • lib/internal/Magento/Framework/Filesystem/Directory

1 file changed

+26
-14
lines changed

lib/internal/Magento/Framework/Filesystem/Directory/Read.php

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
*/
66
namespace Magento\Framework\Filesystem\Directory;
77

8+
use FilesystemIterator;
89
use Magento\Framework\Exception\FileSystemException;
910
use Magento\Framework\Exception\ValidatorException;
11+
use Magento\Framework\Filesystem\DriverInterface;
1012

1113
/**
14+
* Directory Read Class
15+
*
1216
* @api
1317
* @since 100.0.2
1418
*/
@@ -31,11 +35,13 @@ class Read implements ReadInterface
3135
/**
3236
* Filesystem driver
3337
*
34-
* @var \Magento\Framework\Filesystem\DriverInterface
38+
* @var DriverInterface
3539
*/
3640
protected $driver;
3741

3842
/**
43+
* Validator for path strings
44+
*
3945
* @var PathValidatorInterface|null
4046
*/
4147
private $pathValidator;
@@ -44,13 +50,13 @@ class Read implements ReadInterface
4450
* Constructor. Set properties.
4551
*
4652
* @param \Magento\Framework\Filesystem\File\ReadFactory $fileFactory
47-
* @param \Magento\Framework\Filesystem\DriverInterface $driver
53+
* @param DriverInterface $driver
4854
* @param string $path
4955
* @param PathValidatorInterface|null $pathValidator
5056
*/
5157
public function __construct(
5258
\Magento\Framework\Filesystem\File\ReadFactory $fileFactory,
53-
\Magento\Framework\Filesystem\DriverInterface $driver,
59+
DriverInterface $driver,
5460
$path,
5561
?PathValidatorInterface $pathValidator = null
5662
) {
@@ -61,6 +67,8 @@ public function __construct(
6167
}
6268

6369
/**
70+
* Validate provided path with scheme.
71+
*
6472
* @param null|string $path
6573
* @param null|string $scheme
6674
* @param bool $absolutePath
@@ -88,6 +96,7 @@ protected function validatePath(
8896
* Sets base path
8997
*
9098
* @param string $path
99+
*
91100
* @return void
92101
*/
93102
protected function setPath($path)
@@ -98,12 +107,12 @@ protected function setPath($path)
98107
}
99108

100109
/**
101-
* Retrieves absolute path
102-
* E.g.: /var/www/application/file.txt
110+
* Retrieves absolute path E.g.: /var/www/application/file.txt
103111
*
104112
* @param string $path
105113
* @param string $scheme
106114
* @throws ValidatorException
115+
*
107116
* @return string
108117
*/
109118
public function getAbsolutePath($path = null, $scheme = null)
@@ -135,6 +144,7 @@ public function getRelativePath($path = null)
135144
* Retrieve list of all entities in given path
136145
*
137146
* @param string|null $path
147+
* @throws FileSystemException
138148
* @throws ValidatorException
139149
* @return string[]
140150
*/
@@ -153,7 +163,8 @@ public function read($path = null)
153163
/**
154164
* Read recursively
155165
*
156-
* @param null $path
166+
* @param string|null $path
167+
* @throws FileSystemException
157168
* @throws ValidatorException
158169
* @return string[]
159170
*/
@@ -163,7 +174,7 @@ public function readRecursively($path = null)
163174

164175
$result = [];
165176
$paths = $this->driver->readDirectoryRecursively($this->driver->getAbsolutePath($this->path, $path));
166-
/** @var \FilesystemIterator $file */
177+
/** @var FilesystemIterator $file */
167178
foreach ($paths as $file) {
168179
$result[] = $this->getRelativePath($file);
169180
}
@@ -176,6 +187,7 @@ public function readRecursively($path = null)
176187
*
177188
* @param string $pattern
178189
* @param string $path [optional]
190+
* @throws FileSystemException
179191
* @throws ValidatorException
180192
* @return string[]
181193
*/
@@ -202,24 +214,22 @@ public function search($pattern, $path = null)
202214
*
203215
* @param string $path [optional]
204216
* @return bool
205-
* @throws \Magento\Framework\Exception\FileSystemException
217+
* @throws FileSystemException
206218
* @throws ValidatorException
207219
*/
208220
public function isExist($path = null)
209221
{
210222
$this->validatePath($path);
211223

212-
return $this->driver->isExists(
213-
$this->driver->getRealPathSafety($this->driver->getAbsolutePath($this->path, $path))
214-
);
224+
return $this->driver->isExists($this->driver->getAbsolutePath($this->path, $path));
215225
}
216226

217227
/**
218228
* Gathers the statistics of the given path
219229
*
220230
* @param string $path
221-
* @return arrays
222-
* @throws \Magento\Framework\Exception\FileSystemException
231+
* @return array
232+
* @throws FileSystemException
223233
* @throws ValidatorException
224234
*/
225235
public function stat($path)
@@ -234,7 +244,7 @@ public function stat($path)
234244
*
235245
* @param string $path [optional]
236246
* @return bool
237-
* @throws \Magento\Framework\Exception\FileSystemException
247+
* @throws FileSystemException
238248
* @throws ValidatorException
239249
*/
240250
public function isReadable($path = null)
@@ -284,6 +294,7 @@ public function readFile($path, $flag = null, $context = null)
284294
* Check whether given path is file
285295
*
286296
* @param string $path
297+
* @throws FileSystemException
287298
* @throws ValidatorException
288299
* @return bool
289300
*/
@@ -298,6 +309,7 @@ public function isFile($path)
298309
* Check whether given path is directory
299310
*
300311
* @param string $path [optional]
312+
* @throws FileSystemException
301313
* @throws ValidatorException
302314
* @return bool
303315
*/

0 commit comments

Comments
 (0)