2525 * Driver for AWS S3 IO operations.
2626 *
2727 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
28+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2829 */
2930class AwsS3 implements RemoteDriverInterface
3031{
@@ -258,6 +259,7 @@ public function filePutContents($path, $content, $mode = null): int
258259 $ path = $ this ->normalizeRelativePath ($ path , true );
259260 $ config = self ::CONFIG ;
260261
262+ // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
261263 if (false !== ($ imageSize = @getimagesizefromstring ($ content ))) {
262264 $ config ['Metadata ' ] = [
263265 'image-width ' => $ imageSize [0 ],
@@ -489,8 +491,7 @@ public function getRelativePath($basePath, $path = null): string
489491 $ basePath = (string )$ basePath ;
490492 $ path = (string )$ path ;
491493
492- if (
493- ($ basePath && $ path )
494+ if ($ basePath && $ path
494495 && ($ basePath === $ path . '/ ' || strpos ($ path , $ basePath ) === 0 )
495496 ) {
496497 $ result = substr ($ path , strlen ($ basePath ));
@@ -723,6 +724,7 @@ public function fileGetCsv($resource, $length = 0, $delimiter = ',', $enclosure
723724 */
724725 public function fileTell ($ resource ): int
725726 {
727+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
726728 $ result = @ftell ($ resource );
727729 if ($ result === null ) {
728730 throw new FileSystemException (
@@ -738,6 +740,7 @@ public function fileTell($resource): int
738740 */
739741 public function fileSeek ($ resource , $ offset , $ whence = SEEK_SET ): int
740742 {
743+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
741744 $ result = @fseek ($ resource , $ offset , $ whence );
742745 if ($ result === -1 ) {
743746 throw new FileSystemException (
@@ -756,6 +759,7 @@ public function fileSeek($resource, $offset, $whence = SEEK_SET): int
756759 */
757760 public function endOfFile ($ resource ): bool
758761 {
762+ // phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
759763 return feof ($ resource );
760764 }
761765
@@ -773,6 +777,7 @@ public function filePutCsv($resource, array $data, $delimiter = ',', $enclosure
773777 */
774778 public function fileFlush ($ resource ): bool
775779 {
780+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
776781 $ result = @fflush ($ resource );
777782 if (!$ result ) {
778783 throw new FileSystemException (
@@ -791,6 +796,7 @@ public function fileFlush($resource): bool
791796 */
792797 public function fileLock ($ resource , $ lockMode = LOCK_EX ): bool
793798 {
799+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
794800 $ result = @flock ($ resource , $ lockMode );
795801 if (!$ result ) {
796802 throw new FileSystemException (
@@ -809,6 +815,7 @@ public function fileLock($resource, $lockMode = LOCK_EX): bool
809815 */
810816 public function fileUnlock ($ resource ): bool
811817 {
818+ // phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
812819 $ result = @flock ($ resource , LOCK_UN );
813820 if (!$ result ) {
814821 throw new FileSystemException (
@@ -852,13 +859,14 @@ public function fileClose($resource): bool
852859 //phpcs:enable
853860
854861 foreach ($ this ->streams as $ path => $ stream ) {
855- // phpcs:ignore Magento2.Functions.DiscouragedFunction
862+ // phpcs:ignore
856863 if (stream_get_meta_data ($ stream )['uri ' ] === $ resourcePath ) {
857864 $ this ->adapter ->writeStream ($ path , $ resource , new Config (self ::CONFIG ));
858865
859866 // Remove path from streams after
860867 unset($ this ->streams [$ path ]);
861868
869+ // phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
862870 return fclose ($ stream );
863871 }
864872 }
@@ -932,6 +940,7 @@ private function readPath(string $path, $isRecursive = false): array
932940 if (!empty ($ path )
933941 && $ path !== $ relativePath
934942 && (!$ relativePath || strpos ($ path , $ relativePath ) === 0 )) {
943+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
935944 $ itemsList [] = $ this ->getAbsolutePath (dirname ($ path ), $ path );
936945 }
937946 }
0 commit comments