Uses git diff to figure out what the diff line position is, based on the error line number.
@param Builder $builder
@param $file
@param $line
@return int|null
556306
protected function getDiffLineNumber(Builder $builder, $file, $line)
    {
        $line = (integer)$line;

        $builder->logExecOutput(false);

        $prNumber = $this->getExtra('pull_request_number');
        $path = $builder->buildPath;

        if (!empty($prNumber)) {
            $builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
        } else {
            $commitId = $this->getCommitId();
            $compare = $commitId == 'Manual' ? 'HEAD' : $commitId;
            $builder->executeCommand('cd %s && git diff %s^^ "%s"', $path, $compare, $file);
        }

        $builder->logExecOutput(true);

        $diff = $builder->getLastOutput();

        $helper = new Diff();
        $lines = $helper->getLinePositions($diff);

        return isset($lines[$line]) ? $lines[$line] : null;
    }
751828
public Settings load(String file, CommandBuilder builder) throws CommandLineException {

		Scanner scanner = null;
		try {

			File config = new File(file);
			Assert.isTrue(config.exists(), "File '" + file + "' does not exist");
			Assert.isFalse(config.isDirectory(), "File '" + file + "' is a directory");
			Assert.isTrue(config.canRead(), "File '" + file + "' cannot be read");

			scanner = new Scanner(config);

			ArrayList<String> list = new ArrayList<>();
			while (scanner.hasNextLine()) {
				list.add(scanner.nextLine());
			}

			return parse(list, builder);
		}
		catch (FileNotFoundException e) {

			log.error("File not found: " + e.getMessage());
			throw new CommandLineException("File: '" + file + "', not found!");
		}
		finally {

			if (scanner != null) {
				scanner.close();
			}
		}
	}
602698
protected function postCloneSetup(Builder $builder, $cloneTo)
    {
        $buildType = $this->getExtra('build_type');

        $success = true;

        try {
            if (!empty($buildType) && $buildType == 'pull_request') {
                $remoteUrl = $this->getExtra('remote_url');
                $remoteBranch = $this->getExtra('remote_branch');

                $cmd = 'cd "%s" && git checkout -b phpci/' . $this->getId() . ' %s && git pull -q --no-edit %s %s';
                if ($this->canRunSsh()) {
                    $success = $this->runBySsh($builder, $cloneTo, $cmd, [$cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch]);
                } else {
                    $success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch(), $remoteUrl, $remoteBranch);
                }
            }
        } catch (\Exception $ex) {
            $success = false;
        }

        if ($success) {
            $success = parent::postCloneSetup($builder, $cloneTo);
        }

        return $success;
    }
894100
public static function displayError($code,$message,$file,$line)
    {
        if(YII_DEBUG) {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message ($file:$line)</p>\n";
            echo '<pre>';

            $trace=debug_backtrace();
            // skip the first 3 stacks as they do not tell the error position
            if(count($trace)>3)
                $trace=array_slice($trace,3);
            foreach($trace as $i=>$t) {
                if(!isset($t['file']))
                    $t['file']='unknown';
                if(!isset($t['line']))
                    $t['line']=0;
                if(!isset($t['function']))
                    $t['function']='unknown';
                echo "#$i {$t['file']}({$t['line']}): ";
                if(isset($t['object']) && is_object($t['object']))
                    echo get_class($t['object']).'->';
                echo "{$t['function']}()\n";
            }

            echo '</pre>';
        } else {
            echo "<h1>PHP Error [$code]</h1>\n";
            echo "<p>$message</p>\n";
        }
    }
677235
public static function error_handler($number, $message, $file, $line)
    {
        $msg = "$message in $file on line $line";
        if (($number !== E_NOTICE) && ($number < 2048)) {
            self::errorMessage($msg, true);
            self::customErrorMsg();
        }
        return 0;
    }
106063
public function onError($code, $message, $file, $line)
    {
        $this->lastError = [
            'message' => $message,
            'file' => $file,
            'line' => $line
        ];

        $trace = debug_backtrace();
        if (count($trace) > 0 && !isset($trace[0]['file'])) {
            array_shift($trace);
        }

        switch ($code) {
            case E_NOTICE:
            case E_USER_NOTICE:
                $exc = new Errors\Notice($message, $trace);
                break;
            case E_WARNING:
            case E_USER_WARNING:
                $exc = new Errors\Warning($message, $trace);
                break;
            case E_ERROR:
            case E_CORE_ERROR:
            case E_RECOVERABLE_ERROR:
            case E_USER_ERROR:
                $exc = new Errors\Fatal($message, $trace);
                break;
            default:
                $exc = new Errors\Error($message, $trace);
                break;
        }
        $this->notifier->notify($exc);
        return false;
    }
533137
public function getDiffFile($file)
    {
        $args = [
            '-r', '-p', '-m', '-M', '--no-commit-id', '--full-index', $this->revision,
            '--', $this->repository->getWikiDir().$file,
        ];

        $diff = Diff::parse($this->repository->run('diff-tree', $args));
        $diff->setRepository($this->repository);

        return $diff;
    }
766318
public static function error_log($errn,$errstr,$file,$line,$context){
		LogMaster::log($errstr." at ".$file." line ".$line);
	}
818810
public function handler($number, $message, $file, $line, $context) {

		if(0 === error_reporting()) { 
			return;
		}

		$this -> error = new Error();
		$this -> error -> setFile($file); 
		$this -> error -> setMessage($message); 
		$this -> error -> setNumber($number); 
		$this -> error -> setLine($line); 
		$this -> error -> setDate(new DateTime()); 
		$this -> error -> setContext($context); 
		$this -> error -> setBacktrace(debug_backtrace(null, 5));
		$this -> error -> setIp(Request :: getIp());

		switch($this -> error -> getNumber()) {

			case E_ERROR :
			case E_CORE_ERROR :
			case E_COMPILE_ERROR :
			case E_PARSE :
				$this -> error -> setType('FATAL');
			break;
			
			case E_USER_ERROR :
			case E_RECOVERABLE_ERROR :
				$this -> error -> setType('ERROR');
			break;
		
			case E_WARNING :
			case E_CORE_WARNING :
			case E_COMPILE_WARNING :
			case E_USER_WARNING :
				$this -> error -> setType('WARNING');
			break;
		
			case E_NOTICE :
			case E_USER_NOTICE :
				$this -> error -> setType('INFO');
			break;
			
			case E_STRICT :
				$this -> error -> setType('STRICT');
			break;
		}

		$this -> action();
	}
1272711
public static function errorHandler($code, $message, $file, $line)
    {

        if (error_reporting() === 0) {
            // This error code is not included in error_reporting
            return false;
        }
        throw new \sb\Exception($code, $message, $file, $line);
    }
821234
public function logLoadFile($file, $method = null, $line = null)
    {
        if (self::getConfig('log', 'loadFile')) {
            $this->logMessage('LOAD FILE', 'Loading File : "' . $file . '"', $method, $line);
        }
    }
185041
public function on_error( $num, $str, $file, $line, $context = NULL ) {

		$log_context = [];
		if ( $context ) {
			$skip_keys   = array_merge( array_keys( $GLOBALS ), self::$super_globals_keys );
			$skip        = array_fill_keys( $skip_keys, '' );
			$log_context = array_filter( array_diff_key( (array) $context, $skip ) );
		}

		$log_context[ 'file' ] = $file;
		$log_context[ 'line' ] = $line;

		// Log the PHP error.
		do_action(
			\Inpsyde\Wonolog\LOG,
			new Log( $str, self::$errors_level_map[ $num ], Channels::PHP_ERROR, $log_context )
		);

		return FALSE;
	}
529125
public static int countFileLines(final File file) {
        int res = -1;

        try (LineNumberReader reader = new LineNumberReader(new FileReader(file));) {

            // Read each line to increment the line number of the reader
            while (reader.readLine() != null) {
                ;// NOSONAR Just Count lines
            }
            // Extract the current line number
            res = reader.getLineNumber();

        } catch (final IOException e) {
            LOGGER.error(COUNT_LINES_ERROR, e, file.getAbsolutePath());
        }
        return res;
    }
93481
protected function initializeFromBuilder(Builder $builder)
    {
        $this->setModel($builder->getModel())
            ->setEagerLoads($builder->getEagerLoads());

        $builder->macro('getProtected', function (Builder $builder, string $property) {
            return $builder->{$property};
        });

        $this->scopes = $builder->getProtected('scopes');

        $this->localMacros = $builder->getProtected('localMacros');

        $this->onDelete = $builder->getProtected('onDelete');
    }
750677
private function beforeGet(Builder $builder): void {
    $this->remapBuilderColumns($builder);
    $this->remapWheres($builder);
  }
304017
protected function lint($file)
    {
        $command = $this->executable . ' -output-format ' . escapeshellarg(
            'file:__FILE__;line:__LINE__;message:__ERROR__'
        ) . ' ';

        if (isset($this->conf)) {
            $command .= '-conf ' . escapeshellarg($this->conf->getPath()) . ' ';
        }

        $command .= '-process ';

        if (file_exists($file)) {
            if (is_readable($file)) {
                if ($this->cache) {
                    $lastmtime = $this->cache->get($file);

                    if ($lastmtime >= filemtime($file)) {
                        $this->log("Not linting '" . $file . "' due to cache", Project::MSG_DEBUG);

                        return false;
                    }
                }

                $messages = [];
                exec($command . '"' . $file . '"', $messages, $return);

                if ($return > 100) {
                    throw new BuildException("Could not execute Javascript Lint executable '{$this->executable}'");
                }

                $summary = $messages[count($messages) - 1];

                preg_match('/(\d+)\serror/', $summary, $matches);
                $errorCount = (count($matches) > 1 ? $matches[1] : 0);

                preg_match('/(\d+)\swarning/', $summary, $matches);
                $warningCount = (count($matches) > 1 ? $matches[1] : 0);

                $errors = [];
                $warnings = [];
                if ($errorCount > 0 || $warningCount > 0) {
                    $last = false;
                    foreach ($messages as $message) {
                        $matches = [];
                        if (preg_match('/^(\.*)\^$/', $message)) {
                            $column = strlen($message);
                            if ($last == 'error') {
                                $errors[count($errors) - 1]['column'] = $column;
                            } else {
                                if ($last == 'warning') {
                                    $warnings[count($warnings) - 1]['column'] = $column;
                                }
                            }
                            $last = false;
                        }
                        if (!preg_match('/^file:(.+);line:(\d+);message:(.+)$/', $message, $matches)) {
                            continue;
                        }
                        $msg = $matches[3];
                        $data = ['filename' => $matches[1], 'line' => $matches[2], 'message' => $msg];
                        if (preg_match('/^.*error:.+$/i', $msg)) {
                            $errors[] = $data;
                            $last = 'error';
                        } else {
                            if (preg_match('/^.*warning:.+$/i', $msg)) {
                                $warnings[] = $data;
                                $last = 'warning';
                            }
                        }
                    }
                }

                if ($this->showWarnings && $warningCount > 0) {
                    $this->log($file . ': ' . $warningCount . ' warnings detected', Project::MSG_WARN);
                    foreach ($warnings as $warning) {
                        $this->log(
                            '- line ' . $warning['line'] . (isset($warning['column']) ? ' column ' . $warning['column'] : '') . ': ' . $warning['message'],
                            Project::MSG_WARN
                        );
                    }
                    $this->hasWarnings = true;
                }

                if ($errorCount > 0) {
                    $this->log($file . ': ' . $errorCount . ' errors detected', Project::MSG_ERR);
                    if (!isset($this->badFiles[$file])) {
                        $this->badFiles[$file] = [];
                    }

                    foreach ($errors as $error) {
                        $message = 'line ' . $error['line'] . (isset($error['column']) ? ' column ' . $error['column'] : '') . ': ' . $error['message'];
                        $this->log('- ' . $message, Project::MSG_ERR);
                        $this->badFiles[$file][] = $message;
                    }
                    $this->hasErrors = true;
                } else {
                    if (!$this->showWarnings || $warningCount == 0) {
                        $this->log($file . ': No syntax errors detected', Project::MSG_VERBOSE);

                        if ($this->cache) {
                            $this->cache->put($file, filemtime($file));
                        }
                    }
                }
            } else {
                throw new BuildException('Permission denied: ' . $file);
            }
        } else {
            throw new BuildException('File not found: ' . $file);
        }
    }
984700
public function findPositionInSource($fileIndex, $line, $column)
    {
        foreach ($this->lines as $oLine) {
            $pos = $oLine->findPositionInSource($fileIndex, $line, $column);
            if ($pos !== null) {
                return $pos;
            }
        }
        return null;
    }