Skip to content

Commit aca9c3d

Browse files
authored
Fix PHP 8.4 syntax (#175)
Fixes #173
1 parent 4af9369 commit aca9c3d

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

src/Deployment/CommandLine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(string $help, array $defaults = [])
6767
}
6868

6969

70-
public function parse(array $args = null): array
70+
public function parse(?array $args = null): array
7171
{
7272
if ($args === null) {
7373
$args = isset($_SERVER['argv']) ? array_slice($_SERVER['argv'], 1) : [];

src/Deployment/Deployer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ private function writeProgress(
446446
int $count,
447447
int $total,
448448
string $path,
449-
float $percent = null,
450-
string $color = null,
449+
?float $percent = null,
450+
?string $color = null,
451451
): void
452452
{
453453
$len = strlen((string) $total);

src/Deployment/FileServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function readFile(string $remote, string $local): void
5858
* Uploads file.
5959
* @throws ServerException
6060
*/
61-
public function writeFile(string $local, string $remote, callable $progress = null): void
61+
public function writeFile(string $local, string $remote, ?callable $progress = null): void
6262
{
6363
Safe::copy($local, $this->root . $remote);
6464
if ($this->filePermissions) {
@@ -117,7 +117,7 @@ public function removeDir(string $dir): void
117117
* Recursive deletes content of directory or file.
118118
* @throws ServerException
119119
*/
120-
public function purge(string $dir, callable $progress = null): void
120+
public function purge(string $dir, ?callable $progress = null): void
121121
{
122122
$dir = $this->root . $dir;
123123
if (!file_exists($dir)) {

src/Deployment/FtpServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function readFile(string $remote, string $local): void
106106
* Uploads file to FTP server.
107107
* @throws ServerException
108108
*/
109-
public function writeFile(string $local, string $remote, callable $progress = null): void
109+
public function writeFile(string $local, string $remote, ?callable $progress = null): void
110110
{
111111
$size = max(filesize($local), 1);
112112
$blocks = 0;
@@ -222,7 +222,7 @@ public function removeDir(string $dir): void
222222
* Recursive deletes content of directory or file.
223223
* @throws ServerException
224224
*/
225-
public function purge(string $dir, callable $progress = null): void
225+
public function purge(string $dir, ?callable $progress = null): void
226226
{
227227
if (!$this->isDir($dir)) {
228228
return;

src/Deployment/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static function matchMask(string $path, array $patterns, bool $isDir = fa
7777
/**
7878
* Processes HTTP request.
7979
*/
80-
public static function fetchUrl(string $url, ?string &$error, array $postData = null): string
80+
public static function fetchUrl(string $url, ?string &$error, ?array $postData = null): string
8181
{
8282
if (extension_loaded('curl')) {
8383
$ch = curl_init($url);

src/Deployment/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(string $file)
4747
}
4848

4949

50-
public function log(string $s, string $color = null, int $shorten = 1): void
50+
public function log(string $s, ?string $color = null, int $shorten = 1): void
5151
{
5252
fwrite($this->file, $s . "\n");
5353

src/Deployment/PhpsecServer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class PhpsecServer implements Server
2020

2121
public function __construct(
2222
string $url,
23-
string $publicKey = null,
23+
?string $publicKey = null,
2424
#[\SensitiveParameter]
25-
string $privateKey = null,
25+
?string $privateKey = null,
2626
#[\SensitiveParameter]
27-
string $passPhrase = null,
27+
?string $passPhrase = null,
2828
) {
2929
$this->url = parse_url($url);
3030
if (!isset($this->url['scheme'], $this->url['user'], $this->url['host']) || $this->url['scheme'] !== 'phpsec') {
@@ -64,7 +64,7 @@ public function readFile(string $remote, string $local): void
6464
}
6565

6666

67-
public function writeFile(string $local, string $remote, callable $progress = null): void
67+
public function writeFile(string $local, string $remote, ?callable $progress = null): void
6868
{
6969
if ($this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE, -1, -1, $progress) === false) {
7070
throw new ServerException('Unable to write file');
@@ -129,7 +129,7 @@ public function removeDir(string $dir): void
129129
}
130130

131131

132-
public function purge(string $path, callable $progress = null): void
132+
public function purge(string $path, ?callable $progress = null): void
133133
{
134134
if ($this->sftp->file_exists($path)) {
135135
if ($this->sftp->delete($path, true) === false) {

src/Deployment/RetryServer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function readFile(string $remote, string $local): void
4242
}
4343

4444

45-
public function writeFile(string $local, string $remote, callable $progress = null): void
45+
public function writeFile(string $local, string $remote, ?callable $progress = null): void
4646
{
4747
$this->retry(__FUNCTION__, func_get_args());
4848
}
@@ -72,7 +72,7 @@ public function removeDir(string $dir): void
7272
}
7373

7474

75-
public function purge(string $path, callable $progress = null): void
75+
public function purge(string $path, ?callable $progress = null): void
7676
{
7777
$this->retry(__FUNCTION__, func_get_args());
7878
}

src/Deployment/Safe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static function __callStatic(string $func, array $args = [])
8989

9090

9191
/** @throws ServerException */
92-
public static function exec(string $command, array &$output = null, int &$return_var = null): string
92+
public static function exec(string $command, ?array &$output = null, ?int &$return_var = null): string
9393
{
9494
return self::__callStatic(__FUNCTION__, [$command, &$output, &$return_var]);
9595
}

src/Deployment/Server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function readFile(string $remote, string $local): void;
3232
* Uploads file to server. Paths are absolute.
3333
* @throws ServerException
3434
*/
35-
function writeFile(string $local, string $remote, callable $progress = null): void;
35+
function writeFile(string $local, string $remote, ?callable $progress = null): void;
3636

3737
/**
3838
* Removes file from server if exists. Path is absolute.
@@ -62,7 +62,7 @@ function removeDir(string $dir): void;
6262
* Recursive deletes content of directory or file. Path is absolute.
6363
* @throws ServerException
6464
*/
65-
function purge(string $path, callable $progress = null): void;
65+
function purge(string $path, ?callable $progress = null): void;
6666

6767
/**
6868
* Changes file permissions. Path is absolute.

0 commit comments

Comments
 (0)