Completed
Push — master ( afd04b...3b4c22 )
by Colin
10s
created

src/CursorState.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark;
13
14
class CursorState
15
{
16
    /**
17
     * @var string
18
     */
19
    private $line;
20
21
    /**
22
     * @var int
23
     */
24
    private $length;
25
26
    /**
27
     * @var int
28
     */
29
    private $currentPosition;
30
31
    /**
32
     * @var int
33
     */
34
    private $previousPosition;
35
36
    /**
37
     * @var int|null
38
     */
39
    private $nextNonSpaceCache;
40
41
    /**
42
     * @var int
43
     */
44
    private $indent;
45
46
    /**
47
     * @var int
48
     */
49
    private $column;
50
51
    /**
52
     * @var bool
53
     */
54
    private $partiallyConsumedTab;
55
56
    /**
57
     * @param string   $line
58
     * @param int      $length
59
     * @param int      $currentPosition
60
     * @param int      $previousPosition
61
     * @param int|null $nextNonSpaceCache
62
     * @param int      $indent
63
     * @param int      $column
64
     * @param bool     $partiallyConsumedTab
65
     */
66 1011
    public function __construct($line, $length, $currentPosition, $previousPosition, $nextNonSpaceCache, $indent, $column, $partiallyConsumedTab, $encoding)
67
    {
68 1011
        $this->line = $line;
69 1011
        $this->length = $length;
70 1011
        $this->currentPosition = $currentPosition;
71 1011
        $this->previousPosition = $previousPosition;
72 1011
        $this->nextNonSpaceCache = $nextNonSpaceCache;
73 1011
        $this->indent = $indent;
74 1011
        $this->column = $column;
75 1011
        $this->partiallyConsumedTab = $partiallyConsumedTab;
76 1011
        $this->encoding = $encoding;
0 ignored issues
show
The property encoding does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
77 1011
    }
78
79
    /**
80
     * @return int
81
     */
82 855
    public function getCurrentPosition()
83
    {
84 855
        return $this->currentPosition;
85
    }
86
87
    /**
88
     * @return int
89
     */
90 795
    public function getLength()
91
    {
92 795
        return $this->length;
93
    }
94
95
    /**
96
     * @return string
97
     */
98 795
    public function getLine()
99
    {
100 795
        return $this->line;
101
    }
102
103
    /**
104
     * @return int
105
     */
106 795
    public function getPreviousPosition()
107
    {
108 795
        return $this->previousPosition;
109
    }
110
111
    /**
112
     * @return int|null
113
     *
114
     * @deprecated Use getNextNonSpaceCache() instead
115
     */
116
    public function getFirstNonSpaceCache()
117
    {
118
        @trigger_error('CursorState::getFirstNonSpaceCache() will be removed in a future 0.x release.  Use getNextNonSpaceCache() instead. See https://github.com/thephpleague/commonmark/issues/280', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by Colin O'Dell
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
119
120
        return $this->nextNonSpaceCache;
121
    }
122
123
    /**
124
     * @return int|null
125
     */
126 795
    public function getNextNonSpaceCache()
127
    {
128 795
        return $this->nextNonSpaceCache;
129
    }
130
131
    /**
132
     * @return int
133
     */
134 795
    public function getIndent()
135
    {
136 795
        return $this->indent;
137
    }
138
139
    /**
140
     * @return int
141
     */
142 795
    public function getColumn()
143
    {
144 795
        return $this->column;
145
    }
146
147
    /**
148
     * @return bool
149
     */
150 795
    public function getPartiallyConsumedTab()
151
    {
152 795
        return $this->partiallyConsumedTab;
153
    }
154
155
    /**
156
     * @return string
157
     */
158 795
    public function getEncoding()
159
    {
160 795
        return $this->encoding;
161
    }
162
}
163