Issues (85)

src/Delimiter/DelimiterStack.php (22 issues)

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the league/commonmark package.
7
 *
8
 * (c) Colin O'Dell <[email protected]>
9
 *
10
 * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
11
 *  - (c) John MacFarlane
12
 *
13
 * Additional emphasis processing code based on commonmark-java (https://github.com/atlassian/commonmark-java)
14
 *  - (c) Atlassian Pty Ltd
15
 *
16
 * For the full copyright and license information, please view the LICENSE
17
 * file that was distributed with this source code.
18
 */
19
20
namespace League\CommonMark\Delimiter;
21
22
use League\CommonMark\Delimiter\Processor\CacheableDelimiterProcessorInterface;
23
use League\CommonMark\Delimiter\Processor\DelimiterProcessorCollection;
24
use League\CommonMark\Node\Inline\AdjacentTextMerger;
25
use League\CommonMark\Node\Node;
26
27
final class DelimiterStack
28
{
29
    /** @psalm-readonly-allow-private-mutation */
30
    private ?DelimiterInterface $top = null;
31
32
    /** @psalm-readonly-allow-private-mutation */
33
    private ?Bracket $brackets = null;
34
35
    /**
36
     * @deprecated This property will be removed in 3.0 once all delimiters MUST have an index/position
37
     *
38
     * @var \SplObjectStorage<DelimiterInterface, int>|\WeakMap<DelimiterInterface, int>
39
     */
40
    private $missingIndexCache;
41
42
43
    private int $remainingDelimiters = 0;
44
45
    public function __construct(int $maximumStackSize = PHP_INT_MAX)
46
    {
47
        $this->remainingDelimiters = $maximumStackSize;
48
49
        if (\PHP_VERSION_ID >= 80000) {
50
            /** @psalm-suppress PropertyTypeCoercion */
51
            $this->missingIndexCache = new \WeakMap(); // @phpstan-ignore-line
0 ignored issues
show
Documentation Bug introduced by
It seems like new WeakMap() of type WeakMap is incompatible with the declared type SplObjectStorage of property $missingIndexCache.

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...
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

51
            /** @scrutinizer ignore-deprecated */ $this->missingIndexCache = new \WeakMap(); // @phpstan-ignore-line

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
52
        } else {
53
            $this->missingIndexCache = new \SplObjectStorage(); // @phpstan-ignore-line
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

53
            /** @scrutinizer ignore-deprecated */ $this->missingIndexCache = new \SplObjectStorage(); // @phpstan-ignore-line

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
54
        }
55
    }
56
57
    public function push(DelimiterInterface $newDelimiter): void
58
    {
59
        if ($this->remainingDelimiters-- <= 0) {
60
            return;
61
        }
62
63
        $newDelimiter->setPrevious($this->top);
64
65
        if ($this->top !== null) {
66
            $this->top->setNext($newDelimiter);
67
        }
68
69
        $this->top = $newDelimiter;
70
    }
71
72
    /**
73
     * @internal
74
     */
75
    public function addBracket(Node $node, int $index, bool $image): void
76
    {
77
        if ($this->brackets !== null) {
78
            $this->brackets->setHasNext(true);
79
        }
80
81
        $this->brackets = new Bracket($node, $this->brackets, $index, $image);
82
    }
83
84
    /**
85
     * @psalm-immutable
86
     */
87
    public function getLastBracket(): ?Bracket
88
    {
89
        return $this->brackets;
90
    }
91
92
    private function findEarliest(int $stackBottom): ?DelimiterInterface
93
    {
94
        // Move back to first relevant delim.
95
        $delimiter   = $this->top;
96
        $lastChecked = null;
97
98
        while ($delimiter !== null && self::getIndex($delimiter) > $stackBottom) {
0 ignored issues
show
Bug Best Practice introduced by
The method League\CommonMark\Delimi...imiterStack::getIndex() is not static, but was called statically. ( Ignorable by Annotation )

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

98
        while ($delimiter !== null && self::/** @scrutinizer ignore-call */ getIndex($delimiter) > $stackBottom) {
Loading history...
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

98
        while ($delimiter !== null && /** @scrutinizer ignore-deprecated */ self::getIndex($delimiter) > $stackBottom) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
99
            $lastChecked = $delimiter;
100
            $delimiter   = $delimiter->getPrevious();
101
        }
102
103
        return $lastChecked;
104
    }
105
106
    /**
107
     * @internal
108
     */
109
    public function removeBracket(): void
110
    {
111
        if ($this->brackets === null) {
112
            return;
113
        }
114
115
        $this->brackets = $this->brackets->getPrevious();
116
117
        if ($this->brackets !== null) {
118
            $this->brackets->setHasNext(false);
119
        }
120
    }
121
122
    public function removeDelimiter(DelimiterInterface $delimiter): void
123
    {
124
        if ($delimiter->getPrevious() !== null) {
125
            /** @psalm-suppress PossiblyNullReference */
126
            $delimiter->getPrevious()->setNext($delimiter->getNext());
127
        }
128
129
        if ($delimiter->getNext() === null) {
130
            // top of stack
131
            $this->top = $delimiter->getPrevious();
132
        } else {
133
            /** @psalm-suppress PossiblyNullReference */
134
            $delimiter->getNext()->setPrevious($delimiter->getPrevious());
135
        }
136
137
        // Nullify all references from the removed delimiter to other delimiters.
138
        // All references to this particular delimiter in the linked list should be gone,
139
        // but it's possible we're still hanging on to other references to things that
140
        // have been (or soon will be) removed, which may interfere with efficient
141
        // garbage collection by the PHP runtime.
142
        // Explicitly releasing these references should help to avoid possible
143
        // segfaults like in https://bugs.php.net/bug.php?id=68606.
144
        $delimiter->setPrevious(null);
145
        $delimiter->setNext(null);
146
147
        // TODO: Remove the line below once PHP 7.4 support is dropped, as WeakMap won't hold onto the reference, making this unnecessary
148
        unset($this->missingIndexCache[$delimiter]);
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

148
        unset(/** @scrutinizer ignore-deprecated */ $this->missingIndexCache[$delimiter]);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
149
    }
150
151
    private function removeDelimiterAndNode(DelimiterInterface $delimiter): void
152
    {
153
        $delimiter->getInlineNode()->detach();
154
        $this->removeDelimiter($delimiter);
155
    }
156
157
    private function removeDelimitersBetween(DelimiterInterface $opener, DelimiterInterface $closer): void
158
    {
159
        $delimiter      = $closer->getPrevious();
160
        $openerPosition = self::getIndex($opener);
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

160
        $openerPosition = /** @scrutinizer ignore-deprecated */ self::getIndex($opener);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug Best Practice introduced by
The method League\CommonMark\Delimi...imiterStack::getIndex() is not static, but was called statically. ( Ignorable by Annotation )

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

160
        /** @scrutinizer ignore-call */ 
161
        $openerPosition = self::getIndex($opener);
Loading history...
161
        while ($delimiter !== null && self::getIndex($delimiter) > $openerPosition) {
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

161
        while ($delimiter !== null && /** @scrutinizer ignore-deprecated */ self::getIndex($delimiter) > $openerPosition) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
162
            $previous = $delimiter->getPrevious();
163
            $this->removeDelimiter($delimiter);
164
            $delimiter = $previous;
165
        }
166
    }
167
168
    /**
169
     * @param DelimiterInterface|int|null $stackBottom
170
     */
171
    public function removeAll($stackBottom = null): void
172
    {
173
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : self::getIndex($stackBottom);
0 ignored issues
show
Bug Best Practice introduced by
The method League\CommonMark\Delimi...imiterStack::getIndex() is not static, but was called statically. ( Ignorable by Annotation )

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

173
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : self::/** @scrutinizer ignore-call */ getIndex($stackBottom);
Loading history...
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

173
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : /** @scrutinizer ignore-deprecated */ self::getIndex($stackBottom);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
174
175
        while ($this->top && $this->getIndex($this->top) > $stackBottomPosition) {
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

175
        while ($this->top && /** @scrutinizer ignore-deprecated */ $this->getIndex($this->top) > $stackBottomPosition) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
176
            $this->removeDelimiter($this->top);
177
        }
178
    }
179
180
    /**
181
     * @deprecated This method is no longer used internally and will be removed in 3.0
182
     */
183
    public function removeEarlierMatches(string $character): void
184
    {
185
        $opener = $this->top;
186
        while ($opener !== null) {
187
            if ($opener->getChar() === $character) {
188
                $opener->setActive(false);
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...rInterface::setActive() has been deprecated: This method is no longer used internally and will be removed in 3.0 ( Ignorable by Annotation )

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

188
                /** @scrutinizer ignore-deprecated */ $opener->setActive(false);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
189
            }
190
191
            $opener = $opener->getPrevious();
192
        }
193
    }
194
195
    /**
196
     * @internal
197
     */
198
    public function deactivateLinkOpeners(): void
199
    {
200
        $opener = $this->brackets;
201
        while ($opener !== null && $opener->isActive()) {
202
            $opener->setActive(false);
203
            $opener = $opener->getPrevious();
204
        }
205
    }
206
207
    /**
208
     * @deprecated This method is no longer used internally and will be removed in 3.0
209
     *
210
     * @param string|string[] $characters
211
     */
212
    public function searchByCharacter($characters): ?DelimiterInterface
213
    {
214
        if (! \is_array($characters)) {
215
            $characters = [$characters];
216
        }
217
218
        $opener = $this->top;
219
        while ($opener !== null) {
220
            if (\in_array($opener->getChar(), $characters, true)) {
221
                break;
222
            }
223
224
            $opener = $opener->getPrevious();
225
        }
226
227
        return $opener;
228
    }
229
230
    /**
231
     * @param DelimiterInterface|int|null $stackBottom
232
     *
233
     * @todo change $stackBottom to an int in 3.0
234
     */
235
    public function processDelimiters($stackBottom, DelimiterProcessorCollection $processors): void
236
    {
237
        /** @var array<string, int> $openersBottom */
238
        $openersBottom = [];
239
240
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : self::getIndex($stackBottom);
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

240
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : /** @scrutinizer ignore-deprecated */ self::getIndex($stackBottom);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug Best Practice introduced by
The method League\CommonMark\Delimi...imiterStack::getIndex() is not static, but was called statically. ( Ignorable by Annotation )

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

240
        $stackBottomPosition = \is_int($stackBottom) ? $stackBottom : self::/** @scrutinizer ignore-call */ getIndex($stackBottom);
Loading history...
241
242
        // Find first closer above stackBottom
243
        $closer = $this->findEarliest($stackBottomPosition);
244
245
        // Move forward, looking for closers, and handling each
246
        while ($closer !== null) {
247
            $closingDelimiterChar = $closer->getChar();
248
249
            $delimiterProcessor = $processors->getDelimiterProcessor($closingDelimiterChar);
250
            if (! $closer->canClose() || $delimiterProcessor === null) {
251
                $closer = $closer->getNext();
252
                continue;
253
            }
254
255
            if ($delimiterProcessor instanceof CacheableDelimiterProcessorInterface) {
256
                $openersBottomCacheKey = $delimiterProcessor->getCacheKey($closer);
257
            } else {
258
                $openersBottomCacheKey = $closingDelimiterChar;
259
            }
260
261
            $openingDelimiterChar = $delimiterProcessor->getOpeningCharacter();
262
263
            $useDelims            = 0;
264
            $openerFound          = false;
265
            $potentialOpenerFound = false;
266
            $opener               = $closer->getPrevious();
267
            while ($opener !== null && ($openerPosition = self::getIndex($opener)) > $stackBottomPosition && $openerPosition >= ($openersBottom[$openersBottomCacheKey] ?? 0)) {
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

267
            while ($opener !== null && ($openerPosition = /** @scrutinizer ignore-deprecated */ self::getIndex($opener)) > $stackBottomPosition && $openerPosition >= ($openersBottom[$openersBottomCacheKey] ?? 0)) {

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
268
                if ($opener->canOpen() && $opener->getChar() === $openingDelimiterChar) {
269
                    $potentialOpenerFound = true;
270
                    $useDelims            = $delimiterProcessor->getDelimiterUse($opener, $closer);
271
                    if ($useDelims > 0) {
272
                        $openerFound = true;
273
                        break;
274
                    }
275
                }
276
277
                $opener = $opener->getPrevious();
278
            }
279
280
            if (! $openerFound) {
281
                // Set lower bound for future searches
282
                // TODO: Remove this conditional check in 3.0. It only exists to prevent behavioral BC breaks in 2.x.
283
                if ($potentialOpenerFound === false || $delimiterProcessor instanceof CacheableDelimiterProcessorInterface) {
284
                    $openersBottom[$openersBottomCacheKey] = self::getIndex($closer);
0 ignored issues
show
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

284
                    $openersBottom[$openersBottomCacheKey] = /** @scrutinizer ignore-deprecated */ self::getIndex($closer);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
285
                }
286
287
                if (! $potentialOpenerFound && ! $closer->canOpen()) {
288
                    // We can remove a closer that can't be an opener,
289
                    // once we've seen there's no matching opener.
290
                    $next = $closer->getNext();
291
                    $this->removeDelimiter($closer);
292
                    $closer = $next;
293
                } else {
294
                    $closer = $closer->getNext();
295
                }
296
297
                continue;
298
            }
299
300
            \assert($opener !== null);
301
302
            $openerNode = $opener->getInlineNode();
303
            $closerNode = $closer->getInlineNode();
304
305
            // Remove number of used delimiters from stack and inline nodes.
306
            $opener->setLength($opener->getLength() - $useDelims);
307
            $closer->setLength($closer->getLength() - $useDelims);
308
309
            $openerNode->setLiteral(\substr($openerNode->getLiteral(), 0, -$useDelims));
310
            $closerNode->setLiteral(\substr($closerNode->getLiteral(), 0, -$useDelims));
311
312
            $this->removeDelimitersBetween($opener, $closer);
313
            // The delimiter processor can re-parent the nodes between opener and closer,
314
            // so make sure they're contiguous already. Exclusive because we want to keep opener/closer themselves.
315
            AdjacentTextMerger::mergeTextNodesBetweenExclusive($openerNode, $closerNode);
316
            $delimiterProcessor->process($openerNode, $closerNode, $useDelims);
317
318
            // No delimiter characters left to process, so we can remove delimiter and the now empty node.
319
            if ($opener->getLength() === 0) {
320
                $this->removeDelimiterAndNode($opener);
321
            }
322
323
            // phpcs:disable SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
324
            if ($closer->getLength() === 0) {
325
                $next = $closer->getNext();
326
                $this->removeDelimiterAndNode($closer);
327
                $closer = $next;
328
            }
329
        }
330
331
        // Remove all delimiters
332
        $this->removeAll($stackBottomPosition);
333
    }
334
335
    /**
336
     * @internal
337
     */
338
    public function __destruct()
339
    {
340
        while ($this->top) {
341
            $this->removeDelimiter($this->top);
342
        }
343
344
        while ($this->brackets) {
345
            $this->removeBracket();
346
        }
347
    }
348
349
    /**
350
     * @deprecated This method will be dropped in 3.0 once all delimiters MUST have an index/position
351
     */
352
    private function getIndex(?DelimiterInterface $delimiter): int
353
    {
354
        if ($delimiter === null) {
355
            return -1;
356
        }
357
358
        if (($index = $delimiter->getIndex()) !== null) {
359
            return $index;
360
        }
361
362
        if (isset($this->missingIndexCache[$delimiter])) {
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

362
        if (isset(/** @scrutinizer ignore-deprecated */ $this->missingIndexCache[$delimiter])) {

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
363
            return $this->missingIndexCache[$delimiter];
364
        }
365
366
        $prev = $delimiter->getPrevious();
367
        $next = $delimiter->getNext();
368
369
        $i = 0;
370
        do {
371
            $i++;
372
            if ($prev === null) {
373
                break;
374
            }
375
376
            if ($prev->getIndex() !== null) {
377
                return $this->missingIndexCache[$delimiter] = $prev->getIndex() + $i;
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

377
                return /** @scrutinizer ignore-deprecated */ $this->missingIndexCache[$delimiter] = $prev->getIndex() + $i;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
378
            }
379
        } while ($prev = $prev->getPrevious());
380
381
        $j = 0;
382
        do {
383
            $j++;
384
            if ($next === null) {
385
                break;
386
            }
387
388
            if ($next->getIndex() !== null) {
389
                return $this->missingIndexCache[$delimiter] = $next->getIndex() - $j;
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

389
                return /** @scrutinizer ignore-deprecated */ $this->missingIndexCache[$delimiter] = $next->getIndex() - $j;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
390
            }
391
        } while ($next = $next->getNext());
392
393
        // No index was defined on this delimiter, and none could be guesstimated based on the stack.
394
        return $this->missingIndexCache[$delimiter] = $this->getIndex($delimiter->getPrevious()) + 1;
0 ignored issues
show
Deprecated Code introduced by
The property League\CommonMark\Delimi...ack::$missingIndexCache has been deprecated: This property will be removed in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

394
        return /** @scrutinizer ignore-deprecated */ $this->missingIndexCache[$delimiter] = $this->getIndex($delimiter->getPrevious()) + 1;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Deprecated Code introduced by
The function League\CommonMark\Delimi...imiterStack::getIndex() has been deprecated: This method will be dropped in 3.0 once all delimiters MUST have an index/position ( Ignorable by Annotation )

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

394
        return $this->missingIndexCache[$delimiter] = /** @scrutinizer ignore-deprecated */ $this->getIndex($delimiter->getPrevious()) + 1;

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
395
    }
396
}
397