Configures PHP CodeSniffer.

@return void
329160
public function main()
    {
        // Check if all required data is present.
        $this->checkRequirements();

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

        // Create the root 'ruleset' element.
        $root_element = $document->createElement('ruleset');
        $root_element->setAttribute('name', 'NextEuropa_default');
        $document->appendChild($root_element);

        // Add the description.
        $element = $document->createElement(
            'description',
            'Default PHP CodeSniffer configuration for NextEuropa subsites.'
        );
        $root_element->appendChild($element);

        // Add the coding standards.
        foreach ($this->_standards as $standard) {
            if (substr($standard, -4) === '.xml') {
                if (file_exists($standard)) {
                    $element = $document->createElement('rule');
                    $element->setAttribute('ref', $standard);
                    $root_element->appendChild($element);
                }
            }
            else {
                $element = $document->createElement('rule');
                $element->setAttribute('ref', $standard);
                $root_element->appendChild($element);
            }
        }

        // Add the files to check.
        foreach ($this->_files as $file) {
            $element = $document->createElement('file', $file);
            $root_element->appendChild($element);
        }

        // Add file extensions.
        if (!empty($this->_extensions)) {
            $extensions = implode(',', $this->_extensions);
            $this->appendArgument(
                $document,
                $root_element,
                $extensions,
                'extensions'
            );
        }

        // Add ignore patterns.
        foreach ($this->_ignorePatterns as $pattern) {
            $element = $document->createElement('exclude-pattern', $pattern);
            $root_element->appendChild($element);
        }

        // Add the requested Reports..
        foreach ($this->_reports as $report) {
            // Add the report type.
            $this->appendArgument($document, $root_element, $report, 'report');
        }

        // Add the shorthand options.
        $shorthand_options = array(
            'p' => '_showProgress',
            's' => '_showSniffCodes',
        );

        $options = array_filter(
            $shorthand_options,
            function ($value) {
                return $this->$value;
            }
        );

        if (!empty($options)) {
            $this->appendArgument(
                $document,
                $root_element,
                implode('', array_flip($options))
            );
        }

        // Save the file.
        $configSaved = file_put_contents(
            $this->_configFile,
            $document->saveXML()
        );

    }
309637
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[($stackPtr + 1)]) === false) {
            return;
        }

        // Single space after the keyword.
        if (in_array($tokens[$stackPtr]['code'], array(T_CATCH, T_IF, T_WHILE, T_FOR, T_FOREACH, T_ELSEIF, T_SWITCH))) {
            $found = 1;
            if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
                $found = 0;
            } else if ($tokens[($stackPtr + 1)]['content'] !== ' ') {
                if (strpos($tokens[($stackPtr + 1)]['content'], $phpcsFile->eolChar) !== false) {
                    $found = 'newline';
                } else {
                    $found = strlen($tokens[($stackPtr + 1)]['content']);
                }
            }

            if ($found !== 1) {
                $error = 'Expected 1 space after %s keyword; %s found';
                $data  = array(
                          strtoupper($tokens[$stackPtr]['content']),
                          $found,
                         );

                $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data);
                if ($fix === true) {
                    if ($found === 0) {
                        $phpcsFile->fixer->addContent($stackPtr, ' ');
                    } else {
                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
                    }
                }
            }
        }

        // Single newline after the keyword.
        if (in_array($tokens[$stackPtr]['code'], array(T_TRY, T_DO, T_ELSE))
            && isset($tokens[$stackPtr]['scope_opener']) === true
        ) {
            $opener = $tokens[$stackPtr]['scope_opener'];
            $found = ($tokens[$opener]['line'] - $tokens[$stackPtr]['line']);
            if ($found !== 1) {
                $error = 'Expected 1 newline after % keyword; %s found';
                $data  = array(
                            strtoupper($tokens[$stackPtr]['content']),
                            $found,
                            );
                $fix   = $phpcsFile->addFixableError($error, $opener, 'NewlineAfterKeyword', $data);
                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = ($stackPtr + 1); $i < $opener; $i++) {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$opener]['line']) {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($stackPtr, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }//end if
        }//end if

        // Single newline after closing parenthesis.
        if (isset($tokens[$stackPtr]['parenthesis_closer']) === true
            && isset($tokens[$stackPtr]['scope_opener']) === true
        ) {
            $closer  = $tokens[$stackPtr]['parenthesis_closer'];
            $opener  = $tokens[$stackPtr]['scope_opener'];
            $found = ($tokens[$opener]['line'] - $tokens[$closer]['line']);
            if ($found !== 1) {
                $error = 'Expected 1 newline after closing parenthesis; %s found';
                $fix   = $phpcsFile->addFixableError($error, $opener, 'NewlineAfterCloseParenthesis', array($found));
                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = ($closer + 1); $i < $opener; $i++) {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$opener]['line']) {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($closer, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }//end if
        }//end if

        // Single newline after opening brace.
        if (isset($tokens[$stackPtr]['scope_opener']) === true) {
            $opener = $tokens[$stackPtr]['scope_opener'];
            for ($next = ($opener + 1); $next < $phpcsFile->numTokens; $next++) {
                $code = $tokens[$next]['code'];

                if ($code === T_WHITESPACE) {
                    continue;
                }

                // Skip all empty tokens on the same line as the opener.
                if ($tokens[$next]['line'] === $tokens[$opener]['line']
                    && (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true
                    || $code === T_CLOSE_TAG)
                ) {
                    continue;
                }

                // We found the first bit of a code, or a comment on the
                // following line.
                break;
            }

            $found = ($tokens[$next]['line'] - $tokens[$opener]['line']);
            if ($found !== 1) {
                $error = 'Expected 1 newline after opening brace; %s found';
                $data  = array($found);
                $fix   = $phpcsFile->addFixableError($error, $opener, 'NewlineAfterOpenBrace', $data);
                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = ($opener + 1); $i < $next; $i++) {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$next]['line']) {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($opener, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }
        } else if ($tokens[$stackPtr]['code'] === T_WHILE) {
            // Zero spaces after parenthesis closer.
            $closer = $tokens[$stackPtr]['parenthesis_closer'];
            $found  = 0;
            if ($tokens[($closer + 1)]['code'] === T_WHITESPACE) {
                if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false) {
                    $found = 'newline';
                } else {
                    $found = strlen($tokens[($closer + 1)]['content']);
                }
            }

            if ($found !== 0) {
                $error = 'Expected 0 spaces before semicolon; %s found';
                $data  = array($found);
                $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceBeforeSemicolon', $data);
                if ($fix === true) {
                    $phpcsFile->fixer->replaceToken(($closer + 1), '');
                }
            }
        }//end if

        // Only want to check multi-keyword structures from here on.
        if ($tokens[$stackPtr]['code'] === T_DO) {
            if (isset($tokens[$stackPtr]['scope_closer']) === false) {
                return;
            }

            $closer = $tokens[$stackPtr]['scope_closer'];
        } else if ($tokens[$stackPtr]['code'] === T_ELSE
            || $tokens[$stackPtr]['code'] === T_ELSEIF
            || $tokens[$stackPtr]['code'] === T_CATCH
        ) {
            $closer = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
            if ($closer === false || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET) {
                return;
            }
        } else {
            return;
        }

        // Single space after closing brace.
        if ($tokens[$stackPtr]['code'] === T_DO) {
            $found = 1;
            if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) {
                $found = 0;
            } else if ($tokens[($closer + 1)]['content'] !== ' ') {
                if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false) {
                    $found = 'newline';
                } else {
                    $found = strlen($tokens[($closer + 1)]['content']);
                }
            }

            if ($found !== 1) {
                $error = 'Expected 1 space after closing brace; %s found';
                $data  = array($found);
                $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data);
                if ($fix === true) {
                    if ($found === 0) {
                        $phpcsFile->fixer->addContent($closer, ' ');
                    } else {
                        $phpcsFile->fixer->replaceToken(($closer + 1), ' ');
                    }
                }
            }
        }

        // Single newline after closing brace.
        if ($tokens[$stackPtr]['code'] !== T_DO) {
            for ($next = ($closer + 1); $next < $phpcsFile->numTokens; $next++) {
                $code = $tokens[$next]['code'];

                if ($code === T_WHITESPACE) {
                    continue;
                }

                // Skip all empty tokens on the same line as the closer.
                if ($tokens[$next]['line'] === $tokens[$closer]['line']
                    && (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true
                    || $code === T_CLOSE_TAG)
                ) {
                    continue;
                }

                // We found the first bit of a code, or a comment on the
                // following line.
                break;
            }

            $found = ($tokens[$next]['line'] - $tokens[$closer]['line']);
            if ($found !== 1) {
                $error = 'Expected 1 newline after closing brace; %s found';
                $data  = array($found);
                $fix   = $phpcsFile->addFixableError($error, $closer, 'NewlineAfterCloseBrace', $data);
                if ($fix === true) {
                    $phpcsFile->fixer->beginChangeset();
                    for ($i = ($closer + 1); $i < $next; $i++) {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$next]['line']) {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($closer, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }
        }

    }
799442
private function setPut()
    {
        if ($this->parameters['header']["Content-Type"] == "application/x-www-form-urlencoded") {
            if (isset($_GET)) {
                foreach ($_GET as $k => $v) {
                    $this->log->debug("[ PUT Params ]" . $k . ": " . $v, []);
                    $this->put->$k = $this->setSecurityLevel($v);
                    $this->parameters["put"][$k] = $this->setSecurityLevel($v);
                }
                unset($_GET);
            }

            $rawData = file_get_contents("php://input");
            parse_str($rawData, $_PUT);
            foreach ($_PUT as $k => $v) {
                $this->log->debug("[ PUT Params ]" . $k . ": " . $v, []);
                $this->put->$k = $this->setSecurityLevel($v);
                $this->parameters["put"][$k] = $this->setSecurityLevel($v);
            }
            if ($rawData) {
                $this->parameters["put"]['raw'] = $rawData;
                $this->log->debug("[ PUT RawData ] raw: " . $rawData, []);
            }
        }
    }
441923
function setEncoding($enc = 'gzip, deflate')
    {
        if (function_exists('gzdeflate')) {
            $this->protocol_version = '1.1';
            $this->setHeader('Accept-Encoding', $enc);
            if (!isset($this->outgoing_headers['Connection'])) {
                $this->setHeader('Connection', 'close');
                $this->persistentConnection = FALSE;
            }
            // deprecated as of PHP 5.3.0
            //set_magic_quotes_runtime(0);
            $this->encoding = $enc;
        }
    }
800917
protected function configure()
	{
		// the short description shown while running "php bin/console list"
		if( $this->docs->getIs("description") )
		{
			$this->setDescription($this->docs["description"]);
		}

		// the full command description shown when running the command with
		// the "--help" option
		if( $this->docs->getIs("help") )
		{
			$this->setHelp($this->docs["help"]);
		}
	}
282251
public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) {
		$tokens = $phpcsFile->getTokens();

		if ( $tokens[( $stackPtr + 1 )]['code'] !== T_WHITESPACE
			&& ! ( $tokens[$stackPtr]['code'] === T_ELSE && $tokens[( $stackPtr + 1 )]['code'] === T_COLON )
			&& ! ( T_CLOSURE === $tokens[ $stackPtr ]['code'] && 0 === (int) $this->spaces_before_closure_open_paren )
		) {
			$error = 'Space after opening control structure is required';

			if ( isset( $phpcsFile->fixer ) === true ) {
				$fix = $phpcsFile->addFixableError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );

				if ( $fix === true ) {
					$phpcsFile->fixer->beginChangeset();
					$phpcsFile->fixer->addContent( $stackPtr, ' ' );
					$phpcsFile->fixer->endChangeset();
				}
			} else {
				$phpcsFile->addError( $error, $stackPtr, 'NoSpaceAfterStructureOpen' );
			}
		}

		if ( isset( $tokens[ $stackPtr ] ) && isset( $tokens[ $stackPtr ]['scope_closer'] ) === false ) {
			if ( T_USE === $tokens[ $stackPtr ]['code'] ) {
				$scopeOpener = $phpcsFile->findNext( T_OPEN_CURLY_BRACKET, $stackPtr + 1 );
				$scopeCloser = isset( $tokens[ $scopeOpener ]['scope_closer'] ) ? $tokens[ $scopeOpener ]['scope_closer'] : null;
			} else {
				return;
			}
		} else {
			$scopeOpener = isset( $tokens[ $stackPtr ]['scope_opener'] ) ? $tokens[ $stackPtr ]['scope_opener'] : null;
			$scopeCloser = isset( $tokens[ $stackPtr ]['scope_closer'] ) ? $tokens[ $stackPtr ]['scope_closer'] : null;
		}

		$firstContent = $phpcsFile->findNext( T_WHITESPACE, ( $scopeOpener + 1 ), null, true );
		$currentToken = $tokens[$scopeOpener];
		$class_line = array_values( array_filter( array_filter( $tokens, function ( $token ) use( $currentToken ) {
			return $token['line'] === $currentToken['line'];
		} ), function ( $token ) {
			return $token['code'] === T_CLASS;
		} ) );

		if ( count( $class_line ) > 0 ) {
			$next_line = array_filter( $tokens, function ( $token ) use( $class_line ) {
				return $token['line'] === $class_line[0]['line'] + 1;
			} );

			if ( count( $next_line ) > 0 ) {
				$whitespace = array_filter( $next_line, function ( $token ) {
					return $token['code'] === T_WHITESPACE;
				} );

				$whitespace = count( $whitespace ) < count( $next_line );

				if ( $whitespace
					&& $tokens[$scopeOpener]['code'] === T_OPEN_CURLY_BRACKET
					&& ! isset( $tokens[$firstContent]['nested_parenthesis'] )
					&& $tokens[$firstContent]['level'] === 1
				) {
					$error = 'No blank line found at start of control structure';

					if ( isset( $phpcsFile->fixer ) === true ) {
						$fix = $phpcsFile->addFixableError( $error, $scopeOpener, 'NoBlankLineAfterStart' );

						if ( $fix === true ) {
							$phpcsFile->fixer->beginChangeset();

							for ( $i = ( $scopeOpener + 2 ); $i < $firstContent; $i++ ) {
								$phpcsFile->fixer->replaceToken( $i, '' );
							}

							$phpcsFile->fixer->addNewline( $scopeOpener );
							$phpcsFile->fixer->endChangeset();
						}
					} else {
						$phpcsFile->addError( $error, $scopeOpener, 'NoBlankLineAfterStart' );
					}
				}

				$next_line = array_values( $next_line );

				$next_next_line = array_filter( $tokens, function ( $token ) use ( $next_line ) {
					return $token['line'] === $next_line[0]['line'] + 1;
				} );

				if ( count( $next_next_line )  > 0 ) {
					$next_whitespace = array_filter( $next_next_line, function ( $token ) {
						return $token['code'] === T_WHITESPACE;
					} );

					$next_whitespace = count( $next_next_line ) === count( $next_whitespace );

					if ( $next_whitespace
						&& $tokens[$scopeOpener]['code'] === T_OPEN_CURLY_BRACKET
						&& ! isset( $tokens[$firstContent]['nested_parenthesis'] )
						&& $tokens[$firstContent]['level'] === 1
					) {
						$error = 'More then one blank line found at start of control structure';

						if ( isset( $phpcsFile->fixer ) === true ) {
							$fix = $phpcsFile->addFixableError( $error, $scopeOpener, 'MoreThenOneBlankLineAfterStart' );

							if ( $fix === true ) {
								$phpcsFile->fixer->beginChangeset();

								for ( $i = ( $scopeOpener + 2 ); $i < $firstContent; $i++ ) {
									$phpcsFile->fixer->replaceToken( $i, '' );
								}

								$phpcsFile->fixer->addNewline( $scopeOpener );
								$phpcsFile->fixer->endChangeset();
							}
						} else {
							$phpcsFile->addError( $error, $scopeOpener, 'MoreThenOneBlankLineAfterStart' );
						}
					}
				}
			}
		}

		$trailingContent = $phpcsFile->findNext( T_WHITESPACE, ( $scopeCloser + 1 ), null, true );

		if ( $tokens[$trailingContent]['code'] === T_ELSE ) {
			if ( $tokens[$stackPtr]['code'] === T_IF ) {
				// IF with ELSE.
				return;
			}
		}

		if ( $tokens[$trailingContent]['code'] === T_COMMENT ) {
			if ( $tokens[$trailingContent]['line'] === $tokens[$scopeCloser]['line'] ) {
				if ( substr( $tokens[$trailingContent]['content'], 0, 5 ) === '//end' ) {
					// There is an end comment, so we have to get the next piece
					// of content.
					$trailingContent = $phpcsFile->findNext( T_WHITESPACE, ( $trailingContent + 1 ), null, true );
				}
			}
		}

		if ( $tokens[$trailingContent]['code'] === T_BREAK ) {
			// If this BREAK is closing a CASE, we don't need the
			// blank line after this control structure.
			if ( isset( $tokens[$trailingContent]['scope_condition'] ) === true ) {
				$condition = $tokens[$trailingContent]['scope_condition'];

				if ( $tokens[$condition]['code'] === T_CASE || $tokens[$condition]['code'] === T_DEFAULT ) {
					return;
				}
			}
		}
	}
1219569
private function _configure()
    {
        \Twig_Autoloader::register();

        $loader         =  new \Twig_Loader_Filesystem($this->_basePath);

        $cache_path = defined('CACHE_PATH') ? CACHE_PATH : 'cache';
        $this->_twig = new \Twig_Environment($loader,
            array(
                'debug'      => true,
                'autoreload' => false,
                'autoescape' => true,
                'cache'      => $cache_path,
            ));
        $this->_twig->getExtension('core')->setNumberFormat(2, '.', ',');
        //$this->_twig->addFilter(
            //'nonce',
            //new \Twig_Filter_Function(function($str) {
                //$app=$GLOBALS['app'];
                //if (strpos($str, '?') !== false) {
                    //return $str.'&rand_token='.$app->getSessionManager()->getActiveSession()->getAttribute('nonce');
                //}
                //return $str.'?rand_token='.$app->getSessionManager()->getActiveSession()->getAttribute('nonce');
        //})
        //);
        $this->_twig->addFilter(
            'truncate',
            new \Twig_Filter_Function('StringFilter::truncate')
        );
        $this->_twig->addFilter(
            'isToday',
            new \Twig_Filter_Function('DateFilter::isToday')
        );
        $this->_twig->addFilter(
            'isTomorrow',
            new \Twig_Filter_Function('DateFilter::isTomorrow')
        );
        $this->_twig->addFilter(
            'isLater',
            new \Twig_Filter_Function('DateFilter::isLater')
        );

    }
1265715
protected function buildInlineCode() {
        $result = '';
        if (!$this->events->isEmpty()) {
            $variableName = $this->getTriggeredCustomEventsVariableName();

            $result = 'while (' . $variableName . '.count > 0) {' . PHP_EOL
                . '    switch (' . $variableName . '[0]) {' . PHP_EOL;

            foreach ($this->mergeEvents($this->events) as $name => $code) {
                $result .= '        case "' . $name . '": {' . PHP_EOL
                    . $code
                    . '        }' . PHP_EOL;
            }

            $result .= '    }' . PHP_EOL
                . '    declare Temp = ' . $variableName . '.removekey(0);' . PHP_EOL
                . '}' . PHP_EOL;
        }
        return $result;
    }
937126
private function configureHttpClient()
    {
        $httpClientDefaults = [
            'timeout' => $this->config->get('timeout'),
        ];

        $httpClientConfig = $this->config->get('httpClient') ?? [];

        $this->client = new Client(array_merge($httpClientDefaults, $httpClientConfig));
    }
712169
protected function configure()
    {
        $curlOptions = [];

        if ($this->config['cache.disabled']) {
            $this->simplePie->enable_cache(false);
        } else {
            $this->simplePie->set_cache_location($this->config['cache.location']);
            $this->simplePie->set_cache_duration($this->config['cache.life']);
        }

        if (isset($this->config['curl.options']) && is_array($this->config['curl.options'])) {
            $curlOptions += $this->config['curl.options'];
        }

        if ($this->config['ssl_check.disabled']) {
            $curlOptions[CURLOPT_SSL_VERIFYHOST] = false;
            $curlOptions[CURLOPT_SSL_VERIFYPEER] = false;
        }

        if (is_array($curlOptions)) {
            $this->simplePie->set_curl_options($curlOptions);
        }
    }
265896
public function main()
    {
        if (!class_exists('PHP_CodeSniffer')) {
            @include_once 'PHP/CodeSniffer.php';

            if (!class_exists('PHP_CodeSniffer')) {
                throw new BuildException(
                    "This task requires the PHP_CodeSniffer package installed and available on the include path",
                    $this->getLocation()
                );
            }
        }

        /**
         * Determine PHP_CodeSniffer version number
         */
        if (!$this->skipversioncheck) {
            if (defined('PHP_CodeSniffer::VERSION')) {
                preg_match('/\d\.\d\.\d/', PHP_CodeSniffer::VERSION, $version);
            } else {
                preg_match('/\d\.\d\.\d/', shell_exec('phpcs --version'), $version);
            }

            if (version_compare($version[0], '1.2.2') < 0) {
                throw new BuildException(
                    'PhpCodeSnifferTask requires PHP_CodeSniffer version >= 1.2.2',
                    $this->getLocation()
                );
            }
        }

        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        if (count($this->formatters) == 0) {
            // turn legacy format attribute into formatter
            $fmt = new PhpCodeSnifferTaskFormatterElement();
            $fmt->setType($this->format);
            $fmt->setUseFile(false);
            $this->formatters[] = $fmt;
        }

        $fileList = $this->getFilesToParse();

        $cwd = getcwd();

        // Save command line arguments because it confuses PHPCS (version 1.3.0)
        $oldArgs = $_SERVER['argv'];
        $_SERVER['argv'] = [];
        $_SERVER['argc'] = 0;

        $codeSniffer = new PhpCodeSnifferTaskWrapper($this->verbosity, $this->tabWidth, $this->encoding);
        $codeSniffer->setAllowedFileExtensions($this->allowedFileExtensions);
        if ($this->allowedTypes) {
            PhpCodeSnifferTaskWrapper::$allowedTypes = $this->allowedTypes;
        }
        if (is_array($this->ignorePatterns)) {
            $codeSniffer->setIgnorePatterns($this->ignorePatterns);
        }
        foreach ($this->configData as $configData) {
            $codeSniffer::setConfigData($configData->getName(), $configData->getValue(), true);
        }

        /*
         * Verifying if standard is installed only after setting config data.
         * Custom standard paths could be provided via installed_paths config parameter.
         */
        foreach ($this->standards as $standard) {
            if (PHP_CodeSniffer::isInstalledStandard($standard) === false) {
                // They didn't select a valid coding standard, so help them
                // out by letting them know which standards are installed.
                $installedStandards = PHP_CodeSniffer::getInstalledStandards();
                $numStandards = count($installedStandards);
                $errMsg = '';

                if ($numStandards === 0) {
                    $errMsg = 'No coding standards are installed.';
                } else {
                    $lastStandard = array_pop($installedStandards);

                    if ($numStandards === 1) {
                        $errMsg = 'The only coding standard installed is ' . $lastStandard;
                    } else {
                        $standardList = implode(', ', $installedStandards);
                        $standardList .= ' and ' . $lastStandard;
                        $errMsg = 'The installed coding standards are ' . $standardList;
                    }
                }

                throw new BuildException(
                    'ERROR: the "' . $standard . '" coding standard is not installed. ' . $errMsg,
                    $this->getLocation()
                );
            }
        }

        if (!$this->showWarnings) {
            $codeSniffer->cli->warningSeverity = 0;
        }

        // nasty integration hack
        $values = $codeSniffer->cli->getDefaults();
        $_SERVER['argv'] = ['t'];
        $_SERVER['argc'] = 1;
        foreach ($this->formatters as $fe) {
            if ($fe->getUseFile()) {
                $_SERVER['argv'][] = '--report-' . $fe->getType() . '=' . $fe->getOutfile();
            } else {
                $_SERVER['argv'][] = '--report-' . $fe->getType();
            }

            $_SERVER['argc']++;
        }

        if ($this->cache) {
            ReportsPhingRemoveFromCache::setCache($this->cache);
            // add a fake report to remove from cache
            $_SERVER['argv'][] = '--report-phingRemoveFromCache';
            $_SERVER['argc']++;
        }

        $codeSniffer->process($fileList, $this->standards, $this->sniffs, $this->noSubdirectories);
        $_SERVER['argv'] = [];
        $_SERVER['argc'] = 0;

        if ($this->cache) {
            ReportsPhingRemoveFromCache::setCache(null);
            $this->cache->commit();
        }

        $this->printErrorReport($codeSniffer);

        // generate the documentation
        if ($this->docGenerator !== '' && $this->docFile !== null) {
            ob_start();

            $codeSniffer->generateDocs($this->standards, $this->sniffs, $this->docGenerator);

            $output = ob_get_contents();
            ob_end_clean();

            // write to file
            $outputFile = $this->docFile->getPath();
            $check = file_put_contents($outputFile, $output);

            if ($check === false) {
                throw new BuildException('Error writing doc to ' . $outputFile);
            }
        } elseif ($this->docGenerator !== '' && $this->docFile === null) {
            $codeSniffer->generateDocs($this->standards, $this->sniffs, $this->docGenerator);
        }

        if ($this->haltonerror && $codeSniffer->reporting->totalErrors > 0) {
            throw new BuildException('phpcodesniffer detected ' . $codeSniffer->reporting->totalErrors . ' error' . ($codeSniffer->reporting->totalErrors > 1 ? 's' : ''));
        }

        if ($this->haltonwarning && $codeSniffer->reporting->totalWarnings > 0) {
            throw new BuildException('phpcodesniffer detected ' . $codeSniffer->reporting->totalWarnings . ' warning' . ($codeSniffer->reporting->totalWarnings > 1 ? 's' : ''));
        }

        $_SERVER['argv'] = $oldArgs;
        $_SERVER['argc'] = count($oldArgs);
        chdir($cwd);
    }
540038
public function init()
	{
		$this->help_str = 'Send a mail using the instance mail configuration. '.PHP_EOL;

		$this->setNewParam( 'S', 'subject', 'Mail subject.', true, true );
		$this->setNewParam( 'F', 'filecontent', 'Mail body. Don\'t define this params to send  the stdin', true, true );
		$this->setNewParam( 'H', 'html', 'Use this flag to send the mail with html code. Text is default.', false, false );
	}
1095442
protected function configure()
    {
        if (is_readable($configFile = $this->config('config.path') . '/config.php')) {
            $config = include $configFile;
            if (!is_array($config)) {
                $config = (array) $config;
            }
            $this->config($config);
        }
        if (is_readable($configFile = $this->config('config.path') . '/config-' . $this->config('mode') . '.php')) {
            $config = include $configFile;
            if (!is_array($config)) {
                $config = (array) $config;
            }
            $this->config($config);
        }

        date_default_timezone_set($this->config('bono.timezone') ?: 'UTC');
    }
597020
protected function configure(): void
    {
        $this->setName('dependency-guard');
        $this->setDescription(
            'Check Composer dependencies for a --no-dev install.'
        );

        $this->addOption(
            'format',
            'f',
            InputOption::VALUE_REQUIRED,
            'The output format. '
                . implode(
                    ', ',
                    array_map(
                        function (string $format) : string {
                            return sprintf('<comment>%s</comment>', $format);
                        },
                        $this->exporterFactory->getOutputFormats()
                    )
                ),
            ViolationExporterFactoryInterface::DEFAULT_FORMAT
        );
    }
757060
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();

        if (isset($tokens[($stackPtr + 1)]) === false)
        {
            return;
        }

        // Single space after the keyword.
        $found = 1;

        if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE)
        {
            $found = 0;
        }
        elseif ($tokens[($stackPtr + 1)]['content'] !== ' ')
        {
            if (strpos($tokens[($stackPtr + 1)]['content'], $phpcsFile->eolChar) !== false)
            {
                $found = 'newline';
            }
            else
            {
                $found = strlen($tokens[($stackPtr + 1)]['content']);
            }
        }

        if ($found !== 1
            && $tokens[($stackPtr)]['code'] !== T_ELSE
            && $tokens[($stackPtr)]['code'] !== T_TRY
            && $tokens[($stackPtr)]['code'] !== T_DO
            && $tokens[($stackPtr)]['code'] !== T_FINALLY
        )
        {
            $error = 'Expected 1 space after %s keyword; %s found';
            $data  = [
                      strtoupper($tokens[$stackPtr]['content']),
                      $found,
                     ];
            $fix   = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterKeyword', $data);

            if ($fix === true)
            {
                if ($found === 0)
                {
                    $phpcsFile->fixer->addContent($stackPtr, ' ');
                }
                else
                {
                    $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
                }
            }
        }

        // Single newline after opening brace.
        if (isset($tokens[$stackPtr]['scope_opener']) === true)
        {
            $opener = $tokens[$stackPtr]['scope_opener'];

            for ($next = ($opener + 1); $next < $phpcsFile->numTokens; $next++)
            {
                $code = $tokens[$next]['code'];

                if ($code === T_WHITESPACE)
                {
                    continue;
                }

                // Skip all empty tokens on the same line as the opener.
                if ($tokens[$next]['line'] === $tokens[$opener]['line']
                    && (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true
                    || $code === T_CLOSE_TAG)
                )
                {
                    continue;
                }

                // We found the first bit of a code, or a comment on the
                // following line.
                break;
            }

            $found = ($tokens[$next]['line'] - $tokens[$opener]['line']);

            if ($found !== 1)
            {
                $error = 'Expected 1 newline after opening brace; %s found';
                $data  = [$found];
                $fix   = $phpcsFile->addFixableError($error, $opener, 'NewlineAfterOpenBrace', $data);

                if ($fix === true)
                {
                    $phpcsFile->fixer->beginChangeset();

                    for ($i = ($opener + 1); $i < $next; $i++)
                    {
                        if ($found > 0 && $tokens[$i]['line'] === $tokens[$next]['line'])
                        {
                            break;
                        }

                        $phpcsFile->fixer->replaceToken($i, '');
                    }

                    $phpcsFile->fixer->addContent($opener, $phpcsFile->eolChar);
                    $phpcsFile->fixer->endChangeset();
                }
            }
        }
        elseif ($tokens[$stackPtr]['code'] === T_WHILE)
        {
            // Zero spaces after parenthesis closer.
            $closer = $tokens[$stackPtr]['parenthesis_closer'];
            $found  = 0;

            if ($tokens[($closer + 1)]['code'] === T_WHITESPACE)
            {
                if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false)
                {
                    $found = 'newline';
                }
                else
                {
                    $found = strlen($tokens[($closer + 1)]['content']);
                }
            }

            if ($found !== 0)
            {
                $error = 'Expected 0 spaces before semicolon; %s found';
                $data  = [$found];
                $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceBeforeSemicolon', $data);

                if ($fix === true)
                {
                    $phpcsFile->fixer->replaceToken(($closer + 1), '');
                }
            }
        }//end if

        // Only want to check multi-keyword structures from here on.
        if ($tokens[$stackPtr]['code'] === T_DO)
        {
            if (isset($tokens[$stackPtr]['scope_closer']) === false)
            {
                return;
            }

            $closer = $tokens[$stackPtr]['scope_closer'];
        }
        elseif ($tokens[$stackPtr]['code'] === T_ELSE
            || $tokens[$stackPtr]['code'] === T_ELSEIF
            || $tokens[$stackPtr]['code'] === T_CATCH
        )
        {
            $closer = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);

            if ($closer === false || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET)
            {
                return;
            }
        }
        else
        {
            return;
        }

        // Own line for do, else, elseif, catch and no white space after closing brace
        $found = 0;

        if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
            && $tokens[($closer + 1)]['content'] !== $phpcsFile->eolChar
        )
        {
            $found = strlen($tokens[($closer + 1)]['content']);
        }

        if (0 !== $found)
        {
            $error = 'Expected 0 space after closing brace; %s found';
            $data  = [$found];
            $fix   = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data);

            if (true === $fix)
            {
                $phpcsFile->fixer->replaceToken(($closer + 1), '' . $phpcsFile->eolChar);
            }
        }

        if ($tokens[($closer + 1)]['content'] !== $phpcsFile->eolChar && 0 === $found)
        {
            $error  = 'Definition of do,else,elseif,catch must be on their own line.';
            $fix    = $phpcsFile->addFixableError($error, $closer, 'NewLineAfterCloseBrace');
            $blanks = substr($tokens[($closer - 1)]['content'], strpos($tokens[($closer - 1)]['content'], $phpcsFile->eolChar));
            $spaces = str_repeat(' ', strlen($blanks));

            if (true === $fix)
            {
                $phpcsFile->fixer->beginChangeset();
                $phpcsFile->fixer->addContent($closer, $phpcsFile->eolChar);
                $phpcsFile->fixer->addContentBefore(($closer + 1), $spaces);
                $phpcsFile->fixer->endChangeset();
            }
        }
    }
547717
protected function configure()
	{
		$this->setName( self::$defaultName );
		$this->setDescription( 'Clears the content cache' );
		$this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to clear the cache like "default unittest" (none for all)' );
	}
425256
protected function _init()
    {
        $this->url = Config::get('chikka::url');
        $this->client_id = Config::get('chikka::client_id');
        $this->secret_key = Config::get('chikka::secret_key');
        $this->short_code = Config::get('chikka::short_code');
    }