mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-10-01 17:14:08 +02:00
psalm fixes
This commit is contained in:
parent
05cc363c9f
commit
4a93467905
12 changed files with 61 additions and 33 deletions
|
|
@ -78,14 +78,17 @@ class Parser {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
public function checkForError(array $output, string $path): void {
|
||||
if (strpos($output[0], 'does not exist')) {
|
||||
throw new NotFoundException($path);
|
||||
}
|
||||
$error = $this->getErrorCode($output[0]);
|
||||
$error = '';
|
||||
if (isset($output[0])) {
|
||||
if (strpos($output[0], 'does not exist') > 0) {
|
||||
throw new NotFoundException($path);
|
||||
}
|
||||
$error = $this->getErrorCode($output[0]);
|
||||
|
||||
if (substr($output[0], 0, strlen(self::MSG_NOT_FOUND)) === self::MSG_NOT_FOUND) {
|
||||
$localPath = substr($output[0], strlen(self::MSG_NOT_FOUND));
|
||||
throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing');
|
||||
if (substr($output[0], 0, strlen(self::MSG_NOT_FOUND)) === self::MSG_NOT_FOUND) {
|
||||
$localPath = substr($output[0], strlen(self::MSG_NOT_FOUND));
|
||||
throw new InvalidResourceException('Failed opening local file "' . $localPath . '" for writing');
|
||||
}
|
||||
}
|
||||
|
||||
throw Exception::fromMap(self::EXCEPTION_MAP, $error, $path);
|
||||
|
|
@ -197,12 +200,12 @@ class Parser {
|
|||
public function parseListShares(array $output): array {
|
||||
$shareNames = [];
|
||||
foreach ($output as $line) {
|
||||
if (strpos($line, '|')) {
|
||||
if (strpos($line, '|') > 0) {
|
||||
list($type, $name, $description) = explode('|', $line);
|
||||
if (strtolower($type) === 'disk') {
|
||||
$shareNames[$name] = $description;
|
||||
}
|
||||
} elseif (strpos($line, 'Disk')) {
|
||||
} elseif (strpos($line, 'Disk') > 0) {
|
||||
// new output format
|
||||
list($name, $description) = explode('Disk', $line);
|
||||
$shareNames[trim($name)] = trim($description);
|
||||
|
|
@ -221,12 +224,24 @@ class Parser {
|
|||
if (strpos($acl, ':') === false) {
|
||||
continue;
|
||||
}
|
||||
[$type, $acl] = explode(':', $acl, 2);
|
||||
$parts = explode(':', $acl, 2);
|
||||
if (count($parts) !== 2) {
|
||||
continue;
|
||||
}
|
||||
[$type, $acl] = $parts;
|
||||
if ($type !== 'ACL') {
|
||||
continue;
|
||||
}
|
||||
[$user, $permissions] = explode(':', $acl, 2);
|
||||
[$type, $flags, $mask] = explode('/', $permissions);
|
||||
$parts = explode(':', $acl, 2);
|
||||
if (count($parts) !== 2) {
|
||||
continue;
|
||||
}
|
||||
[$user, $permissions] = $parts;
|
||||
$parts = explode('/', $permissions);
|
||||
if (count($parts) < 3) {
|
||||
continue;
|
||||
}
|
||||
[$type, $flags, $mask] = $parts;
|
||||
|
||||
$type = $type === 'ALLOWED' ? ACL::TYPE_ALLOW : ACL::TYPE_DENY;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue