isReadable example

/** * Sets an attribute and apply the name converter if necessary. */
    private function updateData(array $data, string $attribute, mixed $attributeValue, string $class, ?string $format, array $context, ?array $attributesMetadata, ?ClassMetadataInterface $classMetadata): array
    {
        if (null === $attributeValue && ($context[self::SKIP_NULL_VALUES] ?? $this->defaultContext[self::SKIP_NULL_VALUES] ?? false)) {
            return $data;
        }

        if (null !== $classMetadata && null !== $serializedPath = ($attributesMetadata[$attribute] ?? null)?->getSerializedPath()) {
            $propertyAccessor = PropertyAccess::createPropertyAccessor();
            if ($propertyAccessor->isReadable($data$serializedPath) && null !== $propertyAccessor->getValue($data$serializedPath)) {
                throw new LogicException(sprintf('The element you are trying to set is already populated: "%s".', (string) $serializedPath));
            }
            $propertyAccessor->setValue($data$serializedPath$attributeValue);

            return $data;
        }

        if ($this->nameConverter) {
            $attribute = $this->nameConverter->normalize($attribute$class$format$context);
        }

        
if (['-'] === $filenames) {
            return $this->display($io[$this->validate(file_get_contents('php://stdin'))]);
        }

        if (!$filenames) {
            throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
        }

        $filesInfo = [];
        foreach ($filenames as $filename) {
            if (!$this->isReadable($filename)) {
                throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
            }

            foreach ($this->getFiles($filename) as $file) {
                $filesInfo[] = $this->validate(file_get_contents($file)$file);
            }
        }

        return $this->display($io$filesInfo);
    }

    

    public static function is($value$classBaseName, array $args = array()$namespaces = array())
    {
        $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('Zend_Validate'));
        $className  = ucfirst($classBaseName);
        try {
            if (!class_exists($className, false)) {
                foreach($namespaces as $namespace) {
                    $class = $namespace . '_' . $className;
                    $file  = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
                    if (Zend_Loader::isReadable($file)) {
                        Zend_Loader::loadClass($class);
                        $className = $class;
                        break;
                    }
                }
            }

            $class = new ReflectionClass($className);
            if ($class->implementsInterface('Zend_Validate_Interface')) {
                if ($class->hasMethod('__construct')) {
                    $keys    = array_keys($args);
                    
/** * Renames a file or a directory. * * @return void * * @throws IOException When target file or directory already exists * @throws IOException When origin cannot be renamed */
    public function rename(string $origin, string $target, bool $overwrite = false)
    {
        // we check that target does not exist         if (!$overwrite && $this->isReadable($target)) {
            throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
        }

        if (!self::box('rename', $origin$target)) {
            if (is_dir($origin)) {
                // See https://bugs.php.net/54097 & https://php.net/rename#113943                 $this->mirror($origin$target, null, ['override' => $overwrite, 'delete' => $overwrite]);
                $this->remove($origin);

                return;
            }
            
$caller = $this->getTestMethodCaller();
              $html_output = 'Called from ' . $caller['function'] . ' line ' . $caller['line'];
              $html_output .= '<hr />' . $request->getMethod() . ' request to: ' . $request->getUri();

              /** @var \Psr\Http\Message\StreamInterface $stream */
              $stream = $response->getBody();

              // Get the response body as a string. The response stream is set               // to the sink, which defaults to a readable temp stream but can               // be overridden by setting $options['sink'].               $body = $stream->isReadable()
                ? (string) $stream
                : 'Response is not readable.';

              // On redirect responses (status code starting with '3') we need               // to remove the meta tag that would do a browser refresh. We               // don't want to redirect developers away when they look at the               // debug output file in their browser.               $status_code = (string) $response->getStatusCode();
              if ($status_code[0] === '3') {
                $body = preg_replace('#<meta http-equiv="refresh" content=.+/>#', '', $body, 1);
              }
              
public function mapDataToForms(mixed $data, \Traversable $forms): void
    {
        $empty = null === $data || [] === $data;

        if (!$empty && !\is_array($data) && !\is_object($data)) {
            throw new UnexpectedTypeException($data, 'object, array or empty');
        }

        foreach ($forms as $form) {
            $config = $form->getConfig();

            if (!$empty && $config->getMapped() && $this->dataAccessor->isReadable($data$form)) {
                $form->setData($this->dataAccessor->getValue($data$form));
            } else {
                $form->setData($config->getData());
            }
        }
    }

    public function mapFormsToData(\Traversable $forms, mixed &$data): void
    {
        if (null === $data) {
            return;
        }
'file' => 'isFile',
            'dir' => 'isDir',
            'link' => 'isLink',
            'linkTarget' => 'getLinkTarget',
        ];

        $prefix = Caster::PREFIX_VIRTUAL;
        unset($a["\0SplFileInfo\0fileName"]);
        unset($a["\0SplFileInfo\0pathName"]);

        try {
            $c->isReadable();
        } catch (\RuntimeException $e) {
            if ('Object not initialized' !== $e->getMessage()) {
                throw $e;
            }

            $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state';

            return $a;
        } catch (\Error $e) {
            if ('Object not initialized' !== $e->getMessage()) {
                throw $e;
            }

        return $this->stream->eof();
    }

    public function tell(): int
    {
        return $this->stream->tell();
    }

    public function isReadable(): bool
    {
        return $this->stream->isReadable();
    }

    public function isWritable(): bool
    {
        return $this->stream->isWritable();
    }

    public function isSeekable(): bool
    {
        return $this->stream->isSeekable();
    }

    
if (['-'] === $filenames) {
            return $this->display($io[$this->validate(file_get_contents('php://stdin')$flags)]);
        }

        if (!$filenames) {
            throw new RuntimeException('Please provide a filename or pipe file content to STDIN.');
        }

        $filesInfo = [];
        foreach ($filenames as $filename) {
            if (!$this->isReadable($filename)) {
                throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
            }

            foreach ($this->getFiles($filename) as $file) {
                if (!\in_array($file->getPathname()$excludes, true)) {
                    $filesInfo[] = $this->validate(file_get_contents($file)$flags$file);
                }
            }
        }

        return $this->display($io$filesInfo);
    }

    public function resolveTemplateDir($templateDir$key = null)
    {
        if ($this->eventManager !== null) {
            $templateDir = $this->eventManager->filter(
                __CLASS__ . '_ResolveTemplateDir',
                $templateDir,
                ['subject' => $this, 'key' => $key]
            );
        }

        return Enlight_Loader::isReadable($templateDir);
    }

    /** * @param \Enlight_Event_EventManager $eventManager * * @return Enlight_Template_Manager */
    public function setEventManager($eventManager)
    {
        $this->eventManager = $eventManager;

        
// Try to find the file on the filesystem         foreach ($templateDirs as $dir) {
            if (file_exists($dir . $file)) {
                $file = Enlight_Loader::realpath($dir) . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file);
                break;
            }
            if ($useIncludePath) {
                if ($dir === '.' . DIRECTORY_SEPARATOR) {
                    $dir = '';
                }
                if (($result = Enlight_Loader::isReadable($dir . $file)) !== false) {
                    $file = $result;
                    break;
                }
            }
        }

        // Some cleanup code         if (strpos($file$docPath) === 0) {
            $file = substr($file, \strlen($docPath));
        }

        

    public static function loadFile($path$check = true)
    {
        if ($check && !self::checkFile($path)) {
            throw new Enlight_Exception('Security check: Illegal character in filename');
        }
        if ($check && !self::isReadable($path)) {
            throw new Enlight_Exception('File "' . $path . '" not exists failure');
        }
        if (!ob_start()) {
            throw new Enlight_Exception('Output buffering could not be started');
        }

        $result = include $path;
        ob_end_clean();

        return $result;
    }

    
/** * @param DataAccessorInterface[]|iterable $accessors */
    public function __construct(iterable $accessors)
    {
        $this->accessors = $accessors;
    }

    public function getValue(object|array $data, FormInterface $form): mixed
    {
        foreach ($this->accessors as $accessor) {
            if ($accessor->isReadable($data$form)) {
                return $accessor->getValue($data$form);
            }
        }

        throw new AccessException('Unable to read from the given form data as no accessor in the chain is able to read the data.');
    }

    public function setValue(object|array &$data, mixed $value, FormInterface $form): void
    {
        foreach ($this->accessors as $accessor) {
            if ($accessor->isWritable($data$form)) {
                
/** * Filters the iterator values. */
    public function accept(): bool
    {
        if (!$this->matchRegexps && !$this->noMatchRegexps) {
            return true;
        }

        $fileinfo = $this->current();

        if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
            return false;
        }

        $content = $fileinfo->getContents();
        if (!$content) {
            return false;
        }

        return $this->isAccepted($content);
    }

    
/** * Sets a new exchange service * * @param string|Zend_Currency_CurrencyInterface $service Service class * @return Zend_Currency */
    public function setService($service)
    {
        if (is_string($service)) {
            if (!class_exists($service)) {
                $file = str_replace('_', DIRECTORY_SEPARATOR, $service) . '.php';
                if (Zend_Loader::isReadable($file)) {
                    Zend_Loader::loadClass($service);
                }
            }

            $service = new $service;
        }

        if (!($service instanceof Zend_Currency_CurrencyInterface)) {
            throw new Zend_Currency_Exception('A currency service must implement Zend_Currency_CurrencyInterface');
        }

        
Home | Imprint | This part of the site doesn't use cookies.