1 | <?php |
||
24 | class SassEngine implements AssetEngineInterface |
||
25 | { |
||
26 | private $fileSourceMap = false; |
||
27 | private $configuration; |
||
28 | /** @var PageManager */ |
||
29 | private $pageManager; |
||
30 | private $compiler; |
||
31 | private $options = []; |
||
32 | |||
33 | 7 | public function __construct(Configuration $configuration) |
|
38 | |||
39 | 7 | public function getConfigurationNamespace() |
|
43 | |||
44 | 7 | public function getDefaultConfiguration() |
|
51 | |||
52 | 7 | public function getFolder() |
|
56 | |||
57 | 7 | public function getExtensions() |
|
61 | |||
62 | /** |
||
63 | * @param string $content |
||
64 | * @param $options = [ |
||
65 | * 'pageview' => new StaticPageView() |
||
66 | * ] |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 6 | public function parse($content, array $options = []) |
|
71 | { |
||
72 | $sourceMapOptions = [ |
||
73 | 6 | 'sourceMapBasepath' => Service::getWorkingDirectory(), |
|
74 | ]; |
||
75 | |||
76 | 6 | $this->handleThemeImports($content); |
|
77 | |||
78 | // We don't need to write the source map to a file |
||
79 | 6 | if (!$this->fileSourceMap) |
|
80 | { |
||
81 | 6 | $this->compiler->setSourceMapOptions($sourceMapOptions); |
|
82 | |||
83 | 6 | return $this->compiler->compile($content); |
|
84 | } |
||
85 | |||
86 | /** @var StaticPageView $pageView */ |
||
87 | $pageView = $options['pageview']; |
||
88 | |||
89 | // Always put our source map next to the respective CSS file |
||
90 | $sourceMapTargetPath = $this->getSourceMapTargetFile($pageView); |
||
91 | $sourceMapFilename = fs::getFilename($sourceMapTargetPath); |
||
92 | |||
93 | $sourceMapOptions = array_merge($sourceMapOptions, [ |
||
94 | 'sourceMapFilename' => $sourceMapFilename, |
||
95 | 'sourceMapURL' => $pageView->getPermalink() . '.map', |
||
96 | 'sourceMapWriteTo' => $sourceMapTargetPath, |
||
97 | ]); |
||
98 | |||
99 | $sourceMapGenerator = new SourceMapGenerator($sourceMapOptions); |
||
100 | $this->compiler->setSourceMap($sourceMapGenerator); |
||
|
|||
101 | |||
102 | $sass = $this->compiler->compile($content); |
||
103 | |||
104 | $sourceMapPageView = BasePageView::createVirtual([ |
||
105 | 'permalink' => $pageView->getPermalink() . '.map', |
||
106 | ], $sourceMapGenerator->getSourceMapContents()); |
||
107 | |||
108 | $this->pageManager->trackNewPageView($sourceMapPageView); |
||
109 | |||
110 | return $sass; |
||
111 | } |
||
112 | |||
113 | 7 | public function setOptions(array $options) |
|
121 | |||
122 | 1 | public function setPageManager(PageManager $pageManager) |
|
126 | |||
127 | 7 | private function configureImportPath() |
|
131 | |||
132 | 7 | private function configureOutputStyle() |
|
138 | |||
139 | 7 | private function configureSourceMap() |
|
157 | |||
158 | private function getSourceMapTargetFile(StaticPageView $pageView) |
||
159 | { |
||
160 | return fs::absolutePath( |
||
161 | $this->configuration->getTargetFolder(), |
||
162 | $pageView->getTargetFile() . '.map' |
||
163 | ); |
||
164 | } |
||
165 | |||
166 | 6 | private function handleThemeImports(&$content) |
|
174 | |||
175 | public static function stringToFormatter($format) |
||
192 | } |
||
193 |
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: