1 | <?php |
||
37 | class Splitter |
||
38 | { |
||
39 | public const MAX_NAMESPACE_LENGTH = 10; |
||
40 | |||
41 | public const BYTE_NULL = 0; // Zero-byte for terminating documents |
||
42 | public const BYTE_INLINE = 123; // The "{" character indicating an inline expression started |
||
43 | public const BYTE_INLINE_END = 125; // The "}" character indicating an inline expression ended |
||
44 | public const BYTE_PIPE = 124; // The "|" character indicating an inline expression pass operation |
||
45 | public const BYTE_MINUS = 45; // The "-" character (for legacy pass operations) |
||
46 | public const BYTE_TAG = 60; // The "<" character indicating a tag has started |
||
47 | public const BYTE_TAG_END = 62; // The ">" character indicating a tag has ended |
||
48 | public const BYTE_TAG_CLOSE = 47; // The "/" character indicating a tag is a closing tag |
||
49 | public const BYTE_QUOTE_DOUBLE = 34; // The " (standard double-quote) character |
||
50 | public const BYTE_QUOTE_SINGLE = 39; // The ' (standard single-quote) character |
||
51 | public const BYTE_WHITESPACE_SPACE = 32; // A standard space character |
||
52 | public const BYTE_WHITESPACE_TAB = 9; // A standard carriage-return character |
||
53 | public const BYTE_WHITESPACE_RETURN = 13; // A standard tab character |
||
54 | public const BYTE_WHITESPACE_EOL = 10; // A standard (UNIX) line-break character |
||
55 | public const BYTE_SEPARATOR_EQUALS = 61; // The "=" character |
||
56 | public const BYTE_SEPARATOR_COLON = 58; // The ":" character |
||
57 | public const BYTE_SEPARATOR_COMMA = 44; // The "," character |
||
58 | public const BYTE_SEPARATOR_PIPE = 124; // The "|" character |
||
59 | public const BYTE_PARENTHESIS_START = 40; // The "(" character |
||
60 | public const BYTE_PARENTHESIS_END = 41; // The ")" character |
||
61 | public const BYTE_ARRAY_START = 91; // The "[" character |
||
62 | public const BYTE_ARRAY_END = 93; // The "]" character |
||
63 | public const BYTE_SLASH = 47; // The "/" character |
||
64 | public const BYTE_BACKSLASH = 92; // The "\" character |
||
65 | public const BYTE_BACKTICK = 96; // The "`" character |
||
66 | public const MAP_SHIFT = 64; |
||
67 | public const MASK_LINEBREAKS = 0 | (1 << self::BYTE_WHITESPACE_EOL) | (1 << self::BYTE_WHITESPACE_RETURN); |
||
68 | public const MASK_WHITESPACE = 0 | self::MASK_LINEBREAKS | (1 << self::BYTE_WHITESPACE_SPACE) | (1 << self::BYTE_WHITESPACE_TAB); |
||
69 | |||
70 | /** @var Source */ |
||
71 | public $source; |
||
72 | |||
73 | /** @var Context */ |
||
74 | public $context; |
||
75 | |||
76 | /** @var Contexts */ |
||
77 | public $contexts; |
||
78 | |||
79 | /** @var \NoRewindIterator */ |
||
80 | public $sequence; |
||
81 | |||
82 | public $index = 0; |
||
83 | private $primaryMask = 0; |
||
84 | private $secondaryMask = 0; |
||
85 | |||
86 | public function __construct(Source $source, Contexts $contexts) |
||
93 | |||
94 | /** |
||
95 | * Creates a dump, starting from the first line break before $position, |
||
96 | * to the next line break from $position, counting the lines and characters |
||
97 | * and inserting a marker pointing to the exact offending character. |
||
98 | * |
||
99 | * Is not very efficient - but adds bug tracing information. Should only |
||
100 | * be called when exceptions are raised during sequencing. |
||
101 | * |
||
102 | * @param Position $position |
||
103 | * @return string |
||
104 | */ |
||
105 | public function extractSourceDumpOfLineAtPosition(Position $position): string |
||
122 | |||
123 | public function createErrorAtPosition(string $message, int $code): SequencingException |
||
131 | |||
132 | public function createUnsupportedArgumentError(string $argument, array $definitions): SequencingException |
||
142 | |||
143 | /** |
||
144 | * Split a string by searching for recognized characters using at least one, |
||
145 | * optionally two bit masks consisting of OR'ed bit values of each detectable |
||
146 | * character (byte). The secondary bit mask is costless as it is OR'ed into |
||
147 | * the primary bit mask. |
||
148 | * |
||
149 | * @return \NoRewindIterator|string[]|null[] |
||
150 | */ |
||
151 | public function parse(): \NoRewindIterator |
||
155 | |||
156 | /** |
||
157 | * Split a string by searching for recognized characters using at least one, |
||
158 | * optionally two bit masks consisting of OR'ed bit values of each detectable |
||
159 | * character (byte). The secondary bit mask is costless as it is OR'ed into |
||
160 | * the primary bit mask. |
||
161 | * |
||
162 | * @return \NoRewindIterator|string[]|null[] |
||
163 | */ |
||
164 | public function createGenerator(): \Generator |
||
195 | |||
196 | public function switch(Context $context): Context |
||
204 | |||
205 | public function countCharactersMatchingMask(int $primaryMask, int $offset, int $length): int |
||
216 | |||
217 | public function findBytePositionBeforeOffset(int $primaryMask, int $offset): int |
||
227 | |||
228 | public function findBytePositionAfterOffset(int $primaryMask, int $offset): int |
||
238 | } |
||
239 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.