Skip to content

Commit 4d2476f

Browse files
authored
Refactor the flysystem adapter to use private constants (#1495)
1 parent b9d7689 commit 4d2476f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ parameters:
2121
- '#Method AsyncAws\\[^:]+::[^(]+\(\) should return array<[^>]+> but returns array<int(\|string)?, string>\.$#'
2222
- '#PHPDoc tag @throws with type Psr\\Cache\\CacheException is not subtype of Throwable$#'
2323
- '#^Dead catch - JsonException is never thrown in the try block\.$#'
24-
- '#^Unsafe access to private property AsyncAws\\Flysystem\\S3\\AsyncAwsS3Adapter::\$[^ ]+ through static::\.$#'
2524
- '#^Method AsyncAws\\[^\\]+\\Result\\[^ ]+ should return #'
2625
- '#^Parameter \#1 \$input of class AsyncAws\\[^\\]+\\ValueObject\\[^ ]+ constructor expects #'
2726
- '#^Argument 1 of AsyncAws\\Scheduler\\ValueObject\\ScheduleGroupSummary::__construct expects #'

src/Integration/Flysystem/S3/src/AsyncAwsS3Adapter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AsyncAwsS3Adapter extends AbstractAdapter implements CanOverwriteFiles
2323
{
2424
public const PUBLIC_GRANT_URI = 'http://acs.amazonaws.com/groups/global/AllUsers';
2525

26-
private static $resultMap = [
26+
private const RESULT_MAP = [
2727
'Body' => 'contents',
2828
'ContentLength' => 'size',
2929
'ContentType' => 'mimetype',
@@ -34,7 +34,7 @@ class AsyncAwsS3Adapter extends AbstractAdapter implements CanOverwriteFiles
3434
'VersionId' => 'versionid',
3535
];
3636

37-
private static $metaOptions = [
37+
private const META_OPTIONS = [
3838
'ACL',
3939
'CacheControl',
4040
'ContentDisposition',
@@ -496,7 +496,7 @@ protected function getOptionsFromConfig(Config $config): array
496496
$options['ContentType'] = $mimetype;
497497
}
498498

499-
foreach (static::$metaOptions as $option) {
499+
foreach (self::META_OPTIONS as $option) {
500500
if (!$config->has($option)) {
501501
continue;
502502
}
@@ -537,9 +537,9 @@ protected function normalizeResponse(object $output, ?string $path = null): arra
537537
}
538538
}
539539

540-
if ($this->isOnlyDir($result['path'])) {
540+
if ($this->isOnlyDir($path)) {
541541
$result['type'] = 'dir';
542-
$result['path'] = rtrim($result['path'], '/');
542+
$result['path'] = rtrim($path, '/');
543543

544544
return $result;
545545
}
@@ -571,7 +571,7 @@ private function isOnlyDir(string $path): bool
571571
private function resultMap(object $object): array
572572
{
573573
$result = [];
574-
foreach (static::$resultMap as $from => $to) {
574+
foreach (self::RESULT_MAP as $from => $to) {
575575
$methodName = 'get' . $from;
576576
if (method_exists($object, $methodName)) {
577577
$result[$to] = \call_user_func([$object, $methodName]);

0 commit comments

Comments
 (0)