1 | <?php |
||
10 | class Finder |
||
11 | { |
||
12 | const DEFAULT_FORMAT = 'JSON'; |
||
13 | const RESSOURCES_FOLDER = '@FmajLaposteDatanovaBundle/Resources/dataset'; |
||
14 | |||
15 | /** @var Filesystem $filesystem */ |
||
16 | private $filesystem; |
||
17 | |||
18 | /** @var FileLocator $locator */ |
||
19 | private $locator; |
||
20 | |||
21 | /** @var string $directory */ |
||
22 | private $directory; |
||
23 | |||
24 | /** @var LoggerInterface $logger */ |
||
25 | private $logger; |
||
26 | |||
27 | /** |
||
28 | * @param Filesystem $filesystem |
||
29 | * @param FileLocator $locator |
||
30 | * @param string $rootDir |
||
31 | */ |
||
32 | public function __construct(Filesystem $filesystem, FileLocator $locator, $rootDir = self::RESSOURCES_FOLDER) |
||
42 | |||
43 | /** |
||
44 | * @param LoggerInterface $logger |
||
45 | */ |
||
46 | public function setLogger(LoggerInterface $logger) |
||
50 | |||
51 | /** |
||
52 | * @param string $path the working directory for filesystem operations |
||
53 | * |
||
54 | * @throws \InvalidArgumentException |
||
55 | * @throws IOException |
||
56 | */ |
||
57 | public function setWorkingDirectory($path) |
||
86 | |||
87 | /** |
||
88 | * Check if a dataset local file exists |
||
89 | * |
||
90 | * @param string $dataset |
||
91 | * @param string $format |
||
92 | * @param string $filter |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function exists($dataset, $format, $filter = null) |
||
102 | |||
103 | /** |
||
104 | * @param string $dataset |
||
105 | * @param string $format |
||
106 | * @param string $filter |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | private function getFilePath($dataset, $format, $filter = null) |
||
127 | |||
128 | /** |
||
129 | * Save a records to dataset file |
||
130 | * |
||
131 | * @param string $dataset |
||
132 | * @param string $content |
||
133 | * @param string $format |
||
134 | * @param string $filter |
||
135 | * @param bool $force |
||
136 | * |
||
137 | * @return false|string saved file path |
||
138 | */ |
||
139 | public function save($dataset, $content, $format = self::DEFAULT_FORMAT, $filter = null, $force = false) |
||
161 | |||
162 | /** |
||
163 | * @param string $dataset |
||
164 | * @param string $format |
||
165 | * @param string $filter |
||
166 | * |
||
167 | * @return false|string dataset file path |
||
168 | */ |
||
169 | public function findDataset($dataset, $format = self::DEFAULT_FORMAT, $filter = null) |
||
179 | |||
180 | /** |
||
181 | * @param string $filepath |
||
182 | * |
||
183 | * @return null|string |
||
184 | */ |
||
185 | public function getContent($filepath) |
||
194 | } |
||
195 |
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.