Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8
Get the last occurred error
<?php error_get_last(): ?array
<?php         $mode = $this->visibilityConverter->forFile($visibility);



        if ( ! @ftp_chmod($this->connection(), $mode, $location)) {

            $message = error_get_last()['message'];

            throw UnableToSetVisibility::atLocation($path, $message);

        }

    }
<?php         $object = @ftp_raw($this->connection(), 'STAT ' . $location);



        if (empty($object) || count($object) < 3 || substr($object[1], 0, 5) === "ftpd:") {

            throw UnableToRetrieveMetadata::create($path, $type, error_get_last()['message'] ?? '');

        }



        $attributes = $this->normalizeObject($object[1], '');
<?php         $fileSize = @ftp_size($connection, $location);



        if ($fileSize < 0) {

            throw UnableToRetrieveMetadata::fileSize($path, error_get_last()['message'] ?? '');

        }



        return new FileAttributes($path, $fileSize);
<?php             $result = @ftp_mkdir($connection, $location);



            if ($result === false) {

                $errorMessage = error_get_last()['message'] ?? 'unable to create the directory';

                throw UnableToCreateDirectory::atLocation($dirPath, $errorMessage);

            }
<?php         error_clear_last();



        if (($size = @file_put_contents($prefixedLocation, $contents, $this->writeFlags)) === false) {

            throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? '');

        }



        if ($visibility = $config->get(Config::OPTION_VISIBILITY)) {
<?php         $stream = @fopen($prefixedLocation, 'w+b');



        if ( ! ($stream && false !== stream_copy_to_stream($contents, $stream) && fclose($stream))) {

            $reason = error_get_last()['message'] ?? '';

            throw UnableToWriteFile::atLocation($prefixedLocation, $reason);

        }
<?php         error_clear_last();



        if ( ! @unlink($location)) {

            throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? '');

        }

    }
<?php         unset($contents);



        if ( ! @rmdir($location)) {

            throw UnableToDeleteDirectory::atLocation($prefix, error_get_last()['message'] ?? '');

        }

    }
<?php         $contents = @file_get_contents($location);



        if ($contents === false) {

            throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? '');

        }



        return $contents;
<?php         $contents = @fopen($location, 'rb');



        if ($contents === false) {

            throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? '');

        }



        return $contents;
<?php         error_clear_last();



        if ( ! @mkdir($dirname, $visibility, true)) {

            $mkdirError = error_get_last();

        }



        clearstatcache(false, $dirname);
<?php         error_clear_last();



        if ( ! @mkdir($location, $permissions, true)) {

            throw UnableToCreateDirectory::atLocation($path, error_get_last()['message'] ?? '');

        }

    }
<?php         $fileperms = @fileperms($location);



        if ($fileperms === false) {

            throw UnableToRetrieveMetadata::visibility($path, error_get_last()['message'] ?? '');

        }



        $permissions = $fileperms & 0777;
<?php         $mimeType = $this->mimeTypeDetector->detectMimeTypeFromFile($location);



        if ($mimeType === null) {

            throw UnableToRetrieveMetadata::mimeType($path, error_get_last()['message'] ?? '');

        }



        return new FileAttributes($path, null, null, null, $mimeType);
<?php         $lastModified = @filemtime($location);



        if ($lastModified === false) {

            throw UnableToRetrieveMetadata::lastModified($path, error_get_last()['message'] ?? '');

        }



        return new FileAttributes($path, null, null, $lastModified);