1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | /* |
||||
6 | * This file is part of the humbug/php-scoper package. |
||||
7 | * |
||||
8 | * Copyright (c) 2017 Théo FIDRY <[email protected]>, |
||||
9 | * Pádraic Brady <[email protected]> |
||||
10 | * |
||||
11 | * For the full copyright and license information, please view the LICENSE |
||||
12 | * file that was distributed with this source code. |
||||
13 | */ |
||||
14 | |||||
15 | namespace Humbug\PhpScoper\PhpParser; |
||||
16 | |||||
17 | use Humbug\PhpScoper\Scoper\PhpScoper; |
||||
18 | use PhpParser\Error as PhpParserError; |
||||
19 | use PhpParser\Node\Scalar\String_; |
||||
20 | use function Safe\substr; |
||||
21 | |||||
22 | /** |
||||
23 | * @private |
||||
24 | */ |
||||
25 | final class StringNodePrefixer |
||||
26 | { |
||||
27 | private PhpScoper $scoper; |
||||
28 | |||||
29 | public function __construct(PhpScoper $scoper) |
||||
30 | { |
||||
31 | $this->scoper = $scoper; |
||||
32 | } |
||||
33 | |||||
34 | public function prefixStringValue(String_ $node): void |
||||
35 | { |
||||
36 | try { |
||||
37 | $lastChar = substr($node->value, -1); |
||||
0 ignored issues
–
show
|
|||||
38 | |||||
39 | $newValue = $this->scoper->scopePhp($node->value); |
||||
40 | |||||
41 | if ("\n" !== $lastChar) { |
||||
42 | $newValue = substr($newValue, 0, -1); |
||||
0 ignored issues
–
show
The function
Safe\substr() has been deprecated: The Safe version of this function is no longer needed in PHP 8.0+
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||
43 | } |
||||
44 | |||||
45 | $node->value = $newValue; |
||||
46 | } catch (PhpParserError $error) { |
||||
47 | // Continue without scoping the heredoc which for some reasons contains invalid PHP code |
||||
48 | } |
||||
49 | } |
||||
50 | } |
||||
51 |
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.