1 | <?php |
||
23 | class Purifier |
||
24 | { |
||
25 | |||
26 | /** |
||
27 | * @var Filesystem |
||
28 | */ |
||
29 | protected $files; |
||
30 | |||
31 | /** |
||
32 | * @var Repository |
||
33 | */ |
||
34 | protected $config; |
||
35 | |||
36 | /** |
||
37 | * @var HTMLPurifier |
||
38 | */ |
||
39 | protected $purifier; |
||
40 | |||
41 | /** |
||
42 | * Constructor |
||
43 | * |
||
44 | * @param Filesystem $files |
||
45 | * @param Repository $config |
||
46 | * @throws Exception |
||
47 | */ |
||
48 | public function __construct(Filesystem $files, Repository $config) |
||
49 | { |
||
50 | $this->files = $files; |
||
51 | $this->config = $config; |
||
52 | |||
53 | $this->setUp(); |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Setup |
||
58 | * |
||
59 | * @throws Exception |
||
60 | */ |
||
61 | private function setUp() |
||
62 | { |
||
63 | if (!$this->config->has('purifier')) { |
||
64 | throw new Exception('Configuration parameters not loaded!'); |
||
65 | } |
||
66 | |||
67 | $this->checkCacheDirectory(); |
||
68 | |||
69 | // Create a new configuration object |
||
70 | $config = HTMLPurifier_Config::createDefault(); |
||
71 | |||
72 | // Allow configuration to be modified |
||
73 | if (!$this->config->get('purifier.finalize')) { |
||
74 | $config->autoFinalize = false; |
||
75 | } |
||
76 | |||
77 | $config->loadArray($this->getConfig()); |
||
78 | |||
79 | // Create HTMLPurifier object |
||
80 | $this->purifier = new HTMLPurifier($this->configure($config)); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Check/Create cache directory |
||
85 | */ |
||
86 | private function checkCacheDirectory() |
||
87 | { |
||
88 | $cachePath = $this->config->get('purifier.cachePath'); |
||
89 | |||
90 | if ($cachePath) { |
||
91 | if (!$this->files->isDirectory($cachePath)) { |
||
92 | $this->files->makeDirectory($cachePath, $this->config->get('purifier.cacheFileMode', 0755)); |
||
93 | } |
||
94 | } |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param HTMLPurifier_Config $config |
||
99 | * |
||
100 | * @return HTMLPurifier_Config |
||
101 | */ |
||
102 | protected function configure(HTMLPurifier_Config $config) |
||
106 | |||
107 | /** |
||
108 | * @param null $config |
||
109 | * |
||
110 | * @return mixed|null |
||
111 | */ |
||
112 | protected function getConfig($config = null) |
||
133 | |||
134 | /** |
||
135 | * @param $dirty |
||
136 | * @param null $config |
||
137 | * |
||
138 | * @return mixed |
||
139 | */ |
||
140 | public function clean($dirty, $config = null) |
||
150 | |||
151 | /** |
||
152 | * Get HTMLPurifier instance. |
||
153 | * |
||
154 | * @return \HTMLPurifier |
||
155 | */ |
||
156 | public function getInstance() |
||
160 | } |
||
161 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: