Skip to content

Commit 5ae6d5f

Browse files
Fixing tests and phpcs
1 parent 26b8e44 commit 5ae6d5f

File tree

9 files changed

+44
-31
lines changed

9 files changed

+44
-31
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
php-version: ['7.4', '8.0']
12+
php-version: ['7.4', '8.0', '8.1']
1313

1414
steps:
1515
- uses: actions/checkout@v1

composer.json

+2-10
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
"ext-fileinfo": "*",
1616
"ext-json": "*",
1717
"ext-mbstring": "*",
18-
"phauthentic/file-storage-factories": "dev-develop",
18+
"phauthentic/file-storage-factories": "^1.0",
1919
"psr/http-message": "^1.0"
2020
},
2121
"require-dev": {
22-
"instituteweb/composer-scripts": "^1.1",
23-
"phauthentic/file-storage-image-processor": "dev-develop"
22+
"phauthentic/file-storage-image-processor": "^1.0"
2423
},
2524
"suggest": {
2625
"phauthentic/file-storage-image-processor": "For image processing"
@@ -50,31 +49,24 @@
5049
"php config/composer_post_install.php"
5150
],
5251
"test": [
53-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
5452
"phpunit"
5553
],
5654
"test-coverage": [
57-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
5855
"phpunit --coverage-text"
5956
],
6057
"test-coverage-html": [
61-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
6258
"phpunit --coverage-html tmp/coverage/"
6359
],
6460
"cscheck": [
65-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
6661
"phpcs src/ tests/ --standard=phpcs.xml -s"
6762
],
6863
"csfix": [
69-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
7064
"phpcbf src/ tests/ --standard=phpcs.xml"
7165
],
7266
"analyze": [
73-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
7467
"phpstan analyse src/"
7568
],
7669
"phive": [
77-
"\\InstituteWeb\\ComposerScripts\\ImprovedScriptExecution::apply",
7870
"php config/composer_phive.php"
7971
]
8072
}

phive.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<phar url="https://some.tld/tool.phar" />
2828
<phar url="someone/somerepo" />
2929
-->
30-
<phar name="phpunit" version="^9.4" installed="9.4.0" location="./bin/phpunit" copy="true"/>
31-
<phar name="phpstan" version="^0.12.53" installed="0.12.53" location="./bin/phpstan" copy="true"/>
30+
<phar name="phpunit" version="^9.5" installed="9.5.21" location="./bin/phpunit" copy="true"/>
31+
<phar name="phpstan" version="^1.8.10" installed="1.8.10" location="./bin/phpstan" copy="true"/>
3232
<phar name="phpcs" version="^3.5.8" installed="3.5.8" location="./bin/phpcs" copy="true"/>
3333
<phar name="phpcbf" version="^3.5.8" installed="3.5.8" location="./bin/phpcbf" copy="true"/>
3434
<phar name="grumphp" version="^0.19.1" installed="0.19.1" location="./bin/grumphp" copy="true"/>

src/AdapterCollection.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace Phauthentic\Infrastructure\Storage;
1818

19+
use Iterator;
1920
use League\Flysystem\AdapterInterface;
2021
use ArrayIterator;
2122
use RuntimeException;
@@ -119,7 +120,7 @@ public function getNameToClassmap(): array
119120
/**
120121
* @inheritDoc
121122
*/
122-
public function getIterator()
123+
public function getIterator(): Iterator
123124
{
124125
return new ArrayIterator($this->adapters);
125126
}

src/File.php

+30-10
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,9 @@ public function withMetadata(array $metadata, bool $overwrite = false): FileInte
425425
}
426426

427427
/**
428-
* @param string $name Name
429-
* @param mixed $data Data
430-
* @return \Phauthentic\Infrastructure\Storage\FileInterface
428+
* @inheritDoc
431429
*/
432-
public function withMetadataKey(string $name, $data): FileInterface
430+
public function withMetadataByKey(string $name, $data): FileInterface
433431
{
434432
$that = clone $this;
435433
$that->metadata[$name] = $data;
@@ -438,10 +436,9 @@ public function withMetadataKey(string $name, $data): FileInterface
438436
}
439437

440438
/**
441-
* @param string $name Name
442-
* @return \Phauthentic\Infrastructure\Storage\FileInterface
439+
* @inheritDoc
443440
*/
444-
public function withoutMetadataKey(string $name): FileInterface
441+
public function withoutMetadataByKey(string $name): FileInterface
445442
{
446443
$that = clone $this;
447444
unset($that->metadata[$name]);
@@ -450,7 +447,7 @@ public function withoutMetadataKey(string $name): FileInterface
450447
}
451448

452449
/**
453-
* @return $this
450+
* @inheritDoc
454451
*/
455452
public function withoutMetadata(): self
456453
{
@@ -461,7 +458,7 @@ public function withoutMetadata(): self
461458
}
462459

463460
/**
464-
* @return array
461+
* @inheritDoc
465462
*/
466463
public function metadata(): array
467464
{
@@ -540,6 +537,29 @@ public function variantPaths(): array
540537
return $paths;
541538
}
542539

540+
/**
541+
* @param string $key
542+
* @param mixed $data;
543+
*/
544+
public function withMetadataKey(string $key, $data): FileInterface
545+
{
546+
$that = clone $this;
547+
$that->metadata[$key] = $data;
548+
549+
return $that;
550+
}
551+
552+
/**
553+
* @inheritDoc
554+
*/
555+
public function withoutMetadataKey(string $key): FileInterface
556+
{
557+
$that = clone $this;
558+
unset($that->metadata[$key]);
559+
560+
return $that;
561+
}
562+
543563
/**
544564
* Sets many variants at once
545565
*
@@ -612,7 +632,7 @@ public function toArray(): array
612632
/**
613633
* @inheritDoc
614634
*/
615-
public function jsonSerialize()
635+
public function jsonSerialize(): array
616636
{
617637
return $this->toArray();
618638
}

src/FileInterface.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function modelId(): ?string;
7070
/**
7171
* Gets the metadata array
7272
*
73-
* @return array
73+
* @return array<mixed, mixed>
7474
*/
7575
public function metadata(): array;
7676

@@ -157,7 +157,8 @@ public function toArray(): array;
157157
/**
158158
* Adds (replaces) the existing metadata
159159
*
160-
* @param array $metadata Metadata
160+
* @param array<mixed, mixed> $metadata Metadata
161+
* @param bool $overwrite
161162
* @return \Phauthentic\Infrastructure\Storage\FileInterface
162163
*/
163164
public function withMetadata(array $metadata, bool $overwrite = false): FileInterface;
@@ -176,14 +177,14 @@ public function withoutMetadata(): FileInterface;
176177
* @param mixed $data
177178
* @return \Phauthentic\Infrastructure\Storage\FileInterface
178179
*/
179-
public function withMetadataKey(string $key, $data): FileInterface;
180+
public function withMetadataByKey(string $key, $data): FileInterface;
180181

181182
/**
182183
* Removes a key from the metadata array
183184
* @param string $name Name
184185
* @return \Phauthentic\Infrastructure\Storage\FileInterface
185186
*/
186-
public function withoutMetadataKey(string $name): FileInterface;
187+
public function withoutMetadataByKey(string $name): FileInterface;
187188

188189
/**
189190
* Stream resource of the file to be stored

tests/TestCase/FileFactoryTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use GuzzleHttp\Psr7\LazyOpenStream;
2020
use Phauthentic\Infrastructure\Storage\FileFactory;
2121
use Phauthentic\Infrastructure\Storage\FileInterface;
22-
use Psr\Http\Message\StreamInterface;
2322
use Psr\Http\Message\UploadedFileInterface;
2423
use RuntimeException;
2524

tests/TestCase/FileStorageTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testFileStorage(): void
5858
$file = FileFactory::fromDisk($fileOnDisk, 'local')
5959
->withUuid('914e1512-9153-4253-a81e-7ee2edc1d973')
6060
->belongsToModel('User', '1')
61-
->withMetadataKey('bar', 'foo');
61+
->withMetadataByKey('bar', 'foo');
6262

6363
$file = $fileStorage->store($file);
6464

tests/TestCase/FileTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testFile(): void
6666
'one' => 'two',
6767
'two' => 'one'
6868
])
69-
->withMetadataKey('bar', 'foo');
69+
->withMetadataByKey('bar', 'foo');
7070

7171
$file = $file->buildPath($pathBuilder);
7272

0 commit comments

Comments
 (0)