Issues (146)

src/CSS/InputStream.php (3 issues)

Labels
1
<?php
2
/**
3
 * @file
4
 *
5
 * The CSS Input Stream abstraction.
6
 */
7
8
namespace QueryPath\CSS;
9
10
/**
11
 * Simple wrapper to turn a string into an input stream.
12
 * This provides a standard interface on top of an array of
13
 * characters.
14
 */
15
class InputStream
16
{
17
    protected $stream;
18
    public $position = 0;
19
20
    /**
21
     * Build a new CSS input stream from a string.
22
     *
23
     * @param string
24
     *  String to turn into an input stream.
25
     */
26
    public function __construct($string)
27
    {
28
        $this->stream = str_split($string);
29
    }
30
31
    /**
32
     * Look ahead one character.
33
     *
34
     * @return char
0 ignored issues
show
The type QueryPath\CSS\char was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
     *  Returns the next character, but does not remove it from
36
     *  the stream.
37
     */
38
    public function peek()
39
    {
40
        return $this->stream[0];
41
    }
42
43
    /**
44
     * Get the next unconsumed character in the stream.
45
     * This will remove that character from the front of the
46
     * stream and return it.
47
     */
48
    public function consume()
49
    {
50
        $ret = array_shift($this->stream);
0 ignored issues
show
It seems like $this->stream can also be of type boolean; however, parameter $array of array_shift() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

50
        $ret = array_shift(/** @scrutinizer ignore-type */ $this->stream);
Loading history...
51
        if (!empty($ret)) {
52
            $this->position++;
53
        }
54
55
        return $ret;
56
    }
57
58
    /**
59
     * Check if the stream is empty.
60
     *
61
     * @return boolean
62
     *   Returns TRUE when the stream is empty, FALSE otherwise.
63
     */
64
    public function isEmpty()
65
    {
66
        return count($this->stream) === 0;
0 ignored issues
show
It seems like $this->stream can also be of type boolean; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

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

66
        return count(/** @scrutinizer ignore-type */ $this->stream) === 0;
Loading history...
67
    }
68
}
69