1 | <?php |
||
18 | class ZLib implements CompressionInterface |
||
19 | { |
||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $compression_level = -1; |
||
24 | |||
25 | /** |
||
26 | * Deflate constructor. |
||
27 | * |
||
28 | * @param int $compression_level |
||
29 | */ |
||
30 | public function __construct($compression_level = -1) |
||
31 | { |
||
32 | if (!is_numeric($compression_level) || $compression_level < -1 || $compression_level > 9) { |
||
33 | throw new \InvalidArgumentException('The level of compression can be given as 0 for no compression up to 9 for maximum compression. If -1 given, the default compression level will be the default compression level of the zlib library.'); |
||
34 | } |
||
35 | |||
36 | $this->compression_level = $compression_level; |
||
|
|||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return int |
||
41 | */ |
||
42 | private function getCompressionLevel() |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function getMethodName() |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function compress($data) |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function uncompress($data) |
||
70 | } |
||
71 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.