1 | <?php |
||
17 | class Detector |
||
18 | { |
||
19 | /** |
||
20 | * @var StorageInterface |
||
21 | */ |
||
22 | private $dataProvider; |
||
23 | |||
24 | /** |
||
25 | * @return StorageInterface |
||
26 | */ |
||
27 | public function getDataProvider(): StorageInterface |
||
31 | |||
32 | /** |
||
33 | * @return Result |
||
34 | */ |
||
35 | public function getResultObject(): Result |
||
39 | |||
40 | /** |
||
41 | * @var Result |
||
42 | */ |
||
43 | private $resultObject; |
||
44 | |||
45 | /** |
||
46 | * @param StorageInterface $dataProvider |
||
47 | */ |
||
48 | public function setDataProvider(StorageInterface $dataProvider) |
||
52 | |||
53 | private $ua; |
||
54 | |||
55 | /** |
||
56 | * Detector constructor. |
||
57 | * @param string $dataProvider |
||
58 | * @param string $format |
||
59 | * @throws StorageException |
||
60 | */ |
||
61 | public function __construct(string $dataProvider = '\\EndorphinStudio\\Detector\\Storage\\YamlStorage', string $format = 'yaml') |
||
68 | |||
69 | public function analyze(string $ua = 'ua') |
||
80 | |||
81 | private function detect($config, $type) |
||
85 | |||
86 | private function getPatternList($list, $type) |
||
90 | } |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: