25
25
* Driver for AWS S3 IO operations.
26
26
*
27
27
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
28
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
28
29
*/
29
30
class AwsS3 implements RemoteDriverInterface
30
31
{
@@ -258,6 +259,7 @@ public function filePutContents($path, $content, $mode = null): int
258
259
$ path = $ this ->normalizeRelativePath ($ path , true );
259
260
$ config = self ::CONFIG ;
260
261
262
+ // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
261
263
if (false !== ($ imageSize = @getimagesizefromstring ($ content ))) {
262
264
$ config ['Metadata ' ] = [
263
265
'image-width ' => $ imageSize [0 ],
@@ -489,8 +491,7 @@ public function getRelativePath($basePath, $path = null): string
489
491
$ basePath = (string )$ basePath ;
490
492
$ path = (string )$ path ;
491
493
492
- if (
493
- ($ basePath && $ path )
494
+ if ($ basePath && $ path
494
495
&& ($ basePath === $ path . '/ ' || strpos ($ path , $ basePath ) === 0 )
495
496
) {
496
497
$ result = substr ($ path , strlen ($ basePath ));
@@ -723,6 +724,7 @@ public function fileGetCsv($resource, $length = 0, $delimiter = ',', $enclosure
723
724
*/
724
725
public function fileTell ($ resource ): int
725
726
{
727
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
726
728
$ result = @ftell ($ resource );
727
729
if ($ result === null ) {
728
730
throw new FileSystemException (
@@ -738,6 +740,7 @@ public function fileTell($resource): int
738
740
*/
739
741
public function fileSeek ($ resource , $ offset , $ whence = SEEK_SET ): int
740
742
{
743
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
741
744
$ result = @fseek ($ resource , $ offset , $ whence );
742
745
if ($ result === -1 ) {
743
746
throw new FileSystemException (
@@ -756,6 +759,7 @@ public function fileSeek($resource, $offset, $whence = SEEK_SET): int
756
759
*/
757
760
public function endOfFile ($ resource ): bool
758
761
{
762
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
759
763
return feof ($ resource );
760
764
}
761
765
@@ -773,6 +777,7 @@ public function filePutCsv($resource, array $data, $delimiter = ',', $enclosure
773
777
*/
774
778
public function fileFlush ($ resource ): bool
775
779
{
780
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
776
781
$ result = @fflush ($ resource );
777
782
if (!$ result ) {
778
783
throw new FileSystemException (
@@ -791,6 +796,7 @@ public function fileFlush($resource): bool
791
796
*/
792
797
public function fileLock ($ resource , $ lockMode = LOCK_EX ): bool
793
798
{
799
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
794
800
$ result = @flock ($ resource , $ lockMode );
795
801
if (!$ result ) {
796
802
throw new FileSystemException (
@@ -809,6 +815,7 @@ public function fileLock($resource, $lockMode = LOCK_EX): bool
809
815
*/
810
816
public function fileUnlock ($ resource ): bool
811
817
{
818
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
812
819
$ result = @flock ($ resource , LOCK_UN );
813
820
if (!$ result ) {
814
821
throw new FileSystemException (
@@ -852,13 +859,14 @@ public function fileClose($resource): bool
852
859
//phpcs:enable
853
860
854
861
foreach ($ this ->streams as $ path => $ stream ) {
855
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
862
+ // phpcs:ignore
856
863
if (stream_get_meta_data ($ stream )['uri ' ] === $ resourcePath ) {
857
864
$ this ->adapter ->writeStream ($ path , $ resource , new Config (self ::CONFIG ));
858
865
859
866
// Remove path from streams after
860
867
unset($ this ->streams [$ path ]);
861
868
869
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
862
870
return fclose ($ stream );
863
871
}
864
872
}
@@ -932,6 +940,7 @@ private function readPath(string $path, $isRecursive = false): array
932
940
if (!empty ($ path )
933
941
&& $ path !== $ relativePath
934
942
&& (!$ relativePath || strpos ($ path , $ relativePath ) === 0 )) {
943
+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
935
944
$ itemsList [] = $ this ->getAbsolutePath (dirname ($ path ), $ path );
936
945
}
937
946
}
0 commit comments