Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Finds whether a variable is a resource
<?php is_resource(mixed $value): bool
<?php             $adapter = $this->adapter();



            $adapter->writeStream('path.txt', $writeStream, new Config());

            if (is_resource($writeStream)) {

                fclose($writeStream);

            };

            $readStream = $adapter->readStream('path.txt');
<?php     private function assertIsResource($contents): void

    {

        if (is_resource($contents) === false) {

            throw new InvalidStreamProvided(

                "Invalid stream provided, expected stream resource, received " . gettype($contents)

            );
<?php     public function __destruct()

    {

        if (is_resource($this->connection)) {

            @ftp_close($this->connection);

        }

        $this->connection = false;
<?php     private function connection()

    {

        start:

        if ( ! is_resource($this->connection)) {

            $this->connection = $this->connectionProvider->createConnection($this->connectionOptions);

        }
<?php             rewind($writeStream);

            $this->writeStream($path, $writeStream, $config);

        } finally {

            isset($writeStream) && is_resource($writeStream) && fclose($writeStream);

        }

    }
<?php             $visibility = $this->visibility($source)->visibility();

            $this->writeStream($destination, $readStream, new Config(compact('visibility')));

        } catch (Throwable $exception) {

            if (isset($readStream) && is_resource($readStream)) {

                @fclose($readStream);

            }

            throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
<?php         }




        if ( ! is_resource($stream)) {

            throw UnableToReadFile::fromLocation($path, 'Downloaded object does not contain a file resource.');

        }
<?php             $stream = stream_with_contents('something');

            (new LocalFilesystemAdapter('/'))->writeStream('/cannot-create-a-file-here', $stream, new Config());

        } finally {

            isset($stream) && is_resource($stream) && fclose($stream);

        }

    }
<?php         try {

            $this->mountManager->writeStream('first://file.txt', $handle);

        } finally {

            is_resource($handle) && fclose($handle);

        }

    }
<?php             $visibility = $this->visibility($source)->visibility();

            $this->writeStream($destination, $readStream, new Config(compact('visibility')));

        } catch (Throwable $exception) {

            if (isset($readStream) && is_resource($readStream)) {

                @fclose($readStream);

            }

            throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
<?php             $visibility = $this->visibility($source)->visibility();

            $this->writeStream($destination, $readStream, new Config(compact('visibility')));

        } catch (Throwable $exception) {

            if (isset($readStream) && is_resource($readStream)) {

                @fclose($readStream);

            }

            throw UnableToCopyFile::fromLocationTo($source, $destination, $exception);
<?php         $this->runScenario(function () {

            $handle = stream_with_contents('contents');

            $this->adapter()->writeStream('some/path.txt', $handle, new Config([Config::OPTION_VISIBILITY => Visibility::PUBLIC]));

            is_resource($handle) && @fclose($handle);

        });

    }