GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Trace::getChronology()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Gear;
15
16
// ------------------------------------------------------------------------
17
18
/**
19
 * O2System Gear Trace
20
 *
21
 * @package O2System\Gear
22
 */
23
class Trace
24
{
25
    /**
26
     * Trace::$backtrace
27
     *
28
     * @type    string name of called class
29
     */
30
    protected $backtrace = null;
31
32
    /**
33
     * Trace::$chronology
34
     *
35
     * @var array
36
     */
37
    protected $chronology = [];
38
39
    // ------------------------------------------------------------------------
40
41
    /**
42
     * Trace::__construct
43
     *
44
     * @param array $trace
45
     */
46
    public function __construct($trace = [])
47
    {
48
        if ( ! empty($trace)) {
49
            $this->backtrace = $trace;
0 ignored issues
show
Documentation Bug introduced by
It seems like $trace of type array is incompatible with the declared type string of property $backtrace.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50
        } else {
51
            $this->backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
52
        }
53
54
        // reverse array to make steps line up chronologically
55
        $this->backtrace = array_reverse($this->backtrace);
56
57
        // Generate Lines
58
        $this->setChronology();
59
    }
60
61
    // ------------------------------------------------------------------------
62
63
    /**
64
     * Trace::setChronology
65
     *
66
     * Generate Chronology Method
67
     *
68
     * Generate array of Backtrace Chronology
69
     *
70
     * @access           private
71
     * @return           void
72
     */
73
    private function setChronology()
74
    {
75
        foreach ($this->backtrace as $trace) {
0 ignored issues
show
Bug introduced by
The expression $this->backtrace of type string is not traversable.
Loading history...
76
            $line = new Trace\DataStructures\Chronology($trace);
77
78
            if (isset($trace[ 'class' ]) AND isset($trace[ 'type' ])) {
79
                $line->call = $trace[ 'class' ] . $trace[ 'type' ] . $trace[ 'function' ] . '()';
0 ignored issues
show
Bug introduced by
The property call does not seem to exist on O2System\Gear\Trace\DataStructures\Chronology.
Loading history...
80
                $line->type = $trace[ 'type' ] === '->' ? 'non-static' : 'static';
0 ignored issues
show
Bug introduced by
The property type does not seem to exist on O2System\Gear\Trace\DataStructures\Chronology.
Loading history...
81
            } else {
82
                $line->call = $trace[ 'function' ] . '()';
83
                $line->type = 'non-static';
84
            }
85
86
            if ( ! isset($trace[ 'file' ])) {
87
                $currentTrace = current($this->backtrace);
0 ignored issues
show
Bug introduced by
$this->backtrace of type string is incompatible with the type array expected by parameter $array of current(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

87
                $currentTrace = current(/** @scrutinizer ignore-type */ $this->backtrace);
Loading history...
88
                $line->file = isset($currentTrace[ 'file' ]) ? $currentTrace[ 'file' ] : null;
0 ignored issues
show
Bug introduced by
The property file does not seem to exist on O2System\Gear\Trace\DataStructures\Chronology.
Loading history...
89
                $line->line = isset($currentTrace[ 'line' ]) ? $currentTrace[ 'line' ] : null;
0 ignored issues
show
Bug introduced by
The property line does not seem to exist on O2System\Gear\Trace\DataStructures\Chronology.
Loading history...
90
            }
91
92
            if (defined('PATH_ROOT')) {
93
                $line->file = str_replace(PATH_ROOT, '', $line->file);
0 ignored issues
show
Bug introduced by
The constant O2System\Gear\PATH_ROOT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
94
            }
95
96
            $this->chronology[] = $line;
97
98
            if (in_array($line->call, ['print_out()', 'print_line()', 'O2System\Core\Gear\Debug::stop()'])) {
99
                break;
100
            }
101
        }
102
    }
103
104
    // ------------------------------------------------------------------------
105
106
    /**
107
     * Trace::getChronology
108
     *
109
     * @param bool $reset
110
     *
111
     * @return array
112
     */
113
    public function getChronology($reset = true)
114
    {
115
        $chronology = $this->chronology;
116
117
        if ($reset === true) {
118
            $this->chronology = [];
119
        }
120
121
        return $chronology;
122
    }
123
}