1 | <?php |
||
15 | class MessageParser |
||
16 | { |
||
17 | /** |
||
18 | * @var \ZBateson\MailMimeParser\Message the Message object that the read |
||
19 | * mail mime message will be parsed into |
||
20 | */ |
||
21 | protected $message; |
||
22 | |||
23 | /** |
||
24 | * @var \ZBateson\MailMimeParser\MimePartFactory the MimePartFactory object |
||
25 | * used to create parts. |
||
26 | */ |
||
27 | protected $partFactory; |
||
28 | |||
29 | /** |
||
30 | * @var \ZBateson\MailMimeParser\PartStreamRegistry the PartStreamRegistry |
||
31 | * object used to register stream parts. |
||
32 | */ |
||
33 | protected $partStreamRegistry; |
||
34 | |||
35 | /** |
||
36 | * Sets up the parser with its dependencies. |
||
37 | * |
||
38 | * @param \ZBateson\MailMimeParser\Message $m |
||
39 | * @param \ZBateson\MailMimeParser\MimePartFactory $pf |
||
40 | * @param \ZBateson\MailMimeParser\PartStreamRegistry $psr |
||
41 | */ |
||
42 | public function __construct(Message $m, MimePartFactory $pf, PartStreamRegistry $psr) |
||
48 | |||
49 | /** |
||
50 | * Parses the passed stream handle into the ZBateson\MailMimeParser\Message |
||
51 | * object and returns it. |
||
52 | * |
||
53 | * @param resource $fhandle the resource handle to the input stream of the |
||
54 | * mime message |
||
55 | * @return \ZBateson\MailMimeParser\Message |
||
56 | */ |
||
57 | public function parse($fhandle) |
||
63 | |||
64 | /** |
||
65 | * Reads header lines up to an empty line, adding them to the passed $part. |
||
66 | * |
||
67 | * @param resource $handle the resource handle to read from |
||
68 | * @param \ZBateson\MailMimeParser\MimePart $part the current part to add |
||
69 | * headers to |
||
70 | */ |
||
71 | protected function readHeaders($handle, MimePart $part) |
||
88 | |||
89 | /** |
||
90 | * Reads the content of a mime part up to a boundary, or the entire message |
||
91 | * if no boundary is specified. |
||
92 | * |
||
93 | * readPartContent may be called to skip to the first boundary to read its |
||
94 | * headers, in which case $skipPart should be true. |
||
95 | * |
||
96 | * If the end boundary is found, the method returns true. |
||
97 | * |
||
98 | * @param resource $handle the input stream resource |
||
99 | * @param \ZBateson\MailMimeParser\Message $message the current Message |
||
100 | * object |
||
101 | * @param \ZBateson\MailMimeParser\MimePart $part the current MimePart |
||
102 | * object to load the content into. |
||
103 | * @param string $boundary the MIME boundary |
||
104 | * @param boolean $skipPart pass true if the intention is to read up to the |
||
105 | * beginning MIME boundary's headers |
||
106 | * @return boolean if the end boundary is found |
||
107 | */ |
||
108 | protected function readPartContent($handle, Message $message, MimePart $part, $boundary, $skipPart) |
||
134 | |||
135 | /** |
||
136 | * Finds the boundaries for the current MimePart, reads its content and |
||
137 | * creates and returns the next part, setting its parent part accordingly. |
||
138 | * |
||
139 | * @param resource $handle The handle to read from |
||
140 | * @param \ZBateson\MailMimeParser\Message $message The current Message |
||
141 | * @param \ZBateson\MailMimeParser\MimePart $part |
||
142 | * @return type |
||
143 | */ |
||
144 | protected function readMimeMessagePart($handle, Message $message, MimePart $part) |
||
175 | |||
176 | /** |
||
177 | * Extracts the filename and end position of a UUEncoded part. |
||
178 | * |
||
179 | * The filename is set to the passed $nextFilename parameter. The end |
||
180 | * position is returned. |
||
181 | * |
||
182 | * @param resource $handle the current file handle |
||
183 | * @param int &$nextMode is assigned the value of the next file mode or null |
||
184 | * if not found |
||
185 | * @param string &$nextFilename is assigned the value of the next filename |
||
186 | * or null if not found |
||
187 | * @param int &$end assigned the offset position within the passed resource |
||
188 | * $handle of the end of the uuencoded part |
||
189 | */ |
||
190 | private function findNextUUEncodedPartPosition($handle) |
||
204 | |||
205 | /** |
||
206 | * Reads one part of a UUEncoded message and adds it to the passed Message |
||
207 | * as a MimePart. |
||
208 | * |
||
209 | * The method reads up to the first 'begin' part of the message, or to the |
||
210 | * end of the message if no 'begin' exists. |
||
211 | * |
||
212 | * @param resource $handle |
||
213 | * @param \ZBateson\MailMimeParser\Message $message |
||
214 | * @return string |
||
215 | */ |
||
216 | protected function readUUEncodedOrPlainTextPart($handle, Message $message) |
||
234 | |||
235 | /** |
||
236 | * Reads the message from the input stream $handle into $message. |
||
237 | * |
||
238 | * The method will loop to read headers and find and parse multipart-mime |
||
239 | * message parts and uuencoded attachments (as mime-parts), adding them to |
||
240 | * the passed Message object. |
||
241 | * |
||
242 | * @param resource $handle |
||
243 | * @param \ZBateson\MailMimeParser\Message $message |
||
244 | */ |
||
245 | protected function read($handle, Message $message) |
||
260 | } |
||
261 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.