Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/corals/old/vendor/friendsofphp/php-cs-fixer/src/Tokenizer/Analyzer/SwitchAnalyzer.php
<?php

declare(strict_types=1);

/*
 * This file is part of PHP CS Fixer.
 *
 * (c) Fabien Potencier <[email protected]>
 *     Dariusz RumiƄski <[email protected]>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace PhpCsFixer\Tokenizer\Analyzer;

use PhpCsFixer\Tokenizer\Analyzer\Analysis\SwitchAnalysis;
use PhpCsFixer\Tokenizer\Tokens;

/**
 * @internal
 */
final class SwitchAnalyzer
{
    /** @var array<string, array<int>> */
    private static array $cache = [];

    public static function belongsToSwitch(Tokens $tokens, int $index): bool
    {
        if (!$tokens[$index]->equals(':')) {
            return false;
        }

        $tokensHash = md5(serialize($tokens->toArray()));

        if (!\array_key_exists($tokensHash, self::$cache)) {
            self::$cache[$tokensHash] = self::getColonIndicesForSwitch(clone $tokens);
        }

        return \in_array($index, self::$cache[$tokensHash], true);
    }

    /**
     * @return list<int>
     */
    private static function getColonIndicesForSwitch(Tokens $tokens): array
    {
        $colonIndices = [];

        /** @var SwitchAnalysis $analysis */
        foreach (ControlCaseStructuresAnalyzer::findControlStructures($tokens, [T_SWITCH]) as $analysis) {
            if ($tokens[$analysis->getOpenIndex()]->equals(':')) {
                $colonIndices[] = $analysis->getOpenIndex();
            }

            foreach ($analysis->getCases() as $case) {
                $colonIndices[] = $case->getColonIndex();
            }

            $defaultAnalysis = $analysis->getDefaultAnalysis();

            if (null !== $defaultAnalysis) {
                $colonIndices[] = $defaultAnalysis->getColonIndex();
            }
        }

        return $colonIndices;
    }
}

Spamworldpro Mini