Conditions | 4 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 3 |
Ratio | 17.65 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
26 | public function __construct($file) |
||
27 | { |
||
28 | if ($file instanceof File) { |
||
29 | $this->file = $file; |
||
30 | } else if (is_string($file)) { |
||
31 | $this->file = new File($file); |
||
|
|||
32 | } else { |
||
33 | throw new InvalidArgumentException("Unable to open file: " . $file); |
||
34 | } |
||
35 | |||
36 | $stream = @fopen($this->file->getAbsoluteFilePath()); |
||
37 | View Code Duplication | if ($stream === false) { |
|
38 | throw new IOException("Unable open " . $this->file->getAbsoluteFilePath() . " cause by " . $php_errormsg); |
||
39 | } |
||
40 | |||
41 | parent::__construct($stream); |
||
42 | } |
||
43 | |||
52 |
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: