Returns a count of issues per scope (class/trait/method/function)
present in this file, indexed by their (start) line number
@return array ie [['name' => 'Whatever::foo', 'startLine' => 15, 'issues' => 2]...]
333762
public function getContextsNumberOfIssues()
	{
		$list = [];

		foreach ($this->getChildren() as $child)
		{
			if ($child instanceof FunctionContext)
			{
				$list[] = [
					'name'      => $child->getName(),
					'startLine' => $child->startLine,
					'issues'    => $child->getIssuesCount()
				];
			}
			else
			{
				// this might be a class, look for methods
				foreach ($child->getChildren() as $method)
				{
					if ($method instanceof MethodContext)
					{
						$list[] = [
							'name'      => $child->getName().'::'.$method->getName(),
							'startLine' => $method->startLine,
							'issues'    => $method->getIssuesCount()
						];
					}
				}
			}
		}

		return $list;
	}
1015882
public function getErrorsAsArray()
    {
        $errors = array();
        $errors['HasErrors'] = $this->hasErrors();
        $errors['ErrorCount'] = $this->getErrorCount();
        $errors['Errors'] = (array)$this->errors;

        /*
        $errors['ErrorString'] = '';
        $errors['FieldErrorString'] = '';
        $errors['GlobalErrorString'] = '';
        $errors['ErrorStringHTML'] = '';
        $errors['FieldErrorStringHTML'] = '';
        $errors['GlobalErrorStringHTML'] = '';

        */

        foreach ((array)$this->errors as $err) {

            if ($err instanceof FieldValidationError) {
                $field = $err->getFieldResolved();
                $errors['Has'.$field.'Error'] = true;
                // $errors[$field.'ErrorMessage'] = $err->getDefaultErrorMessage();
                // $errors[$field.'ErrorCode'] = $err->getErrorCode();
                $errors['ErrorFields'][] = $field;
                $errors['ErrorValues'][] = $err->getValue();

                // $errors['FieldErrorString'] .= $err->getDefaultErrorMessage()."\n";
                // $errors['FieldErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';
            } else {
                // $errors['GlobalErrorString'] .= $err->getDefaultErrorMessage()."\n";
                // $errors['GlobalErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';
            }

            $errors['ErrorCodes'][] = $err->getErrorCode();
            // $errors['ErrorMessages'][] = $err->getDefaultErrorMessage();
            // $errors['ErrorString'] .= $err->getDefaultErrorMessage()."\n";
            // $errors['ErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';
        }

        return $errors;

    }
359159
public function getInspectionData()
    {
        return [
            static::PARAM_CLASSES    => $this->declaredClasses,
            static::PARAM_INTERFACES => $this->declaredInterfaces,
            static::PARAM_TRAITS     => $this->declaredTraits,
            static::PARAM_FUNCTIONS  => $this->declaredFunctions,
            static::PARAM_CONSTANTS  => $this->declaredConstants,
        ];
    }
70907
public function getErrors()
    {
        foreach ($this->errors as $i => $error) {
            if ($error instanceof \Closure) {
                $this->errors[$i] = (string) $error();
            } elseif (!\is_string($error)) {
                $this->errors[$i] = (string) $error;
            }
        }

        return $this->errors;
    }
384320
public function getAllErrors() {

        $errors = array();
        // First the table itself
        if ($this->getError()) {
            $errors[] = $this->getError();
        }
        // Delegate to fields
        if ($fields = $this->getFields()) {
            foreach ($fields as $field) {
                if ($field->getError()) {
                    $errors[] = $field->getError();
                }
            }
        }
        // Delegate to keys
        if ($keys = $this->getKeys()) {
            foreach ($keys as $key) {
                if ($key->getError()) {
                    $errors[] = $key->getError();
                }
            }
        }
        // Delegate to indexes
        if ($indexes = $this->getIndexes()) {
            foreach ($indexes as $index) {
                if ($index->getError()) {
                    $errors[] = $index->getError();
                }
            }
        }
        // Return decision
        if (count($errors)) {
            return $errors;
        } else {
            return false;
        }
    }
940613
public function stat(): array
    {
        $result = fstat($this->handle);

        if (false === $result) {
            $message = 'Could not stat file.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return $result;
    }
595095
protected function checkInstances()
    {
        $output = [];
        foreach ($this->checks as $check) {
            list($checkClass, $checkTitle) = $check;
            if (is_string($checkClass)) {
                $checkInst = Injector::inst()->create($checkClass);
                if ($checkInst instanceof EnvironmentCheck) {
                    $output[] = [$checkInst, $checkTitle];
                } else {
                    throw new InvalidArgumentException(
                        "Bad EnvironmentCheck: '$checkClass' - the named class doesn't implement EnvironmentCheck"
                    );
                }
            } elseif ($checkClass instanceof EnvironmentCheck) {
                $output[] = [$checkClass, $checkTitle];
            } else {
                throw new InvalidArgumentException("Bad EnvironmentCheck: " . var_export($check, true));
            }
        }
        return $output;
    }
741257
public static function getAllScopes()
    {
        return array(
            self::SCOPE_MANAGE_ACCOUNTS,
            self::SCOPE_MANAGE_SUBSCRIPTIONS,
            self::SCOPE_COLLECT_PAYMENTS,
            self::SCOPE_PREAPPROVE_PAYMENTS,
            self::SCOPE_VIEW_USER,
            self::SCOPE_SEND_MONEY
        );
    }
591017
public static function caller ( )
	{
		$backtrace = V(debug_backtrace());

		foreach ($backtrace as $line) {
			$line = A($line);

			if ($line->class === 'Bacon\Log') continue;

			return A([
				'class'  => $line->class,
				'file'   => $line->file,
				'method' => $line->function,
				'object' => $line->object
			]);
		}

		/*
		if (isset($backtrace[2]['class'])) {
			return $backtrace[2]['class'];
		} elseif (isset($backtrace[2]['file'])) {
			return $backtrace[2]['file'];
		} else {
			return $backtrace[0]['file'];
		}
		 */
	}
255255
public function getBetterTrace() {
        $trace = $this->betterTrace;

        if (!$trace) {
            // transform the original stacktrace into a better one
            $trace = DebugHelper::fixTrace($this->getTrace(), $this->getFile(), $this->getLine());

            // drop the first frame if the exception was created in the registered error handler
            if (DebugHelper::getFQFunctionName($trace[0]) == ErrorHandler::class.'::handleError') {
                \array_shift($trace);

                // if the error was triggered by include/require/_once: fix the next frame, it's wrong
                if (sizeof($trace) > 1) {
                    $function = DebugHelper::getFQFunctionName($trace[0]);
                    if ($function=='include' || $function=='include_once' || $function=='require' || $function=='require_once') {
                        if (isset($trace[0]['file']) && isset($trace[1]['file'])) {
                            if ($trace[0]['file'] == $trace[1]['file']) {
                                if (isset($trace[0]['line']) && isset($trace[1]['line'])) {
                                    if ($trace[0]['line'] == $trace[1]['line']) {
                                        unset($trace[0]['file'], $trace[0]['line']);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // store the new stacktrace
            $this->betterTrace = $trace;
        }
        return $trace;
    }
1096468
private function loadReturnsOfThisFunction(): array
    {
        $returnPositions = TokenHelper::findNextAll(
            $this->file->getBaseFile(),
            [T_RETURN],
            $this->stackPos + 1,
            $this->token['scope_closer']
        );

        return array_filter($returnPositions, function (int $returnPos): bool {
            $possibleClosure = $this->file->findPrevious([T_CLOSURE, T_FUNCTION], $returnPos - 1, $this->stackPos);

            return $possibleClosure === $this->stackPos;
        });
    }
1109518
public function getOptions(): int
    {
        $options = $this->traitGetOptions();

        if (! (bool)($options & \JSON_THROW_ON_ERROR)) {
            $options |= \JSON_THROW_ON_ERROR;
        }

        return $options;
    }
908656
public static function count(/* ... */)
	{
		$args = func_get_args();
		$options = static::extractAndValidateOptions($args);
		$options['select'] = 'COUNT(*)';

		if (!empty($args) && !is_null($args[0]) && !empty($args[0]))
		{
			if (is_hash($args[0]))
				$options['conditions'] = $args[0];
			else
				$options['conditions'] = call_user_func_array('static::pk_conditions',$args);
		}

		$table = static::table();
		$sql = $table->options_to_sql($options);
		$values = $sql->get_where_values();
		return static::connection()->query_and_fetch_one($sql->to_s(),$values);
	}
675363
public function getCauseMessage()
    {
        $causes  = [];
        $current = [
            'class'   => get_class($this),
            'message' => $this->getMessage(),
            'code'    => $this->getCode(),
            'file'    => $this->getFile(),
            'line'    => $this->getLine()
        ];

        $causes[] = $current;
        $previous = $this->getPrevious();

        while ($previous !== null) {
            if ($previous instanceof Exception) {
                $prevCauses = $previous->getCauseMessage();

                foreach ($prevCauses as $cause) {
                    $causes[] = $cause;
                }
            } elseif ($previous instanceof PhpException) {
                $causes[] = [
                    'class'   => get_class($previous),
                    'message' => $previous->getMessage(),
                    'code'    => $previous->getCode(),
                    'file'    => $previous->getFile(),
                    'line'    => $previous->getLine()
                ];
            }

            $previous = $previous->getPrevious();
        }

        return $causes;
    }
1308475
private function getServerArguments() {
        $args = $_SERVER['argv'];
        array_shift($args);

        $args = $this->parseArgs($args);

        return $args;
    }
656671
protected function getTrace()
    {
        $backtrace = debug_backtrace();
        $index = null;
        $hasNull = false;
        $realClassName = static::__getRealClassName();
        foreach($backtrace as $i => $item)
        {
            if($realClassName === $item['class'])
            {
                $index = $i + 2;
                break;
            }
        }
        if(null === $index)
        {
            return [];
        }
        return array_splice($backtrace, $index);
    }
258258
public function getMethodMutations(
        $method_name,
        Context $context
    ) {
        $project_analyzer = $this->getFileAnalyzer()->project_analyzer;
        $codebase = $project_analyzer->getCodebase();

        foreach ($this->class->stmts as $stmt) {
            if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod &&
                strtolower($stmt->name->name) === strtolower($method_name)
            ) {
                $method_analyzer = new MethodAnalyzer($stmt, $this);

                $method_analyzer->analyze($context, null, true);
            } elseif ($stmt instanceof PhpParser\Node\Stmt\TraitUse) {
                foreach ($stmt->traits as $trait) {
                    $fq_trait_name = self::getFQCLNFromNameObject(
                        $trait,
                        $this->source->getAliases()
                    );

                    $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name);
                    $trait_node = $codebase->classlikes->getTraitNode($fq_trait_name);
                    $trait_aliases = $codebase->classlikes->getTraitAliases($fq_trait_name);
                    $trait_analyzer = new TraitAnalyzer(
                        $trait_node,
                        $trait_file_analyzer,
                        $fq_trait_name,
                        $trait_aliases
                    );

                    foreach ($trait_node->stmts as $trait_stmt) {
                        if ($trait_stmt instanceof PhpParser\Node\Stmt\ClassMethod &&
                            strtolower($trait_stmt->name->name) === strtolower($method_name)
                        ) {
                            $method_analyzer = new MethodAnalyzer($trait_stmt, $trait_analyzer);

                            $actual_method_id = (string)$method_analyzer->getMethodId();

                            if ($context->self && $context->self !== $this->fq_class_name) {
                                $analyzed_method_id = (string)$method_analyzer->getMethodId($context->self);
                                $declaring_method_id = $codebase->methods->getDeclaringMethodId($analyzed_method_id);

                                if ($actual_method_id !== $declaring_method_id) {
                                    break;
                                }
                            }

                            $method_analyzer->analyze($context, null, true);
                        }
                    }
                }
            }
        }
    }