@param PhpCsStandard $standard

@return PhpCs
498836
public function addStandard(PhpCsStandard $standard)
    {
        return new self(
            $this->undefined,
            $this->enabled,
            $standard,
            $this->ignore
        );
    }
1369070
protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, array $tags)
    {
        parent::processCopyright($phpcsFile, $tags);

        $tokens = $phpcsFile->getTokens();
        foreach ($tags as $tag) {
            if ($tokens[($tag + 2)]['code'] !== T_DOC_COMMENT_STRING) {
                // No content.
                continue;
            }

            $content = $tokens[($tag + 2)]['content'];
            $matches = array();
            if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) {
                if ($matches[3] !== '') {
                    if ($matches[1] !== "2013" || $matches[4] !== date("Y") || $matches[5] != "Hexmedia.pl") {
                        $fix = $phpcsFile->addFixableWarning("Not hexmedia:)", $tag, "NotHexmedia");

                        if (true === $fix) {
                            $phpcsFile->fixer->replaceToken(($tag + 2), sprintf("2013-%s Hexmedia.pl", date("Y")));
                        }
                    }
                }
            }
        }//end foreach
    }
1054698
public function resolve(Specification $spec)
    {
        foreach ($this->converters as $converter) {
            if ($converter->accept($spec)) {
                return $converter;
            }
        }

        return null;
    }
365143
public function process(File $phpcsFile, $stackPtr)
    {
        if ($this->supportsBelow('5.6') !== true) {
            return;
        }

        $tokens = $phpcsFile->getTokens();

        $ignore = array(
            \T_DOUBLE_COLON    => true,
            \T_OBJECT_OPERATOR => true,
            \T_FUNCTION        => true,
            \T_CONST           => true,
        );

        $prevToken = $phpcsFile->findPrevious(\T_WHITESPACE, ($stackPtr - 1), null, true);
        if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
            // Not a call to a PHP function.
            return;
        }

        $functionLc = strtolower($tokens[$stackPtr]['content']);
        if ($functionLc !== 'define') {
            return;
        }

        $secondParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 2);
        if (isset($secondParam['start'], $secondParam['end']) === false) {
            return;
        }

        $targetNestingLevel = 0;
        if (isset($tokens[$secondParam['start']]['nested_parenthesis'])) {
            $targetNestingLevel = \count($tokens[$secondParam['start']]['nested_parenthesis']);
        }

        $array = $phpcsFile->findNext(array(\T_ARRAY, \T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
        if ($array !== false) {
            if ((isset($tokens[$array]['nested_parenthesis']) === false && $targetNestingLevel === 0) || \count($tokens[$array]['nested_parenthesis']) === $targetNestingLevel) {
                $phpcsFile->addError(
                    'Constant arrays using define are not allowed in PHP 5.6 or earlier',
                    $array,
                    'Found'
                );
            }
        }
    }
1006210
private static function supportsCsvEscapeChar()
    {
        if (self::$csvEscapeChar === null) {
            self::$csvEscapeChar = version_compare(PHP_VERSION, '5.5.4') >= 0;
        }

        return self::$csvEscapeChar;
    }
797607
public static function error($msg)
    {
        phpCAS :: traceBegin();
        $dbg = debug_backtrace();
        $function = '?';
        $file = '?';
        $line = '?';
        if (is_array($dbg)) {
            for ($i = 1; $i < sizeof($dbg); $i++) {
                if (is_array($dbg[$i]) && isset($dbg[$i]['class']) ) {
                    if ($dbg[$i]['class'] == __CLASS__) {
                        $function = $dbg[$i]['function'];
                        $file = $dbg[$i]['file'];
                        $line = $dbg[$i]['line'];
                    }
                }
            }
        }
        if (self::$_PHPCAS_VERBOSE) {
            echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
        } else {
            echo "<br />\n<b>Error</b>: <font color=\"FF0000\"><b>". DEFAULT_ERROR ."</b><br />\n";
        }
        phpCAS :: trace($msg . ' in ' . $file . 'on line ' . $line );
        phpCAS :: traceEnd();

        throw new CAS_GracefullTerminationException(__CLASS__ . "::" . $function . '(): ' . $msg);
    }
1219023
public function findStandardIdentityByIdentifier(string $identifier): Entity\StandardIdentity
    {
        $identity = new Entity\StandardIdentity;
        $identity->setIdentifier($identifier);

        $this->repository->load($identity);

        if ($identity->getId() === null) {
            $this->logger->notice('identity not found', [
                'input' => [
                    'identifier' => $identifier,
                ],
            ]);

            throw new IdentityNotFound;
        }

        return $identity;
    }
938177
public function removeStandard($standard)
    {
        if ($this->hasStandard($standard)) {
            unset($this->standards[$this->getStandardName($standard)]);
        }

        return $this;
    }
166997
protected function parseExtends(File $phpcsFile, int $extendsStartIndex): array
    {
        $extendsEndIndex = $phpcsFile->findNext([T_IMPLEMENTS, T_OPEN_CURLY_BRACKET], $extendsStartIndex + 1);

        return $this->parse($phpcsFile, $extendsStartIndex, $extendsEndIndex);
    }
564822
public static function configure(IOInterface $io, PhpCs $phpCs)
    {
        if (true === $phpCs->isUndefined()) {
            $answer = $io->ask(HookQuestions::PHPCS_TOOL, HookQuestions::DEFAULT_TOOL_ANSWER);
            $phpCs = $phpCs->setEnabled(new Enabled(HookQuestions::DEFAULT_TOOL_ANSWER === strtoupper($answer)));

            if (true === $phpCs->isEnabled()) {
                $standardAnswer = $io->ask(HookQuestions::PHPCS_STANDARD, null);
                /** @var PhpCs $phpCs */
                $phpCs = $phpCs->addStandard(new PhpCsStandard($standardAnswer));

                $ignoreOptionAnswer = $io->ask(HookQuestions::PHPCS_IGNORE, null);
                $phpCs->addIgnore(new Ignore($ignoreOptionAnswer));
            }
        }

        return $phpCs;
    }
1054283
public static function standardize($value, $toArray = false)
    {
        if (is_array($value) || ((strpos($value, '|') === false) && !$toArray)) {
            return $value;
        }

        return explode('|', $value);
    }
657284
protected function printErrorReport($phpcs)
    {
        $sniffs = $phpcs->getSniffs();
        $sniffStr = '';
        foreach ($sniffs as $sniff) {
            if (is_string($sniff)) {
                $sniffStr .= '- ' . $sniff . PHP_EOL;
            } else {
                $sniffStr .= '- ' . get_class($sniff) . PHP_EOL;
            }
        }
        $this->project->setProperty($this->getPropertyName(), (string) $sniffStr);

        if ($this->showSniffs) {
            $this->log('The list of used sniffs (#' . count($sniffs) . '): ' . PHP_EOL . $sniffStr, Project::MSG_INFO);
        }

        // process output
        $reporting = $phpcs->reporting;
        foreach ($this->formatters as $fe) {
            $reportFile = null;

            if ($fe->getUseFile()) {
                $reportFile = $fe->getOutfile();
                //ob_start();
            }

            // Crude check, but they broke backwards compatibility
            // with a minor version release.
            if (PHP_CodeSniffer::VERSION >= '2.2.0') {
                $cliValues = ['colors' => false];
                $reporting->printReport(
                    $fe->getType(),
                    $this->showSources,
                    $cliValues,
                    $reportFile,
                    $this->reportWidth
                );
            } else {
                $reporting->printReport(
                    $fe->getType(),
                    $this->showSources,
                    $reportFile,
                    $this->reportWidth
                );
            }

            // reporting class uses ob_end_flush(), but we don't want
            // an output if we use a file
            if ($fe->getUseFile()) {
                //ob_end_clean();
            }
        }
    }
1225114
public function init_is_standard() {

        $pluginman = $this->pluginman;
        $standard = $pluginman::standard_plugins_list($this->type);

        if ($standard !== false) {
            $standard = array_flip($standard);
            if (isset($standard[$this->name])) {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_STANDARD;
            } else if (!is_null($this->versiondb) and is_null($this->versiondisk)
                and $pluginman::is_deleted_standard_plugin($this->type, $this->name)) {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_STANDARD; // To be deleted.
            } else {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_EXTENSION;
            }
        }
    }
88124
public static function parse_class_spec($classSpec)
    {
        if (isset(static::$_cache_parse[$classSpec])) {
            return static::$_cache_parse[$classSpec];
        }

        $tokens = token_get_all("<?php $classSpec");
        $class = null;
        $args = array();

        // Keep track of the current bucket that we're putting data into
        $bucket = &$args;
        $bucketStack = array();
        $hadNamespace = false;
        $currentKey = null;

        foreach ($tokens as $token) {
            // $forceResult used to allow null result to be detected
            $result = $forceResult = null;
            $tokenName = is_array($token) ? $token[0] : $token;

            // Get the class name
            if ($class === null && is_array($token) && $token[0] === T_STRING) {
                $class = $token[1];
            } elseif (is_array($token) && $token[0] === T_NS_SEPARATOR) {
                $class .= $token[1];
                $hadNamespace = true;
            } elseif ($token === '.') {
                // Treat service name separator as NS separator
                $class .= '.';
                $hadNamespace = true;
            } elseif ($hadNamespace && is_array($token) && $token[0] === T_STRING) {
                $class .= $token[1];
                $hadNamespace = false;
            // Get arguments
            } elseif (is_array($token)) {
                switch ($token[0]) {
                    case T_CONSTANT_ENCAPSED_STRING:
                        $argString = $token[1];
                        switch ($argString[0]) {
                            case '"':
                                $result = stripcslashes(substr($argString, 1, -1));
                                break;
                            case "'":
                                $result = str_replace(
                                    ["\\\\", "\\'"],
                                    ["\\", "'"],
                                    substr($argString, 1, -1)
                                );
                                break;
                            default:
                                throw new Exception("Bad T_CONSTANT_ENCAPSED_STRING arg $argString");
                        }

                        break;

                    case T_DNUMBER:
                        $result = (double)$token[1];
                        break;

                    case T_LNUMBER:
                        $result = (int)$token[1];
                        break;

                    case T_DOUBLE_ARROW:
                        // We've encountered an associative array (the array itself has already been
                        // added to the bucket), so the previous item added to the bucket is the key
                        end($bucket);
                        $currentKey = current($bucket);
                        array_pop($bucket);
                        break;

                    case T_STRING:
                        switch ($token[1]) {
                            case 'true':
                                $result = true;

                                break;
                            case 'false':
                                $result = false;

                                break;
                            case 'null':
                                $result = null;
                                $forceResult = true;

                                break;
                            default:
                                throw new Exception("Bad T_STRING arg '{$token[1]}'");
                        }

                        break;

                    case T_ARRAY:
                        $result = array();
                        break;
                }
            } else {
                if ($tokenName === '[') {
                    $result = array();
                } elseif (($tokenName === ')' || $tokenName === ']') && !empty($bucketStack)) {
                    // Store the bucket we're currently working on
                    $oldBucket = $bucket;
                    // Fetch the key for the bucket at the top of the stack
                    end($bucketStack);
                    $key = key($bucketStack);
                    reset($bucketStack);
                    // Re-instate the bucket from the top of the stack
                    $bucket = &$bucketStack[$key];
                    // Add our saved, "nested" bucket to the bucket we just popped off the stack
                    $bucket[$key] = $oldBucket;
                    // Remove the bucket we just popped off the stack
                    array_pop($bucketStack);
                }
            }

            // If we've got something to add to the bucket, add it
            if ($result !== null || $forceResult) {
                if ($currentKey) {
                    $bucket[$currentKey] = $result;
                    $currentKey = null;
                } else {
                    $bucket[] = $result;
                }

                // If we've just pushed an array, that becomes our new bucket
                if ($result === array()) {
                    // Fetch the key that the array was pushed to
                    end($bucket);
                    $key = key($bucket);
                    reset($bucket);
                    // Store reference to "old" bucket in the stack
                    $bucketStack[$key] = &$bucket;
                    // Set the active bucket to be our newly-pushed, empty array
                    $bucket = &$bucket[$key];
                }
            }
        }

        $result = [$class, $args];
        static::$_cache_parse[$classSpec] = $result;
        return $result;
    }
225414
public function create(array $paths)
    {
        $standards = new Standards();
        foreach ($paths as $path) {
            $standards->addStandard($this->standardFactory->create($path));
        }

        return $standards;
    }
52945
private function execute(array $files, $standard, $errorMessage, $ignore)
    {
        $outputMessage = new PreCommitOutputWriter(self::EXECUTE_MESSAGE);
        $this->output->write($outputMessage->getMessage());

        $errors = [];
        foreach ($files as $file) {
            $errors[] = $this->phpCsToolProcessor->process($file, $standard, $ignore);
        }

        $errors = array_filter($errors);

        if (!empty($errors)) {
            $this->output->writeln($outputMessage->getFailMessage());
            $this->output->writeln($outputMessage->setError(implode('', $errors)));
            $this->output->writeln(BadJobLogoResponse::paint($errorMessage));
            throw new PhpCsViolationException();
        }
        $this->output->writeln($outputMessage->getSuccessfulMessage());
    }
200658
public static function __static()
	{
		$prefixes = array( STANDARD_PREFIX_SCHEMA, STANDARD_PREFIX_XBRLI, STANDARD_PREFIX_LINK, STANDARD_PREFIX_XLINK, STANDARD_PREFIX_GENERIC, STANDARD_PREFIX_XBRLDT, STANDARD_PREFIX_XBRLDI );
		self::$standardNamespaces = $temp = array_flip( array_intersect_key( self::$standardPrefixes, array_flip( $prefixes ) ) );

		self::$standardArcElements = array_flip(
			array(
				"definitionArc",
				"calculationArc",
				"presentationArc",
				"labelArc",
				"referenceArc",
				"footnoteArc",
			)
		);

		self::$standardLinkElements = array_flip(
			array(
				"definitionLink",
				"calculationLink",
				"presentationLink",
				"labelLink",
				"referenceLink",
				"footnoteLink",
				"label",
				"footnote",
				"reference",
			)
		);

		foreach ( self::$standardArcElements as $arc => $value )
		{
			$qname = self::qnameNS( "link:$arc" );
			self::$standardArcQnames[ (string) $qname ] = $qname;
		}

		foreach ( self::$standardLinkElements as $link => $value )
		{
			/**
			 * @var QName qname
			 */
			$qname = self::qnameNS( "link:$link" );
			self::$standardExtLinkQnamesAndResources[ (string) $qname ] = $qname;
		}

		self::$standardExtLinkQnames = array_filter(
			self::$standardExtLinkQnamesAndResources,
			function( $qname ) { return XBRL::endsWith( $qname->localName, 'Link' ); }
		);

		self::$resourceArcRoles = array_flip(
			array(
				self::$arcRoleConceptLabel,
				self::$arcRoleConceptReference,
				self::$arcRoleFactFootnote,
				self::$genericElementLabel,
				self::$genericElementReference,
			)
		);

		self::$standardLabelRoles = array(
			self::$labelRoleLabel,
			self::$labelRoleTerseLabel,
			self::$labelRoleVerboseLabel,
			self::$labelRolePositiveLabel,
			self::$labelRolePositiveTerseLabel,
			self::$labelRolePositiveVerboseLabel,
			self::$labelRoleNegativeLabel,
			self::$labelRoleNegativeTerseLabel,
			self::$labelRoleNegativeVerboseLabel,
			self::$labelRoleZeroLabel,
			self::$labelRoleZeroTerseLabel,
			self::$labelRoleZeroVerboseLabel,
			self::$labelRoleTotalLabel,
			self::$labelRolePeriodStartLabel,
			self::$labelRolePeriodEndLabel,
			self::$labelRoleDocumentation,
			self::$labelRoleDefinitionGuidance,
			self::$labelRoleDisclosureGuidance,
			self::$labelRolePresentationGuidance,
			self::$labelRoleMeasurementGuidance,
			self::$labelRoleCommentaryGuidance,
			self::$labelRoleExampleGuidance,
		);

		self::$standardRoles = array_flip(
			array_merge(
				self::$standardLabelRoles,
				self::$standardReferenceRoles,
				self::$standardLinkbaseRefRoles,
				array(
						self::$defaultLinkRole,
						self::$footnote,
				)
			)
		);

		self::$standardArcRoles = array_flip(
			array(
				self::$linkCalculationArc,
				self::$linkDefinitionArc,
				self::$linkFootnoteArc,
				self::$linkLabelArc,
				self::$linkPresentationArc,
				self::$linkReferenceArc,
			)
		);

		self::$standardArcroleCyclesAllowed = array(
			self::$arcRoleConceptLabel		=> array( "any", null ),
			self::$arcRoleConceptReference	=> array( "any", null ),
			self::$arcRoleFactFootnote		=> array( "any", null ),
			self::$arcRoleParentChild		=> array( "undirected", "xbrl.5.2.4.2" ),
			self::$arcRoleSummationItem		=> array( "any", "xbrl.5.2.5.2" ),
			self::$arcRoleGeneralSpecial	=> array( "undirected", "xbrl.5.2.6.2.1" ),
			self::$arcRoleEssenceAlias		=> array( "undirected", "xbrl.5.2.6.2.1" ),
			self::$arcRoleSimilarTuples		=> array( "any", "xbrl.5.2.6.2.3" ),
			self::$arcRoleRequiresElement	=> array( "any", "xbrl.5.2.6.2.4" ),
		);

		self::$consecutiveArcrole = array( // can be list of or single arcrole
			'all'						=> array( self::$arcRoleDimensionDomain, self::$arcRoleHypercubeDimension ),
			'notAll'					=> array( self::$arcRoleDimensionDomain, self::$arcRoleHypercubeDimension ),
			'hypercubeDimension'		=> self::$arcRoleDimensionDomain,
			'dimensionDomain'			=> array( self::$arcRoleDomainMember, self::$arcRoleAll, self::$arcRoleNotAll ),
			'domainMember'				=> array( self::$arcRoleDomainMember, self::$arcRoleAll, self::$arcRoleNotAll ),
			'dimensionDefault'			=> array(),
		);

		self::$hasHypercube = array(
			self::$arcRoleAll,
			self::$arcRoleNotAll,
		);

		self::$standardLinkbaseRefRoles = array(
			self::$CalculationLinkbaseRef,
			self::$DefinitionLinkbaseRef,
			self::$LabelLinkbaseRef,
			self::$PresentationLinkbaseRef,
			self::$ReferenceLinkbaseRef,
		);

		self::$arcCustomAttributesExclusions = array(
			'http://www.w3.org/2000/xmlns',
			self::$standardPrefixes[ STANDARD_PREFIX_XLINK ],
			"use",
			"priority",
			"order",
		);

		self::$xbrliSubstitutionHeads = array(
			self::$xbrldtDimensionItem,
			self::$xbrldtHypercubeItem,
			self::$xbrliItem,
			self::$xbrliTuple,
		);

		self::$arcRoleDimensional = array(
			XBRL_Constants::$arcRoleAll,
			XBRL_Constants::$arcRoleNotAll,
			XBRL_Constants::$arcRoleDimensionDomain,
			XBRL_Constants::$arcRoleDomainMember,
			XBRL_Constants::$arcRoleDimensionMember,
			XBRL_Constants::$arcRoleHypercubeDimension,
			XBRL_Constants::$arcRoleDimensionDefault,
		);
	}