Opened 6 weeks ago
Closed 10 days ago
#65409 closed enhancement (fixed)
Filesystem: Update constructor parameter default value to an empty array
| Reported by: | Soean | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Filesystem API | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | docs |
Description
The constructor parameters of the WP_Filesystem_FTPextand WP_Filesystem_SSH2 classes should be an array not an empty string (''). We also should improve the doc block.
Change History (13)
This ticket was mentioned in PR #11593 on WordPress/wordpress-develop by @Soean.
6 weeks ago
#1
@westonruter commented on PR #11593:
5 weeks ago
#2
@Soean I've added a commit to address a wide _array_ of PHPStan issues. On trunk, the following rule level 5 issues exist:
composer phpstan -- -c phpstan.neon.dist --level=5 src/wp-admin/includes/class-wp-filesystem*
------ --------------------------------------------------------------------
Line class-wp-filesystem-base.php
------ --------------------------------------------------------------------
443 Binary operation "+" between non-empty-string and non-empty-string
results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-base.php:443
444 Binary operation "+" between non-empty-string and non-empty-string
results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-base.php:444
445 Binary operation "+" between non-empty-string and non-empty-string
results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-base.php:445
------ --------------------------------------------------------------------
------ ---------------------------------------------------------------------
Line class-wp-filesystem-direct.php
------ ---------------------------------------------------------------------
25 Constructor of class WP_Filesystem_Direct has an unused parameter
$arg.
🪪 constructor.unusedParameter
at src/wp-admin/includes/class-wp-filesystem-direct.php:25
253 Method WP_Filesystem_Direct::owner() should return string|false but
returns int<1, max>.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-direct.php:253
298 Method WP_Filesystem_Direct::group() should return string|false but
returns int<1, max>.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-direct.php:298
------ ---------------------------------------------------------------------
------ -----------------------------------------------------------------------
Line class-wp-filesystem-ftpext.php
------ -----------------------------------------------------------------------
22 Property WP_Filesystem_FTPext::$link has unknown class FTP\Connection
as its type.
🪪 class.notFound
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:22
31 Default value of the parameter #1 $opt (string) of method
WP_Filesystem_FTPext::__construct() is incompatible with type array.
🪪 parameter.defaultValue
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:31
656 Parameter #2 $min of function mktime expects int, string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:656
656 Parameter #4 $mon of function mktime expects int, string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:656
656 Parameter #5 $day of function mktime expects int, string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:656
719 Variable $b might not be defined.
🪪 variable.undefined
at src/wp-admin/includes/class-wp-filesystem-ftpext.php:719
------ -----------------------------------------------------------------------
------ -------------------------------------------------------------------
Line class-wp-filesystem-ftpsockets.php
------ -------------------------------------------------------------------
31 Default value of the parameter #1 $opt (string) of method
WP_Filesystem_ftpsockets::__construct() is incompatible with type
array.
🪪 parameter.defaultValue
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:31
------ -------------------------------------------------------------------
------ -----------------------------------------------------------------------
Line class-wp-filesystem-ssh2.php
------ -----------------------------------------------------------------------
42 Property WP_Filesystem_SSH2::$link (resource) does not accept default
value of type false.
🪪 property.defaultValue
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:42
63 Default value of the parameter #1 $opt (string) of method
WP_Filesystem_SSH2::__construct() is incompatible with type array.
🪪 parameter.defaultValue
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:63
421 Method WP_Filesystem_SSH2::owner() should return string|false but
returns int<1, max>.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:421
461 Method WP_Filesystem_SSH2::group() should return string|false but
returns int<1, max>.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:461
------ -----------------------------------------------------------------------
[ERROR] Found 17 errors
With the commit, the only error left at rule level 5 is:
Property WP_Filesystem_FTPext::$link has unknown class FTP\Connection as its type.
Now, clearly these changes could be out of scope here and could be reverted. However, by providing these additional types it is revealing possible bugs which were not previously detected. So maybe the scope should be increased to add the WP docs as well as the PHPStan docs for static analysis.
#3
@
5 weeks ago
- Focuses docs added
- Milestone Awaiting Review → 7.1
- Owner set to
- Status new → reviewing
@westonruter commented on PR #11593:
5 weeks ago
#4
The remaining rule level 10 errors:
------ -----------------------------------------------------------------------
Line class-wp-filesystem-direct.php
------ -----------------------------------------------------------------------
143 Argument of an invalid type array|false supplied for foreach, only
iterables are supported.
🪪 foreach.nonIterable
at src/wp-admin/includes/class-wp-filesystem-direct.php:143
144 Binary operation "." between string and mixed results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-direct.php:144
231 Argument of an invalid type array|false supplied for foreach, only
iterables are supported.
🪪 foreach.nonIterable
at src/wp-admin/includes/class-wp-filesystem-direct.php:231
232 Binary operation "." between non-falsy-string and mixed results in an
error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-direct.php:232
417 Cannot access offset 'type' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-direct.php:417
417 Parameter #3 $type of method WP_Filesystem_Direct::delete() expects
string|false, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-direct.php:417
644 Method WP_Filesystem_Direct::dirlist() return type has no value type
specified in iterable type array.
🪪 missingType.iterableValue
💡 See:
https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-i
terable-type
at src/wp-admin/includes/class-wp-filesystem-direct.php:644
688 Parameter #2 $timestamp of function gmdate expects int, int|false
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-direct.php:688
689 Parameter #2 $timestamp of function gmdate expects int, int|false
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-direct.php:689
------ -----------------------------------------------------------------------
------ -----------------------------------------------------------------------
Line class-wp-filesystem-ftpsockets.php
------ -----------------------------------------------------------------------
221 Parameter #2 $str of function explode expects string, string|false
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:221
269 Method WP_Filesystem_ftpsockets::put_contents() should return bool
but returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:269
283 Parameter #1 $value of function trailingslashit expects string, mixed
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:283
286 Method WP_Filesystem_ftpsockets::cwd() should return string|false but
returns 0|0.0|array{}|string|false|null.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:286
298 Method WP_Filesystem_ftpsockets::chdir() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:298
334 Method WP_Filesystem_ftpsockets::chmod() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:334
348 Cannot access offset 'owner' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:348
348 Method WP_Filesystem_ftpsockets::owner() should return string|false
but returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:348
362 Cannot access offset 'permsn' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:362
362 Method WP_Filesystem_ftpsockets::getchmod() should return string but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:362
376 Cannot access offset 'group' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:376
376 Method WP_Filesystem_ftpsockets::group() should return string|false
but returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:376
425 Method WP_Filesystem_ftpsockets::move() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:425
446 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:446
450 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:450
453 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:453
518 Parameter #1 $dir of method WP_Filesystem_ftpsockets::chdir() expects
string, string|false given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:518
570 Method WP_Filesystem_ftpsockets::mtime() should return int|false but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:570
582 Method WP_Filesystem_ftpsockets::size() should return int|false but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:582
686 Method WP_Filesystem_ftpsockets::dirlist() return type has no value
type specified in iterable type array.
🪪 missingType.iterableValue
💡 See:
https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-i
terable-type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:686
708 Argument of an invalid type mixed supplied for foreach, only
iterables are supported.
🪪 foreach.nonIterable
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:708
710 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:710
714 Cannot access offset 0 on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:714
722 Cannot access offset 'type' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:722
724 Binary operation "." between string and mixed results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:724
724 Cannot access offset 'files' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:724
726 Cannot access offset 'files' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:726
731 Cannot access offset 'islink' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:731
732 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:732
732 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:732
732 Parameter #3 $subject of function preg_replace expects array<float|in
t|string>|string, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:732
736 Cannot access offset 'perms' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:736
736 Cannot access offset 'permsn' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:736
736 Parameter #1 $mode of method WP_Filesystem_Base::getnumchmodfromh()
expects string, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:736
738 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:738
738 Possibly invalid array key type mixed.
🪪 offsetAccess.invalidOffset
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:738
------ -----------------------------------------------------------------------
------ -----------------------------------------------------------------------
Line class-wp-filesystem-ssh2.php
------ -----------------------------------------------------------------------
171 Offset 'hostkey' might not exist on array{hostname: non-empty-string,
username?: non-empty-string, password: string|null, port: int<0,
max>, public_key?: non-empty-string, private_key?: non-empty-string,
hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:171
188 Offset 'username' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:188
188 Parameter #3 $password of function ssh2_auth_password expects string,
string|null given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:188
194 Offset 'username' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:194
201 Offset 'private_key' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:201
201 Offset 'public_key' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:201
201 Offset 'username' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:201
201 Parameter #5 $passphrase of function ssh2_auth_pubkey_file expects
string, string|null given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:201
207 Offset 'username' might not exist on array{hostname:
non-empty-string, username?: non-empty-string, password: string|null,
port: int<0, max>, public_key?: non-empty-string, private_key?:
non-empty-string, hostkey?: array{hostkey: non-empty-string}}.
🪪 offsetAccess.notFound
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:207
215 Property WP_Filesystem_SSH2::$sftp_link (resource) does not accept
resource|false.
🪪 assign.propertyType
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:215
356 Method WP_Filesystem_SSH2::cwd() should return string but returns
string|false.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:356
368 Method WP_Filesystem_SSH2::chdir() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:368
388 Method WP_Filesystem_SSH2::chgrp() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:388
388 Parameter #1 $arg of function escapeshellarg expects string,
int|string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:388
391 Method WP_Filesystem_SSH2::chgrp() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:391
391 Parameter #1 $arg of function escapeshellarg expects string,
int|string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:391
422 Method WP_Filesystem_SSH2::chmod() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:422
425 Method WP_Filesystem_SSH2::chmod() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:425
445 Method WP_Filesystem_SSH2::chown() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:445
445 Parameter #1 $arg of function escapeshellarg expects string,
int|string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:445
448 Method WP_Filesystem_SSH2::chown() should return bool but returns
bool|string.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:448
448 Parameter #1 $arg of function escapeshellarg expects string,
int|string given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:448
488 Parameter #1 $decimal_number of function decoct expects int, int<0,
max>|false given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:488
603 Cannot access offset 'type' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:603
603 Parameter #3 $type of method WP_Filesystem_SSH2::delete() expects
string|false, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:603
818 Method WP_Filesystem_SSH2::dirlist() return type has no value type
specified in iterable type array.
🪪 missingType.iterableValue
💡 See:
https://phpstan.org/blog/solving-phpstan-no-value-type-specified-in-i
terable-type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:818
862 Parameter #2 $timestamp of function gmdate expects int, int|false
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:862
863 Parameter #2 $timestamp of function gmdate expects int, int|false
given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ssh2.php:863
------ -----------------------------------------------------------------------
[ERROR] Found 73 errors
@westonruter commented on PR #11593:
5 weeks ago
#5
All rule level 6 errors are now resolved. Note that 459fd6e seems to have fixed a key bug with \WP_Filesystem_Direct::chown() and \WP_Filesystem_Direct::chgrp() where it was attempting to concatenate a directory path with a FileListing array. This issue didn't happen with \WP_Filesystem_Direct::chmod() because it is doing:
foreach ( (array) $filelist as $filename => $filemeta ) { $this->chmod( $file . $filename, $mode, $recursive ); }
As opposed to:
foreach ( $filelist as $filename ) { $this->chgrp( $file . $filename, $group, $recursive ); }
Note the return value of the dirlist() method is array<string, FileListing>|false, so in the case of chmod() it it was using the array keys successfully, but for chgrp() and chown() it was failing to do so. This had been fixed in WordPress 3.0 for chmod() but not for chgrp() and chown(). See bb80851161240500afe6f1bbb5ea8770de085009 (r12997) for Core-11261.
@westonruter commented on PR #11593:
5 weeks ago
#6
All errors up to rule level 9 have been fixed. What remains are the following rule level 10 errors:
------ -----------------------------------------------------------------------
Line class-wp-filesystem-ftpsockets.php
------ -----------------------------------------------------------------------
274 Method WP_Filesystem_ftpsockets::put_contents() should return bool
but returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:274
306 Method WP_Filesystem_ftpsockets::chdir() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:306
342 Method WP_Filesystem_ftpsockets::chmod() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:342
433 Method WP_Filesystem_ftpsockets::move() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:433
454 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:454
458 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:458
461 Method WP_Filesystem_ftpsockets::delete() should return bool but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:461
581 Method WP_Filesystem_ftpsockets::mtime() should return int|false but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:581
593 Method WP_Filesystem_ftpsockets::size() should return int|false but
returns mixed.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:593
720 Argument of an invalid type mixed supplied for foreach, only
iterables are supported.
🪪 foreach.nonIterable
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:720
722 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:722
726 Cannot access offset 0 on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:726
734 Cannot access offset 'type' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:734
736 Binary operation "." between string and mixed results in an error.
🪪 binaryOp.invalid
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:736
736 Cannot access offset 'files' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:736
738 Cannot access offset 'files' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:738
743 Cannot access offset 'islink' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:743
744 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:744
744 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:744
744 Parameter #3 $subject of function preg_replace expects array<float|in
t|string>|string, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:744
748 Cannot access offset 'perms' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:748
748 Cannot access offset 'permsn' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:748
748 Parameter #1 $mode of method WP_Filesystem_Base::getnumchmodfromh()
expects string, mixed given.
🪪 argument.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:748
750 Cannot access offset 'name' on mixed.
🪪 offsetAccess.nonOffsetAccessible
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:750
750 Possibly invalid array key type mixed.
🪪 offsetAccess.invalidOffset
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:750
755 Method WP_Filesystem_ftpsockets::dirlist() should return
array<string, array{name: string, perms?: string, permsn?: string,
number?: int|string|false, owner?: int<1, max>|string|false, group?:
int<1, max>|string|false, size: int|string|false, lastmodunix?:
int|string|false, ...}>|false but returns array.
🪪 return.type
at src/wp-admin/includes/class-wp-filesystem-ftpsockets.php:755
------ -----------------------------------------------------------------------
[ERROR] Found 26 errors
@westonruter commented on PR #11593:
5 weeks ago
#7
And there we have it! All PHPStan rule level 10 errors addressed.
@westonruter commented on PR #11593:
2 weeks ago
#8
@Soean are you happy with this?
@Soean commented on PR #11593:
2 weeks ago
#9
Looks good to me 👍
@westonruter commented on PR #11593:
10 days ago
#10
I've filed Core-65584 to log the defect regarding chown() and chgrp() I mentioned in https://github.com/WordPress/wordpress-develop/pull/11593#issuecomment-4662753003.
@westonruter commented on PR #11593:
10 days ago
#12
I've committed two subsets of this PR separately:
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The constructor parameters of the
WP_Filesystem_FTPextandWP_Filesystem_SSH2classes should be anarraynot an emptystring(''). We also should improve the doc block.Trac ticket: https://core.trac.wordpress.org/ticket/65409