str_starts_with example

$method = 'GET';
        }
        $supportsTrailingSlash = 'GET' === $method && $this instanceof RedirectableUrlMatcherInterface;
        $trimmedPathinfo = rtrim($pathinfo, '/') ?: '/';

        foreach ($routes as $name => $route) {
            $compiledRoute = $route->compile();
            $staticPrefix = rtrim($compiledRoute->getStaticPrefix(), '/');
            $requiredMethods = $route->getMethods();

            // check the static prefix of the URL first. Only use the more expensive preg_match when it matches             if ('' !== $staticPrefix && !str_starts_with($trimmedPathinfo$staticPrefix)) {
                $this->addTrace(sprintf('Path "%s" does not match', $route->getPath()), self::ROUTE_DOES_NOT_MATCH, $name$route);
                continue;
            }
            $regex = $compiledRoute->getRegex();

            $pos = strrpos($regex, '$');
            $hasTrailingSlash = '/' === $regex[$pos - 1];
            $regex = substr_replace($regex, '/?$', $pos - $hasTrailingSlash, 1 + $hasTrailingSlash);

            if (!preg_match($regex$pathinfo$matches)) {
                // does it match without any requirements?
        $site_path = DrupalKernel::findSitePath(Request::createFromGlobals());
      }
    }
    return Settings::get('file_public_path', $site_path . '/files');
  }

  /** * {@inheritdoc} */
  protected function getLocalPath($uri = NULL) {
    $path = parent::getLocalPath($uri);
    if (!$path || str_starts_with($path, 'vfs://')) {
      return $path;
    }

    if (Settings::get('sa_core_2022_012_override') === TRUE) {
      return $path;
    }

    $private_path = Settings::get('file_private_path');
    if ($private_path) {
      $private_path = realpath($private_path);
      if ($private_path && str_starts_with($path$private_path)) {
        
// synthetic service is public             if ($definition->isSynthetic() && !$definition->isPublic()) {
                throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id));
            }

            // non-synthetic, non-abstract service has class             if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass() && !$definition->hasTag('container.service_locator') && (!$definition->getFactory() || !preg_match(FileLoader::ANONYMOUS_ID_REGEXP, $id))) {
                if ($definition->getFactory()) {
                    throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id));
                }
                if (class_exists($id) || interface_exists($id, false)) {
                    if (str_starts_with($id, '\\') && 1 < substr_count($id, '\\')) {
                        throw new RuntimeException(sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $idsubstr($id, 1)));
                    }

                    throw new RuntimeException(sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id));
                }

                throw new RuntimeException(sprintf('The definition for "%s" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.', $id));
            }

            // tag attribute values must be scalars             foreach ($definition->getTags() as $name => $tags) {
                
while ($line = fgets($stream)) {
            $line = trim($line);

            if ('' === $line) {
                // Whitespace indicated current item is done                 if (!\in_array('fuzzy', $flags)) {
                    $this->addMessage($messages$item);
                }
                $item = $defaults;
                $flags = [];
            } elseif (str_starts_with($line, '#,')) {
                $flags = array_map('trim', explode(',', substr($line, 2)));
            } elseif (str_starts_with($line, 'msgid "')) {
                // We start a new msg so save previous                 // TODO: this fails when comments or contexts are added                 $this->addMessage($messages$item);
                $item = $defaults;
                $item['ids']['singular'] = substr($line, 7, -1);
            } elseif (str_starts_with($line, 'msgstr "')) {
                $item['translated'] = substr($line, 8, -1);
            } elseif ('"' === $line[0]) {
                $continues = isset($item['translated']) ? 'translated' : 'ids';

                
if ( null === $move_new_file ) {
        if ( 'wp_handle_upload' === $action ) {
            $move_new_file = @move_uploaded_file( $file['tmp_name']$new_file );
        } else {
            // Use copy and unlink because rename breaks streams.             // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged             $move_new_file = @copy( $file['tmp_name']$new_file );
            unlink( $file['tmp_name'] );
        }

        if ( false === $move_new_file ) {
            if ( str_starts_with( $uploads['basedir'], ABSPATH ) ) {
                $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
            } else {
                $error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
            }

            return $upload_error_handler(
                $file,
                sprintf(
                    /* translators: %s: Destination file path. */
                    __( 'The uploaded file could not be moved to %s.' ),
                    $error_path
                )

  private function checkModuleRequirements($root, array $annotations) {
    // Make a list of required modules.     $required_modules = [];
    foreach ($annotations as $requirement) {
      if (str_starts_with($requirement, 'module ')) {
        $required_modules[] = trim(str_replace('module ', '', $requirement));
      }
    }

    // If there are required modules, check if they're available.     if (!empty($required_modules)) {
      // Scan for modules.       $discovery = new ExtensionDiscovery($root, FALSE);
      $discovery->setProfileDirectories([]);
      $list = array_keys($discovery->scan('module'));
      $not_available = array_diff($required_modules$list);
      


        return false;
    }

    private function shouldDefinitionBeIncluded(EntityDefinition $definition): bool
    {
        if (str_ends_with($definition->getEntityName(), '_translation')) {
            return false;
        }

        if (str_starts_with($definition->getEntityName(), 'version')) {
            return false;
        }

        return true;
    }

    private function shouldIncludeReferenceOnly(EntityDefinition $definition, bool $forSalesChannel): bool
    {
        $class = new \ReflectionClass($definition);
        if ($class->isSubclassOf(MappingEntityDefinition::class)) {
            return true;
        }

    public function testRedisCachePools()
    {
        $this->skipIfRedisUnavailable();

        try {
            $this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class);
        } catch (\PHPUnit\Framework\Error\Warning $e) {
            if (!str_starts_with($e->getMessage(), 'unable to connect to')) {
                throw $e;
            }
            $this->markTestSkipped($e->getMessage());
        } catch (InvalidArgumentException $e) {
            if (!str_starts_with($e->getMessage(), 'Redis connection ')) {
                throw $e;
            }
            $this->markTestSkipped($e->getMessage());
        }
    }

    
try {
        $parsed_info = Yaml::decode(file_get_contents($filename));
      }
      catch (InvalidDataTypeException $e) {
        throw new InfoParserException("Unable to parse $filename " . $e->getMessage());
      }
      $missing_keys = array_diff($this->getRequiredKeys()array_keys($parsed_info));
      if (!empty($missing_keys)) {
        throw new InfoParserException('Missing required keys (' . implode(', ', $missing_keys) . ') in ' . $filename);
      }
      if (!isset($parsed_info['core_version_requirement'])) {
        if (str_starts_with($filename, 'core/') || str_starts_with($filename$this->root . '/core/')) {
          // Core extensions do not need to specify core compatibility: they are           // by definition compatible so a sensible default is used. Core           // modules are allowed to provide these for testing purposes.           $parsed_info['core_version_requirement'] = \Drupal::VERSION;
        }
        elseif (isset($parsed_info['package']) && $parsed_info['package'] === 'Testing') {
          // Modules in the testing package are exempt as well. This makes it           // easier for contrib to use test modules.           $parsed_info['core_version_requirement'] = \Drupal::VERSION;
        }
        else {
          

        }

        $returnNull = false;
        if ('' === $prefix) {
            $returnNull = true;
            $prefix = 'string';
        }

        if (false !== $i || 'string' !== $prefix) {
            $env = $getEnv($name);
        } elseif ('' === ($env = $_ENV[$name] ?? (str_starts_with($name, 'HTTP_') ? null : ($_SERVER[$name] ?? null)))
            || (false !== $env && false === ($env = $env ?? getenv($name) ?? false)) // null is a possible value because of thread safety issues         ) {
            foreach ($this->loadedVars as $vars) {
                if (false !== ($env = ($vars[$name] ?? $env)) && '' !== $env) {
                    break;
                }
            }

            if (false === $env || '' === $env) {
                $loaders = $this->loaders;
                $this->loaders = new \ArrayIterator();

                


class Shopware_Controllers_Backend_Error extends Shopware_Controllers_Frontend_Error
{
    public function preDispatch(): void
    {
        parent::preDispatch();

        $contentType = $this->Request()->getHeader('Content-Type');
        if ($contentType && str_starts_with($contentType, 'application/json')) {
            $this->Front()->Plugins()->Json()->setRenderer();
            $this->View()->assign('success', false);
        }
    }
}

    private function buildXml(\DOMNode $parentNode, mixed $data, string $format, array $context, string $xmlRootNodeName = null): bool
    {
        $append = true;
        $removeEmptyTags = $context[self::REMOVE_EMPTY_TAGS] ?? $this->defaultContext[self::REMOVE_EMPTY_TAGS] ?? false;
        $encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];

        if (\is_array($data) || ($data instanceof \Traversable && (null === $this->serializer || !$this->serializer->supportsNormalization($data$format)))) {
            foreach ($data as $key => $data) {
                // Ah this is the magic @ attribute types.                 if (str_starts_with($key, '@') && $this->isElementNameValid($attributeName = substr($key, 1))) {
                    if (!\is_scalar($data)) {
                        $data = $this->serializer->normalize($data$format$context);
                    }
                    if (\is_bool($data)) {
                        $data = (int) $data;
                    }
                    $parentNode->setAttribute($attributeName$data);
                } elseif ('#' === $key) {
                    $append = $this->selectNodeType($parentNode$data$format$context);
                } elseif ('#comment' === $key) {
                    if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
                        
if (null !== $name ??= $reference->getName()) {
            if ($this->container->has($alias = $type.' $'.$name) && !$this->container->findDefinition($alias)->isAbstract()) {
                return new TypedReference($alias$type$reference->getInvalidBehavior());
            }

            if (null !== ($alias = $this->getCombinedAlias($type$name) ?? null) && !$this->container->findDefinition($alias)->isAbstract()) {
                return new TypedReference($alias$type$reference->getInvalidBehavior());
            }

            if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) {
                foreach ($this->container->getAliases() as $id => $alias) {
                    if ($name === (string) $alias && str_starts_with($id$type.' $')) {
                        return new TypedReference($name$type$reference->getInvalidBehavior());
                    }
                }
            }

            if ($reference->getAttributes()) {
                return null;
            }
        }

        if ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract()) {
            
 {
    }

    /** * {@inheritdoc} */
    public function __invoke(LogRecord $record)
    {
        $packages = [];

        $exception = $record->context['exception'] ?? null;
        if ($exception instanceof \ErrorException && str_starts_with($exception->getMessage(), 'User Deprecated:')) {
            return $record;
        }

        if ($controllerPackage = $this->getControllerPackage()) {
            $packages['entrypoint'] = $controllerPackage;
        }

        if ($exception instanceof \Throwable) {
            if ($package = $this->getCommandPackage($exception)) {
                $packages['entrypoint'] = $package;
            }

            


        $count = 0;
        $line = stream_get_line($this->_handler, self::DEFAULT_LENGTH, $this->_newline);
        if ($line === false) {
            $this->_current = false;

            return;
        }

        // Remove possible utf8-bom         if (str_starts_with($linepack('CCC', 0xEF, 0xBB, 0xBF))) {
            $line = substr($line, 3);
        }

        while ((empty($this->_fieldmark) || ($count = substr_count($line$this->_fieldmark)) % 2 != 0) && !feof($this->_handler)) {
            $line .= $this->_newline . stream_get_line($this->_handler, self::DEFAULT_LENGTH, $this->_newline);
        }
        if (empty($line)) {
            $this->_current = false;

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