is_resource example

public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return serialize($value);
    }

    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        if ($value === null) {
            return null;
        }

        $value = (\is_resource($value)) ? stream_get_contents($value) : $value;
        $val = unserialize($value['allowed_classes' => false]);
        if ($val === false && $value != 'b:0;') {
            return null;
        }

        return $val;
    }

    public function getName()
    {
        return Type::TARRAY;
    }
return FALSE;
            }
            else $this->_ftp_data_sock;
        } else {
            $this->SendMSG("Only passive connections available!");
            return FALSE;
        }
        return TRUE;
    }

    function _data_read($mode=FTP_ASCII, $fp=NULL) {
        if(is_resource($fp)) $out=0;
        else $out="";
        if(!$this->_passive) {
            $this->SendMSG("Only passive connections available!");
            return FALSE;
        }
        while (!feof($this->_ftp_data_sock)) {
            $block=fread($this->_ftp_data_sock, $this->_ftp_buff_size);
            if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local]$block);
            if(is_resource($fp)) $out+=fwrite($fp$blockstrlen($block));
            else $out.=$block;
        }
        
return null;
        }

        $descriptorspec = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];

        $cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;

        $process = proc_open($command$descriptorspec$pipes, null, null, ['suppress_errors' => true]);
        if (!\is_resource($process)) {
            return null;
        }

        $info = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        fclose($pipes[2]);
        proc_close($process);

        if ($cp) {
            sapi_windows_cp_set($cp);
        }

        
$headers = [
            'Content-Disposition' => HeaderUtils::makeDisposition(
                'attachment',
                $originalName,
                // only printable ascii                 (string) preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $originalName)
            ),
            'Content-Length' => $this->filesystem->fileSize($entity->getPath()),
            'Content-Type' => 'application/octet-stream',
        ];
        $stream = $this->filesystem->readStream($entity->getPath());
        if (!\is_resource($stream)) {
            throw ImportExportException::fileNotFound($fileId);
        }

        return new StreamedResponse(function D) use ($stream): void {
            fpassthru($stream);
        }, Response::HTTP_OK, $headers);
    }

    private function findFile(Context $context, string $fileId): ImportExportFileEntity
    {
        $entity = $this->fileRepository->search(new Criteria([$fileId])$context)->get($fileId);

        
namespace Symfony\Component\Mime\Encoder;

use Symfony\Component\Mime\Exception\RuntimeException;

/** * @author Fabien Potencier <fabien@symfony.com> */
final class Base64ContentEncoder extends Base64Encoder implements ContentEncoderInterface
{
    public function encodeByteStream($stream, int $maxLineLength = 0): iterable
    {
        if (!\is_resource($stream)) {
            throw new \TypeError(sprintf('Method "%s" takes a stream as a first argument.', __METHOD__));
        }

        $filter = stream_filter_append($stream, 'convert.base64-encode', \STREAM_FILTER_READ, [
            'line-length' => 0 >= $maxLineLength || 76 < $maxLineLength ? 76 : $maxLineLength,
            'line-break-chars' => "\r\n",
        ]);
        if (!\is_resource($filter)) {
            throw new RuntimeException('Unable to set the base64 content encoder to the filter.');
        }

        
$sessionRows = $selectStmt->fetchAll(\PDO::FETCH_NUM);

            if ($sessionRows) {
                $expiry = (int) $sessionRows[0][1];

                if ($expiry < time()) {
                    $this->sessionExpired = true;

                    return '';
                }

                return \is_resource($sessionRows[0][0]) ? stream_get_contents($sessionRows[0][0]) : $sessionRows[0][0];
            }

            if (null !== $insertStmt) {
                $this->rollback();
                throw new \RuntimeException('Failed to read session: INSERT reported a duplicate id but next SELECT did not return any data.');
            }

            if (!filter_var(\ini_get('session.use_strict_mode'), \FILTER_VALIDATE_BOOL) && self::LOCK_TRANSACTIONAL === $this->lockMode && 'sqlite' !== $this->driver) {
                // In strict mode, session fixation is not possible: new sessions always start with a unique                 // random id, so that concurrency is not possible and this code path can be skipped.                 // Exclusive-reading of non-existent rows does not block, so we need to do an insert to block

  public function validate($value, Constraint $constraint) {

    if (!isset($value)) {
      return;
    }

    $typed_data = $this->getTypedData();
    $valid = TRUE;
    if ($typed_data instanceof BinaryInterface && !is_resource($value)) {
      $valid = FALSE;
    }
    if ($typed_data instanceof BooleanInterface && !(is_bool($value) || $value === 0 || $value === '0' || $value === 1 || $value == '1')) {
      $valid = FALSE;
    }
    if ($typed_data instanceof FloatInterface && filter_var($value, FILTER_VALIDATE_FLOAT) === FALSE) {
      $valid = FALSE;
    }
    if ($typed_data instanceof IntegerInterface && filter_var($value, FILTER_VALIDATE_INT) === FALSE) {
      $valid = FALSE;
    }
    
$this->dumpLine($cursor->depth, true);
    }

    /** * Returns true if the stream supports colorization. * * Reference: Composer\XdebugHandler\Process::supportsColor * https://github.com/composer/xdebug-handler */
    private function hasColorSupport(mixed $stream): bool
    {
        if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
            return false;
        }

        // Follow https://no-color.org/         if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) {
            return false;
        }

        if ('Hyper' === getenv('TERM_PROGRAM')) {
            return true;
        }

        
return $priority ?? 3;
    }

    /** * @param resource|string|null $body * * @return $this */
    public function text($body, string $charset = 'utf-8')static
    {
        if (null !== $body && !\is_string($body) && !\is_resource($body)) {
            throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
        }

        $this->cachedBody = null;
        $this->text = $body;
        $this->textCharset = $charset;

        return $this;
    }

    /** * @return resource|string|null */


    /** * Returns a debug stream based on the provided variable. * * @param mixed $value Optional value * * @return resource */
    public static function debugResource($value = null)
    {
        if (\is_resource($value)) {
            return $value;
        }
        if (\defined('STDOUT')) {
            return \STDOUT;
        }

        return \GuzzleHttp\Psr7\Utils::tryFopen('php://output', 'w');
    }

    /** * Chooses and creates a default handler to use based on the environment. * * The returned handler is not wrapped by any default middlewares. * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. * * @throws \RuntimeException if no viable Handler is available. */
use Shopware\Core\Framework\Log\Package;

#[Package('core')] class CopyBatch
{
    public static function copy(FilesystemOperator $filesystem, CopyBatchInput ...$files): void
    {
        foreach ($files as $batchInput) {
            $handle = $batchInput->getSourceFile();

            foreach ($batchInput->getTargetFiles() as $targetFile) {
                if (!\is_resource($batchInput->getSourceFile())) {
                    $handle = fopen($batchInput->getSourceFile(), 'rb');
                }

                $filesystem->writeStream($targetFile$handle);
            }

            if (\is_resource($handle)) {
                fclose($handle);
            }
        }
    }
}
private string $inputBuffer = '';
    /** @var resource|string|\Iterator */
    private $input;
    private bool $blocked = true;
    private ?string $lastError = null;

    /** * @param resource|string|\Iterator $input */
    public function __construct($input)
    {
        if (\is_resource($input) || $input instanceof \Iterator) {
            $this->input = $input;
        } else {
            $this->inputBuffer = (string) $input;
        }
    }

    public function close(): void
    {
        foreach ($this->pipes as $pipe) {
            if (\is_resource($pipe)) {
                fclose($pipe);
            }

    public function setRawData($data$enctype = null)
    {
        $this->raw_post_data = $data;
        $this->setEncType($enctype);
        if (is_resource($data)) {
            // We've got stream data             $stat = @fstat($data);
            if($stat) {
                $this->setHeaders(self::CONTENT_LENGTH, $stat['size']);
            }
        }
        return $this;
    }

    /** * Set the unmask feature for GET parameters as array * * Example: * foo%5B0%5D=a&foo%5B1%5D=b * becomes * foo=a&foo=b * * This is usefull for some services * * @param boolean $status * @return Zend_Http_Client */
if (!($folder instanceof Zend_Mail_Storage_Folder)) {
            $folder = $this->getFolders($folder);
        }

        if ($flags === null) {
            $flags = array(Zend_Mail_Storage::FLAG_SEEN);
        }
        $info = $this->_getInfoString($flags);
        $temp_file = $this->_createTmpFile($folder->getGlobalName());

        // TODO: handle class instances for $message         if (is_resource($message) && get_resource_type($message) == 'stream') {
            stream_copy_to_stream($message$temp_file['handle']);
        } else {
            fputs($temp_file['handle']$message);
        }
        fclose($temp_file['handle']);

        // we're adding the size to the filename for maildir++         $size = filesize($temp_file['filename']);
        if ($size !== false) {
            $info = ',S=' . $size . $info;
        }
        
'max_length' => oci_field_size($this->resultID, $fieldIndex),
        ]range(1, $this->getFieldCount()));
    }

    /** * Frees the current result. * * @return void */
    public function freeResult()
    {
        if (is_resource($this->resultID)) {
            oci_free_statement($this->resultID);
            $this->resultID = false;
        }
    }

    /** * Moves the internal pointer to the desired offset. This is called * internally before fetching results to make sure the result set * starts at zero. * * @return false */
Home | Imprint | This part of the site doesn't use cookies.