This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace Genkgo\Mail\Stream; |
||
5 | |||
6 | use Genkgo\Mail\StreamInterface; |
||
7 | |||
8 | final class AsciiEncodedStream implements StreamInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private $text; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | private $position = 0; |
||
19 | |||
20 | /** |
||
21 | * AsciiEncodedStream constructor. |
||
22 | * @param string $text |
||
23 | * @param int $lineLength |
||
24 | * @param string $lineBreak |
||
25 | */ |
||
26 | 203 | public function __construct(string $text, int $lineLength = 78, string $lineBreak = "\r\n") |
|
27 | { |
||
28 | 203 | $this->text = \wordwrap($text, $lineLength, $lineBreak); |
|
29 | 203 | } |
|
30 | |||
31 | /** |
||
32 | * @return string |
||
33 | */ |
||
34 | 162 | public function __toString(): string |
|
35 | { |
||
36 | 162 | return $this->text; |
|
37 | } |
||
38 | |||
39 | public function close(): void |
||
40 | { |
||
41 | return; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @return mixed |
||
46 | */ |
||
47 | 12 | public function detach() |
|
48 | { |
||
49 | 12 | $handle = \fopen('php://memory', 'r+'); |
|
50 | 12 | if ($handle === false) { |
|
51 | throw new \UnexpectedValueException('Cannot open php://memory for writing'); |
||
52 | } |
||
53 | |||
54 | 12 | \fwrite($handle, $this->text); |
|
55 | 12 | return $handle; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return int|null |
||
60 | */ |
||
61 | 26 | public function getSize(): ?int |
|
62 | { |
||
63 | 26 | return \strlen($this->text); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return int |
||
68 | * @throws \RuntimeException |
||
69 | */ |
||
70 | 1 | public function tell(): int |
|
71 | { |
||
72 | 1 | return $this->position; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return bool |
||
77 | */ |
||
78 | 7 | public function eof(): bool |
|
79 | { |
||
80 | 7 | return $this->position >= \strlen($this->text); |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function isSeekable(): bool |
||
87 | { |
||
88 | return true; |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @param int $offset |
||
93 | * @param int $whence |
||
94 | * @return int |
||
95 | */ |
||
96 | 2 | public function seek(int $offset, int $whence = SEEK_SET): int |
|
97 | { |
||
98 | 2 | $length = \strlen($this->text); |
|
99 | 2 | if ($length < $offset) { |
|
100 | 1 | $offset = $length; |
|
101 | } |
||
102 | |||
103 | 2 | $this->position = $offset; |
|
104 | 2 | return 0; |
|
105 | } |
||
106 | |||
107 | /** |
||
108 | * @return bool |
||
109 | */ |
||
110 | 4 | public function rewind(): bool |
|
111 | { |
||
112 | 4 | $this->position = 0; |
|
113 | 4 | return true; |
|
114 | } |
||
115 | |||
116 | /** |
||
117 | * @return bool |
||
118 | */ |
||
119 | 1 | public function isWritable(): bool |
|
120 | { |
||
121 | 1 | return true; |
|
122 | } |
||
123 | |||
124 | /** |
||
125 | * @param string $string |
||
126 | * @return int |
||
127 | */ |
||
128 | 1 | public function write($string): int |
|
129 | { |
||
130 | 1 | $this->text = \substr_replace($this->text, $string, $this->position, \strlen($string)); |
|
131 | 1 | $bytesWritten = \strlen($string); |
|
132 | 1 | $this->position += $bytesWritten; |
|
133 | 1 | return $bytesWritten; |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * @return bool |
||
138 | */ |
||
139 | public function isReadable(): bool |
||
140 | { |
||
141 | return true; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * @param int $length |
||
146 | * @return string |
||
147 | */ |
||
148 | 8 | public function read(int $length): string |
|
149 | { |
||
150 | 8 | $result = \substr($this->text, $this->position, $length); |
|
151 | 8 | $this->position += \strlen($result); |
|
152 | 8 | return $result; |
|
153 | } |
||
154 | |||
155 | /** |
||
156 | * @return string |
||
157 | */ |
||
158 | 8 | public function getContents(): string |
|
159 | { |
||
160 | 8 | return \substr($this->text, $this->position); |
|
161 | } |
||
162 | |||
163 | /** |
||
164 | * @param array<int, string> $keys |
||
165 | * @return array<string, mixed> |
||
0 ignored issues
–
show
|
|||
166 | */ |
||
167 | 180 | public function getMetadata(array $keys = []): array |
|
168 | { |
||
169 | 180 | return []; |
|
170 | } |
||
171 | } |
||
172 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.