Copyright tag must be in the form 'xxxx-xxxx Barracuda Networks, Inc.'.

@param int $errorPos The line number where the error occurs.

@return void
486144
protected function processCopyrights($errorPos)
    {
        $copyrights = $this->commentParser->getCopyrights();
        $copyright  = $copyrights[0];
        if ($copyright !== null) {
            $content = $copyright->getContent();
            if (empty($content) === true) {
                $error = 'Content missing for @copyright tag in file comment';
                $this->currentFile->addError($error, $errorPos, 'MissingCopyright');
            } else if (preg_match('/^([0-9]{4})(-[0-9]{4})? (\.*\)$/', $content) === 0) {
                $error = 'Expected "xxxx-xxxx Barracuda Networks, Inc." for copyright declaration';
                $this->currentFile->addError($error, $errorPos, 'IncorrectCopyright');
            }
        }
    }
473759
public function writeHookFile(string $hook) : void
    {
        $hooksDir = $this->repository->getHooksDir();
        $hookFile = $hooksDir . DIRECTORY_SEPARATOR . $hook;
        $doIt     = true;

        // if hook is configured and no force option is set
        // ask the user if overwriting the hook is ok
        if ($this->needInstallConfirmation($hook)) {
            $ans  = $this->io->ask('  <comment>The \'' . $hook . '\' hook exists! Overwrite? [y,n]</comment> ', 'n');
            $doIt = IOUtil::answerToBool($ans);
        }

        if ($doIt) {
            $code = $this->getHookSourceCode($hook);
            $file = new File($hookFile);
            $file->write($code);
            chmod($hookFile, 0755);
            $this->io->write('  <info>\'' . $hook . '\' hook installed successfully</info>');
        }
    }
605590
private function checkAndRegisterSortingError(): void
    {
        $orgTokens = $this->getTagTokens();
        $sortedTokens = $this->sortTokens($orgTokens);

        if (array_values($orgTokens) !== $sortedTokens) {
            $error = (new CodeWarning(
                static::CODE_WRONG_TAG_SORTING,
                self::MESSAGE_WRONG_TAG_SORTING,
                array_shift($orgTokens)['pointer']
            ))->setToken($this->token);

            $error->isFixable(true);

            throw $error;
        }
    }
316563
public function addWatermark($watermarkImage, $pos, $padding = 0, $opacity = 0)
		# Author:     Jarrod Oberto
		# Date:       18-11-09
		# Purpose:    Add watermark image
		# Param in:   (str) $watermark: The watermark image
		#       (str) $pos: Could be a pre-determined position such as:
		#           tl = top left,
		#           t  = top (middle),
		#           tr = top right,
		#           l  = left,
		#           m  = middle,
		#           r  = right,
		#           bl = bottom left,
		#           b  = bottom (middle),
		#           br = bottom right
		#         Or, it could be a co-ordinate position such as: 50x100
		#
		#       (int) $padding: If using a pre-determined position you can
		#         adjust the padding from the edges by passing an amount
		#         in pixels. If using co-ordinates, this value is ignored.
		# Param out:
		# Reference:  http://www.php.net/manual/en/image.examples-watermark.php
		# Notes:      Based on example in reference.
		#
		#
	{

		// Load the stamp and the photo to apply the watermark to
		$stamp = $this->openImage($watermarkImage);    # stamp
		$im = $this->imageResized;            # photo

		// *** Get stamps width and height
		$sx = imagesx($stamp);
		$sy = imagesy($stamp);

		// *** Find co-ords to place image
		$posArray = $this->calculatePosition($pos, $padding, $sx, $sy);
		$x = $posArray['width'];
		$y = $posArray['height'];

		// *** Set watermark opacity
		if (fix_strtolower(strrchr($watermarkImage, '.')) == '.png')
		{

			$opacity = $this->invertTransparency($opacity, 100);
			$this->filterOpacity($stamp, $opacity);
		}

		// Copy the watermark image onto our photo
		imagecopy($im, $stamp, $x, $y, 0, 0, imagesx($stamp), imagesy($stamp));

	}
1125684
private function handleCurlError($error, $errorNumber, $verbose): void
    {
        if (!$error) {
            return;
        }

        $errorMessage = "\ncURL transport error: $errorNumber - $error";

        $transportException = new TransportException($errorMessage);

        rewind($verbose);

        $verboseLog = stream_get_contents($verbose);

        if ($verboseLog !== false) {
            $verboseLog = htmlspecialchars($verboseLog);

            $transportException->setData($verboseLog);
        }

        throw $transportException;
    }
938233
protected function fixeUse(int $endPos, int $usePos): void
    {
        $indentation = $this->getIndentationForFix($usePos);
        $file = $this->getFile()->getBaseFile();
        $fixer = $file->fixer;

        $fixer->beginChangeset();

        $commaPointers = TokenHelper::findNextAll($file, T_COMMA, $usePos + 1, $endPos);
        foreach ($commaPointers as $commaPos) {
            $pointerAfterComma = TokenHelper::findNextEffective($file, $commaPos + 1);
            $fixer->replaceToken($commaPos, ';' . $file->eolChar . $indentation . 'use ');
            for ($i = $commaPos + 1; $i < $pointerAfterComma; $i++) {
                $fixer->replaceToken($i, '');
            }
        }

        $fixer->endChangeset();
    }
135235
protected function validateOnPost(ErrorCollection $errors)
    {
        $this->validateData([
            Schema::KEYWORD_ID => $this->getId(),
        ], [
            Schema::KEYWORD_ID => 'required|unique:' . Model::TABLE_NAME . ',' . Model::FIELD_ID,
        ], $errors);

        $this->validateAttributes([
            Schema::ATTR_NAME => 'required|max:' . Model::LENGTH_NAME,
        ], $errors);
    }
613746
public function logError( $errMsg, $context = null )
    {
        $errMsg = $context != null ? $errMsg . ' - ' . $context : $errMsg;
        error_log( $errMsg );
    }
96411
private function checkForContentInCopyrightTag(File $phpcs_file, $copyright_tag_ptr, $comment_end_ptr): void
    {
        $tokens = $phpcs_file->getTokens();
        $ptr    = $phpcs_file->findNext(T_DOC_COMMENT_STRING, $copyright_tag_ptr, $comment_end_ptr);
        if ($ptr !== false && $tokens[$ptr]['line'] === $tokens[$copyright_tag_ptr]['line']) {
            return;
        }

        $error = 'Content missing for ' . $this->copyright_tag . ' tag in File comment';
        if (!$phpcs_file->addFixableError($error, $copyright_tag_ptr, 'Empty ' . $this->copyright_tag . ' Tag')) {
            return;
        }

        $phpcs_file->fixer->addContent($copyright_tag_ptr, ' ' . $this->getCopyrightLine());
    }
1044945
protected function error( $text, $pos = null ) {
		if ( !$this->ignoreErrors ) {
			if ( $pos === null ) {
				$pos = $this->pos;
			}
			$this->listener->error( $text, $pos );
		}
	}
1282483
private function fixLinesBeforeFirstUse(
        int $firstUsePos,
        int $posBeforeFirstUse
    ): void {
        $file = $this->getFile();
        $file->fixer->beginChangeset();

        $posBeforeIndentation = TokenHelper::findPreviousContent(
            $file,
            T_WHITESPACE,
            $file->eolChar,
            $firstUsePos,
            $posBeforeFirstUse
        );

        if ($posBeforeIndentation !== null) {
            for ($i = $posBeforeFirstUse + 1; $i <= $posBeforeIndentation; $i++) {
                $file->fixer->replaceToken($i, '');
            }
        }
        for ($i = 0; $i <= self::LINES_BEFORE_FIRST_USE; $i++) {
            $file->fixer->addNewline($posBeforeFirstUse);
        }

        $file->fixer->endChangeset();
    }
1279988
protected function outputParagraphStart($maxPos)
	{
		// Do nothing if we're already in a paragraph, or if we don't use paragraphs
		if ($this->context['inParagraph']
		 || !($this->context['flags'] & self::RULE_CREATE_PARAGRAPHS))
		{
			return;
		}

		// Output the whitespace between $this->pos and $maxPos if applicable
		$this->outputWhitespace($maxPos);

		// Open the paragraph, but only if it's not at the very end of the text
		if ($this->pos < $this->textLen)
		{
			$this->output .= '<p>';
			$this->context['inParagraph'] = true;
		}
	}
115998
private function checkDeclaration(int $usePos): void
    {
        $file = $this->getFile()->getBaseFile();

        if (TokenHelper::findNextLocal($file, T_COMMA, $usePos + 1)) {
            $endPos = TokenHelper::findNext($file, [T_OPEN_CURLY_BRACKET, T_SEMICOLON], $usePos + 1);
            $tokens = $file->getTokens();

            if ($tokens[$endPos]['code'] === T_OPEN_CURLY_BRACKET) {
                $file->addError(
                    self::MESSAGE_MULTIPLE_TRAITS_PER_DECLARATION,
                    $usePos,
                    static::CODE_MULTIPLE_TRAITS_PER_DECLARATION
                );
            } else {
                $fix = $file->addFixableError(
                    self::MESSAGE_MULTIPLE_TRAITS_PER_DECLARATION,
                    $usePos,
                    static::CODE_MULTIPLE_TRAITS_PER_DECLARATION
                );

                if ($fix) {
                    $this->fixeUse($endPos, $usePos);
                }
            }
        }
    }
976249
protected function checkSaltPositionArgument($position): void
    {
        if (!in_array($position, [self::SALT_BEFORE, self::SALT_AFTER])) {
            throw new InvalidArgumentException(sprintf(
                '`%s` is an invalud argument, it has to be `` or ``',
                $position,
                self::SALT_BEFORE,
                self::SALT_AFTER
            ));
        }
    }
901695
public function registerSyntaxErrorEdit(array $server = null, array $post = null)
    {
        $server = $server ?: $_SERVER;
        $isBearAceSave = isset($server['HTTP_X_REQUESTED_WITH'])
            && strtolower($server['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'
            && $server['REQUEST_METHOD'] === 'POST'
            && isset($server['HTTP_X_BEAR_ACE']);

        if ($isBearAceSave) {
            try {
                $post = $post ?: $_POST;
                /** @noinspection PhpExpressionResultUnusedInspection */
                $editor = new Editor;
                (string)$editor
                    ->setRootPath('/')
                    ->setPath($post['file'])
                    ->save($post['contents']);
                exit(0);
            } catch (Exception $e) {
            }
        }

        // register syntax error editor
        register_shutdown_function($this->handler);
        return '';
    }
12466
public static function validatePos($pos)
    {
        $posLength = strlen($pos);

        if (1 > $posLength) {
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR1,
                $pos
            );
        }

        if (preg_match('/[^0-9\-#]/', $pos)) { // alphabetic characters etc. are not valid
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR2,
                $pos
            );
        }

        if (strpos($pos, '-') === $posLength - 1) { // something like 123- is not valid
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR3,
                $pos
            );
        }

        if (0 === strpos($pos, '-')) { // something like -123 ist not valid
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR4,
                $pos
            );
        }

        if (strpos($pos, '-') !== strrpos($pos, '-')) { // only one - is allowed
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR5,
                $pos
            );
        }

        $_pos = explode('-', $pos);

        if (2 < count($_pos)) {
            throw new InvalidMARCspecException(
                InvalidMARCspecException::PR.
                InvalidMARCspecException::PR6,
                $pos
            );
        }

        if (1 == count($_pos)) {
            $_pos[1] = null;
        }

        return $_pos;
    }
39317
private static function setErrors($errors) {

        $std_rpc_errors = array(
            -32700 => "Parse error",
            -32701 => "Parse error - Unsupported encoding",
            -32702 => "Parse error - Invalid character for encoding",
            -32600 => "Invalid Request",
            -32601 => "Method not found",
            -32602 => "Invalid params",
            -32603 => "Internal error",
            -32500 => "Application error",
            -32400 => "System error",
            -32300 => "Transport error",
            // Predefined Comodojo Errors
            -31000 => "Multicall is available only in XMLRPC",
            -31001 => "Recursive system.multicall forbidden"
        );

        foreach ( $std_rpc_errors as $code => $message ) {

            $errors->add($code, $message);

        }

    }