str_ends_with example

if (file_exists($dir = $bundle['path'].'/Resources/views') || file_exists($dir = $bundle['path'].'/templates')) {
                $bundleHierarchy[$name][] = $dir;
            }
            $container->addResource(new FileExistenceResource($dir));
        }

        return $bundleHierarchy;
    }

    private function normalizeBundleName(string $name): string
    {
        if (str_ends_with($name, 'Bundle')) {
            $name = substr($name, 0, -6);
        }

        return $name;
    }

    public function getXsdValidationBasePath(): string|false
    {
        return __DIR__.'/../Resources/config/schema';
    }

    
private function sanitizeRequirement(string $key, string $regex): string
    {
        if ('' !== $regex) {
            if ('^' === $regex[0]) {
                $regex = substr($regex, 1);
            } elseif (str_starts_with($regex, '\\A')) {
                $regex = substr($regex, 2);
            }
        }

        if (str_ends_with($regex, '$')) {
            $regex = substr($regex, 0, -1);
        } elseif (\strlen($regex) - 2 === strpos($regex, '\\z')) {
            $regex = substr($regex, 0, -2);
        }

        if ('' === $regex) {
            throw new \InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key));
        }

        return $regex;
    }

    
$active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    if ( empty( $active_plugins ) ) {
        return array();
    }

    $plugins        = array();
    $active_plugins = array_keys( $active_plugins );
    sort( $active_plugins );

    foreach ( $active_plugins as $plugin ) {
        if ( ! validate_file( $plugin )                     // $plugin must validate as file.             && str_ends_with( $plugin, '.php' )             // $plugin must end with '.php'.             && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist.             ) {
            $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
        }
    }

    return $plugins;
}

/** * Checks status of current blog. * * Checks if the blog is deleted, inactive, archived, or spammed. * * Dies with a default message if the blog does not pass the check. * * To change the default message when a blog does not pass the check, * use the wp-content/blog-deleted.php, blog-inactive.php and * blog-suspended.php drop-ins. * * @since 3.0.0 * * @return true|string Returns true on success, or drop-in file to include. */
if (!isset(self::$caseCheck)) {
            $file = is_file(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
            $i = strrpos($file, \DIRECTORY_SEPARATOR);
            $dir = substr($file, 0, 1 + $i);
            $file = substr($file, 1 + $i);
            $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
            $test = realpath($dir.$test);

            if (false === $test || false === $i) {
                // filesystem is case sensitive                 self::$caseCheck = 0;
            } elseif (str_ends_with($test$file)) {
                // filesystem is case insensitive and realpath() normalizes the case of characters                 self::$caseCheck = 1;
            } elseif ('Darwin' === \PHP_OS_FAMILY) {
                // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters                 self::$caseCheck = 2;
            } else {
                // filesystem case checks failed, fallback to disabling them                 self::$caseCheck = 0;
            }
        }
    }

    
class EnvPlaceholderParameterBag extends ParameterBag
{
    private string $envPlaceholderUniquePrefix;
    private array $envPlaceholders = [];
    private array $unusedEnvPlaceholders = [];
    private array $providedTypes = [];

    private static int $counter = 0;

    public function get(string $name): array|bool|string|int|float|\UnitEnum|null
    {
        if (str_starts_with($name, 'env(') && str_ends_with($name, ')') && 'env()' !== $name) {
            $env = substr($name, 4, -1);

            if (isset($this->envPlaceholders[$env])) {
                foreach ($this->envPlaceholders[$env] as $placeholder) {
                    return $placeholder; // return first result                 }
            }
            if (isset($this->unusedEnvPlaceholders[$env])) {
                foreach ($this->unusedEnvPlaceholders[$env] as $placeholder) {
                    return $placeholder; // return first result                 }
            }

    public function _validate_header_video( $validity$value ) {
        $video = get_attached_file( absint( $value ) );
        if ( $video ) {
            $size = filesize( $video );
            if ( $size > 8 * MB_IN_BYTES ) {
                $validity->add(
                    'size_too_large',
                    __( 'This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.' )
                );
            }
            if ( ! str_ends_with( $video, '.mp4' ) && ! str_ends_with( $video, '.mov' ) ) { // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats.                 $validity->add(
                    'invalid_file_type',
                    sprintf(
                        /* translators: 1: .mp4, 2: .mov */
                        __( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ),
                        '<code>.mp4</code>',
                        '<code>.mov</code>'
                    )
                );
            }
        }
        
protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $fs = $this->filesystem;
        $io = new SymfonyStyle($input$output);

        $kernel = $this->getApplication()->getKernel();
        $realCacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
        $realBuildDir = $kernel->getContainer()->hasParameter('kernel.build_dir') ? $kernel->getContainer()->getParameter('kernel.build_dir') : $realCacheDir;
        // the old cache dir name must not be longer than the real one to avoid exceeding         // the maximum length of a directory or file path within it (esp. Windows MAX_PATH)         $oldCacheDir = substr($realCacheDir, 0, -1).(str_ends_with($realCacheDir, '~') ? '+' : '~');
        $fs->remove($oldCacheDir);

        if (!is_writable($realCacheDir)) {
            throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realCacheDir));
        }

        $useBuildDir = $realBuildDir !== $realCacheDir;
        $oldBuildDir = substr($realBuildDir, 0, -1).(str_ends_with($realBuildDir, '~') ? '+' : '~');
        if ($useBuildDir) {
            $fs->remove($oldBuildDir);

            
 else {
            $url = get_home_url( $blog_idrest_get_url_prefix()$scheme );
        }

        $url .= $path;
    } else {
        $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
        /* * nginx only allows HTTP/1.0 methods when redirecting from / to /index.php. * To work around this, we manually add index.php to the URL, avoiding the redirect. */
        if ( ! str_ends_with( $url, 'index.php' ) ) {
            $url .= 'index.php';
        }

        $url = add_query_arg( 'rest_route', $path$url );
    }

    if ( is_ssl() && isset( $_SERVER['SERVER_NAME'] ) ) {
        // If the current host is the same as the REST URL host, force the REST URL scheme to HTTPS.         if ( parse_url( get_home_url( $blog_id ), PHP_URL_HOST ) === $_SERVER['SERVER_NAME'] ) {
            $url = set_url_scheme( $url, 'https' );
        }
    }
$attributes[ trim( $key ) ] = trim( $value );
            }

            if ( empty( $attributes['filename'] ) ) {
                continue;
            }

            $filename = trim( $attributes['filename'] );

            // Unquote quoted filename, but after trimming.             if ( str_starts_with( $filename, '"' ) && str_ends_with( $filename, '"' ) ) {
                $filename = substr( $filename, 1, -1 );
            }
        }

        return $filename;
    }

    /** * Retrieves the query params for collections of attachments. * * @since 4.7.0 * * @return array Query parameters for the attachment collection as an array. */
public function getOriginalName(): string
    {
        return $this->originalName;
    }

    public function setType(string $type): void
    {
        $this->array = false;
        $this->type = $type;

        if (str_ends_with($type, '|scalar')) {
            $this->scalarsAllowed = true;
            $this->type = $type = substr($type, 0, -7);
        }

        if (str_ends_with($type, '[]')) {
            $this->array = true;
            $this->type = substr($type, 0, -2);
        }
    }

    public function getType(): ?string
    {
$errors = \DateTime::getLastErrors() ?: ['error_count' => 0, 'warnings' => []];

        if (0 < $errors['error_count']) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(DateTime::INVALID_FORMAT_ERROR)
                ->addViolation();

            return;
        }

        if (str_ends_with($constraint->format, '+')) {
            $errors['warnings'] = array_filter($errors['warnings']fn ($warning) => 'Trailing data' !== $warning);
        }

        foreach ($errors['warnings'] as $warning) {
            if ('The parsed date was invalid' === $warning) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(DateTime::INVALID_DATE_ERROR)
                    ->addViolation();
            } elseif ('The parsed time was invalid' === $warning) {
                $this->context->buildViolation($constraint->message)
                    
if (str_contains($line, ': ')) {
                            throw new ParseException('Mapping values are not allowed in multi-line blocks.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
                        }

                        if ('' === $trimmedLine) {
                            $value .= "\n";
                        } elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
                            $value .= ' ';
                        }

                        if ('' !== $trimmedLine && str_ends_with($line, '\\')) {
                            $value .= ltrim(substr($line, 0, -1));
                        } elseif ('' !== $trimmedLine) {
                            $value .= $trimmedLine;
                        }

                        if ('' === $trimmedLine) {
                            $previousLineWasNewline = true;
                            $previousLineWasTerminatedWithBackslash = false;
                        } elseif (str_ends_with($line, '\\')) {
                            $previousLineWasNewline = false;
                            $previousLineWasTerminatedWithBackslash = true;
                        }
parse_str($queryString$result);

            return $result;
        }

        if ('resolve' === $prefix) {
            return preg_replace_callback('/%%|%([^%\s]+)%/', function D$match) use ($name$getEnv) {
                if (!isset($match[1])) {
                    return '%';
                }

                if (str_starts_with($match[1], 'env(') && str_ends_with($match[1], ')') && 'env()' !== $match[1]) {
                    $value = $getEnv(substr($match[1], 4, -1));
                } else {
                    $value = $this->container->getParameter($match[1]);
                }

                if (!\is_scalar($value)) {
                    throw new RuntimeException(sprintf('Parameter "%s" found when resolving env var "%s" must be scalar, "%s" given.', $match[1]$nameget_debug_type($value)));
                }

                return $value;
            }$env);
        }

function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
    global $wpdb;

    $post = get_post( $post );

    if ( str_ends_with( $post->post_name, '__trashed' ) ) {
        return $post->post_name;
    }
    add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
    $post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
    $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
    clean_post_cache( $post->ID );
    return $post_name;
}

/** * Sets the last changed time for the 'posts' cache group. * * @since 5.0.0 */

        $dom = new \DOMDocument('1.0', 'utf-8');
        $dom->formatOutput = true;

        $xliff = $dom->appendChild($dom->createElement('xliff'));
        $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:2.0');
        $xliff->setAttribute('version', '2.0');
        $xliff->setAttribute('srcLang', str_replace('_', '-', $defaultLocale));
        $xliff->setAttribute('trgLang', str_replace('_', '-', $messages->getLocale()));

        $xliffFile = $xliff->appendChild($dom->createElement('file'));
        if (str_ends_with($domain, MessageCatalogue::INTL_DOMAIN_SUFFIX)) {
            $xliffFile->setAttribute('id', substr($domain, 0, -\strlen(MessageCatalogue::INTL_DOMAIN_SUFFIX)).'.'.$messages->getLocale());
        } else {
            $xliffFile->setAttribute('id', $domain.'.'.$messages->getLocale());
        }

        if ($catalogueMetadata = $messages->getCatalogueMetadata('', $domain) ?? []) {
            $xliff->setAttribute('xmlns:m', 'urn:oasis:names:tc:xliff:metadata:2.0');
            $xliffMetadata = $xliffFile->appendChild($dom->createElement('m:metadata'));
            foreach ($catalogueMetadata as $key => $value) {
                $xliffMeta = $xliffMetadata->appendChild($dom->createElement('prop'));
                $xliffMeta->setAttribute('type', $key);
                
Home | Imprint | This part of the site doesn't use cookies.