mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
phpstan fixes
This commit is contained in:
parent
6fe667eaca
commit
5d37f6813d
10 changed files with 24 additions and 86 deletions
|
|
@ -10,21 +10,17 @@ on:
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
php-cs-fixer:
|
checks:
|
||||||
name: PHP-CS-Fixer
|
name: Nix checks
|
||||||
runs-on: ubuntu-latest
|
runs-on: nix
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup PHP
|
- uses: https://codeberg.org/icewind/attic-action@v1
|
||||||
uses: https://github.com/shivammathur/setup-php@v2
|
|
||||||
with:
|
with:
|
||||||
php-version: "8.2"
|
name: link
|
||||||
extensions: apcu
|
instance: https://cache.icewind.link
|
||||||
- name: Composer
|
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||||
run: composer install
|
- run: nix flake check --keep-going
|
||||||
- name: PHP-CS-Fixer
|
|
||||||
run: |
|
|
||||||
composer run cs:check
|
|
||||||
|
|
||||||
php-versions:
|
php-versions:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|
@ -201,61 +197,3 @@ jobs:
|
||||||
--coverage-clover=coverage.xml
|
--coverage-clover=coverage.xml
|
||||||
env:
|
env:
|
||||||
BACKEND: smbclient
|
BACKEND: smbclient
|
||||||
|
|
||||||
static-psalm-analysis:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Psalm static analysis - PHP ${{ matrix.php-version }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
php-version:
|
|
||||||
- "8.2"
|
|
||||||
- "8.3"
|
|
||||||
- "8.4"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: krb5-dev
|
|
||||||
env:
|
|
||||||
DEBIAN_FRONTEND: noninteractive
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libkrb5-dev libsmbclient-dev
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Set up php
|
|
||||||
uses: https://github.com/shivammathur/setup-php@master
|
|
||||||
with:
|
|
||||||
php-version: "${{ matrix.php-version }}"
|
|
||||||
tools: composer:v2
|
|
||||||
coverage: none
|
|
||||||
extensions: apcu, smbclient, krb5
|
|
||||||
env:
|
|
||||||
fail-fast: true
|
|
||||||
- name: Install dependencies
|
|
||||||
run: composer i
|
|
||||||
- name: Run coding standards check
|
|
||||||
run: composer run psalm
|
|
||||||
|
|
||||||
phpstan:
|
|
||||||
name: PHPStan Static Analysis
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: krb5-dev
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libkrb5-dev
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Setup PHP
|
|
||||||
uses: https://github.com/shivammathur/setup-php@v2
|
|
||||||
with:
|
|
||||||
php-version: 8.3
|
|
||||||
extensions: apcu, smbclient, krb5
|
|
||||||
env:
|
|
||||||
fail-fast: true
|
|
||||||
- name: Composer
|
|
||||||
run: composer install
|
|
||||||
- env:
|
|
||||||
BACKEND: smbclient
|
|
||||||
run: php ./vendor/bin/phpstan analyse --level 6 src
|
|
||||||
|
|
|
||||||
8
flake.lock
generated
8
flake.lock
generated
|
|
@ -46,11 +46,11 @@
|
||||||
"phps": "phps"
|
"phps": "phps"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1761418624,
|
"lastModified": 1761424893,
|
||||||
"narHash": "sha256-VKsV/b8rQ+SEzAav2uJYZSbJFv0m6bpsJJSURnsZIPk=",
|
"narHash": "sha256-vBYj2I6xdVImVAMU7u1CCZkZELIbbo6dzAo/9pSc6RI=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "dbdb33ac9ff56810441e6693645da7ea0fbcc950",
|
"rev": "a59a517f661f7381303588ad20c945ddf916ff5c",
|
||||||
"revCount": 3,
|
"revCount": 7,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://codeberg.org/icewind/flakelight-php.git"
|
"url": "https://codeberg.org/icewind/flakelight-php.git"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,6 @@
|
||||||
outputs = {flakelight-php, ...}:
|
outputs = {flakelight-php, ...}:
|
||||||
flakelight-php ./. {
|
flakelight-php ./. {
|
||||||
vendorHash = "sha256-biMQm0+JPJxnxlnvZMpVNhd3s/KPno8LQ/kL8D5xrHU=";
|
vendorHash = "sha256-biMQm0+JPJxnxlnvZMpVNhd3s/KPno8LQ/kL8D5xrHU=";
|
||||||
phpExtensions = all: with all; [smbclient];
|
phpExtensions = all: with all; [smbclient krb5];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
parameters:
|
parameters:
|
||||||
level: 3
|
level: 7
|
||||||
paths:
|
paths:
|
||||||
- src
|
- src
|
||||||
stubFiles:
|
stubFiles:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ final class AnonymousAuth implements IAuth {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWorkgroup(): ?string {
|
public function getWorkgroup(): string {
|
||||||
return 'dummy';
|
return 'dummy';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ final class BasicAuth implements IAuth {
|
||||||
$this->password = $password;
|
$this->password = $password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsername(): ?string {
|
public function getUsername(): string {
|
||||||
return $this->username;
|
return $this->username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ final class BasicAuth implements IAuth {
|
||||||
return $this->workgroup;
|
return $this->workgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword(): ?string {
|
public function getPassword(): string {
|
||||||
return $this->password;
|
return $this->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class Exception extends \Exception {
|
||||||
if (isset($exceptionMap[$error])) {
|
if (isset($exceptionMap[$error])) {
|
||||||
$exceptionClass = $exceptionMap[$error];
|
$exceptionClass = $exceptionMap[$error];
|
||||||
if (is_numeric($error)) {
|
if (is_numeric($error)) {
|
||||||
return new $exceptionClass($path, $error);
|
return new $exceptionClass($path, (int)$error);
|
||||||
} else {
|
} else {
|
||||||
return new $exceptionClass($path);
|
return new $exceptionClass($path);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ final class NativeReadStream extends NativeStream {
|
||||||
return $this->readBuffer->remaining() <= 0 && parent::stream_eof();
|
return $this->readBuffer->remaining() <= 0 && parent::stream_eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_tell() {
|
public function stream_tell(): int {
|
||||||
return $this->pos;
|
return $this->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ final class NativeWriteStream extends NativeStream {
|
||||||
parent::stream_write($this->writeBuffer->flush());
|
parent::stream_write($this->writeBuffer->flush());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_write($data) {
|
public function stream_write($data): int {
|
||||||
$written = $this->writeBuffer->push($data);
|
$written = $this->writeBuffer->push($data);
|
||||||
$this->pos += $written;
|
$this->pos += $written;
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ final class NativeWriteStream extends NativeStream {
|
||||||
return parent::stream_close() && $flushResult;
|
return parent::stream_close() && $flushResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stream_tell() {
|
public function stream_tell(): int {
|
||||||
return $this->pos;
|
return $this->pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ final class Parser {
|
||||||
// A line = explode statement may not fill all array elements
|
// A line = explode statement may not fill all array elements
|
||||||
// properly. May happen when accessing non Windows Fileservers
|
// properly. May happen when accessing non Windows Fileservers
|
||||||
$words = explode(':', $line, 2);
|
$words = explode(':', $line, 2);
|
||||||
$name = isset($words[0]) ? $words[0] : '';
|
$name = $words[0];
|
||||||
$value = isset($words[1]) ? $words[1] : '';
|
$value = isset($words[1]) ? $words[1] : '';
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
|
|
@ -160,7 +160,7 @@ final class Parser {
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
'mtime' => (int)strtotime($data['write_time']),
|
'mtime' => (int)strtotime($data['write_time']),
|
||||||
'mode' => hexdec(substr($data['attributes'], $attributeStart + 1, -1)),
|
'mode' => (int)hexdec(substr($data['attributes'], $attributeStart + 1, -1)),
|
||||||
'size' => isset($data['stream']) ? (int)(explode(' ', $data['stream'])[1]) : 0
|
'size' => isset($data['stream']) ? (int)(explode(' ', $data['stream'])[1]) : 0
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -255,7 +255,7 @@ final class Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($mask, 0, 2) === '0x') {
|
if (substr($mask, 0, 2) === '0x') {
|
||||||
$maskInt = hexdec($mask);
|
$maskInt = (int)hexdec($mask);
|
||||||
} else {
|
} else {
|
||||||
$maskInt = 0;
|
$maskInt = 0;
|
||||||
foreach (explode('|', $mask) as $maskString) {
|
foreach (explode('|', $mask) as $maskString) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue