|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
|
4
|
|
|
* |
|
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace ZBateson\MailMimeParser\Parser\Proxy; |
|
8
|
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Stream\StreamFactory; |
|
10
|
|
|
use ZBateson\MailMimeParser\Message\MimePart; |
|
11
|
|
|
use ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory; |
|
12
|
|
|
use ZBateson\MailMimeParser\Message\PartHeaderContainer; |
|
13
|
|
|
use ZBateson\MailMimeParser\Parser\PartBuilder; |
|
14
|
|
|
use ZBateson\MailMimeParser\Parser\IParserFactory; |
|
15
|
|
|
use ZBateson\MailMimeParser\Parser\Part\ParsedPartStreamContainerFactory; |
|
16
|
|
|
use ZBateson\MailMimeParser\Parser\Part\ParsedPartChildrenContainerFactory; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Responsible for creating ParsedMimePart instances. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Zaahid Bateson |
|
22
|
|
|
*/ |
|
23
|
|
|
class ParserMimePartFactory |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var StreamFactory the StreamFactory instance |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $streamFactory; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var ParsedPartStreamContainerFactory |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $parsedPartStreamContainerFactory; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var PartHeaderContainerFactory |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $partHeaderContainerFactory; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var PartChildrenContainerFactory |
|
|
|
|
|
|
42
|
|
|
*/ |
|
43
|
|
|
protected $partChildrenContainerFactory; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var ParsedPartChildrenContainerFactory |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $parsedPartChildrenContainerFactory; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var IParserFactory |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $parserFactory; |
|
54
|
|
|
|
|
55
|
|
|
public function __construct( |
|
56
|
|
|
StreamFactory $sdf, |
|
57
|
|
|
PartHeaderContainerFactory $phcf, |
|
58
|
|
|
ParsedPartStreamContainerFactory $pscf, |
|
59
|
|
|
ParsedPartChildrenContainerFactory $ppccf |
|
60
|
|
|
) { |
|
61
|
|
|
$this->streamFactory = $sdf; |
|
62
|
|
|
$this->partHeaderContainerFactory = $phcf; |
|
63
|
|
|
$this->parsedPartStreamContainerFactory = $pscf; |
|
64
|
|
|
$this->parsedPartChildrenContainerFactory = $ppccf; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function setParserFactory(IParserFactory $parserFactory) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->parserFactory = $parserFactory; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* |
|
74
|
|
|
* @param PartBuilder $partBuilder |
|
75
|
|
|
* @param PartHeaderContainer $headerContainer |
|
76
|
|
|
* @param ParserMimePartProxy $parent |
|
77
|
|
|
* @return \ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartProxy |
|
78
|
|
|
*/ |
|
79
|
|
|
public function newParserMimePartProxy(PartBuilder $partBuilder, PartHeaderContainer $headerContainer, ParserMimePartProxy $parent) |
|
80
|
|
|
{ |
|
81
|
|
|
return new ParserMimePartProxy($headerContainer, $partBuilder, $this->parserFactory->newInstance(), $parent); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Constructs a new MimePart object and returns it |
|
86
|
|
|
* |
|
87
|
|
|
* @param PartBuilder $partBuilder |
|
88
|
|
|
* @param PartHeaderContainer $headerContainer |
|
89
|
|
|
* @param ParserMimePartProxy $parent |
|
90
|
|
|
* @return \ZBateson\MailMimeParser\Message\IMimePart |
|
91
|
|
|
*/ |
|
92
|
|
|
public function newInstance(PartBuilder $partBuilder, PartHeaderContainer $headerContainer, ParserMimePartProxy $parent) |
|
93
|
|
|
{ |
|
94
|
|
|
// changes to headers by the user can't affect parsing which could come |
|
95
|
|
|
// after a change to headers is made by the user on the Part |
|
96
|
|
|
$copied = $this->partHeaderContainerFactory->newInstance($headerContainer); |
|
97
|
|
|
$parserProxy = $this->newParserMimePartProxy($partBuilder, $copied, $parent); |
|
98
|
|
|
$streamContainer = $this->parsedPartStreamContainerFactory->newInstance($parserProxy); |
|
99
|
|
|
$childrenContainer = $this->parsedPartChildrenContainerFactory->newInstance($parserProxy); |
|
100
|
|
|
|
|
101
|
|
|
$part = new MimePart( |
|
102
|
|
|
$parent->getPart(), |
|
103
|
|
|
$streamContainer, |
|
104
|
|
|
$headerContainer, |
|
105
|
|
|
$childrenContainer |
|
106
|
|
|
); |
|
107
|
|
|
$parserProxy->setPart($part); |
|
108
|
|
|
$parserProxy->setParsedPartStreamContainer($streamContainer); |
|
109
|
|
|
$parserProxy->setParsedPartChildrenContainer($childrenContainer); |
|
110
|
|
|
|
|
111
|
|
|
$streamContainer->setStream($this->streamFactory->newMessagePartStream($part)); |
|
112
|
|
|
$part->attach($streamContainer); |
|
113
|
|
|
|
|
114
|
|
|
$parent->addChild($parserProxy); |
|
115
|
|
|
return $part; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths