1 | <?php |
||
14 | class Module extends ExternalModule |
||
15 | { |
||
16 | /** LESS mixin declaration pattern */ |
||
17 | const P_IMPORT_DECLARATION = '/@import\s+(\'|\")(?<path>[^\'\"]+)(\'|\");/'; |
||
18 | |||
19 | /** LESS resource importing dependencies file name */ |
||
20 | const DEPENDENCY_CACHE = 'dependencies'; |
||
21 | |||
22 | /** @var array LESS resources dependencies */ |
||
23 | public $dependencies = []; |
||
24 | |||
25 | /** @var Path to LESS resources dependencies cache file */ |
||
26 | protected $dependencyCache; |
||
27 | |||
28 | /** @var \lessc LESS compiler */ |
||
29 | protected $less; |
||
30 | |||
31 | /** SamsonFramework load preparation stage handler */ |
||
32 | 6 | public function prepare(array $params = []) |
|
33 | { |
||
34 | 6 | $moduleCachePath = array_key_exists('cachePath', $params) ? $params['cachePath'] : $this->cache_path; |
|
35 | 6 | $this->dependencyCache = $moduleCachePath.self::DEPENDENCY_CACHE; |
|
|
|||
36 | |||
37 | // Read previous cache file |
||
38 | 6 | if (file_exists($this->dependencyCache)) { |
|
39 | $this->dependencies = unserialize(file_get_contents($this->dependencyCache)); |
||
40 | } |
||
41 | |||
42 | 6 | $this->less = new \lessc; |
|
43 | |||
44 | 6 | Event::subscribe(Router::E_RESOURCE_COMPILE, [$this, 'compiler']); |
|
45 | 6 | Event::subscribe(Router::E_FINISHED, [$this, 'cacheDependencies']); |
|
46 | |||
47 | 6 | return parent::prepare(); |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * Cache LESS resources importing dependency trees. |
||
52 | */ |
||
53 | 1 | public function cacheDependencies() |
|
57 | |||
58 | /** |
||
59 | * Recursively replace @import in content of the LESS file |
||
60 | * |
||
61 | * @param string $resource Resource full path |
||
62 | * @param string $content less file content |
||
63 | * |
||
64 | * @return string Content of LESS file with included @imported resources |
||
65 | * @throws ResourceNotFound If importing resource could not be found |
||
66 | */ |
||
67 | protected function readImport($resource, $content) |
||
91 | |||
92 | /** |
||
93 | * LESS resource compiler. |
||
94 | * |
||
95 | * @param string $resource Resource full path |
||
96 | * @param string $extension Resource extension |
||
97 | * @param string $content Compiled output resource content |
||
98 | * @param array $dependencies Collection of compiled resource dependent modules |
||
99 | * |
||
100 | * @throws \Exception |
||
101 | */ |
||
102 | public function compiler($resource, &$extension, &$content, &$dependencies) |
||
124 | } |
||
125 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..