@@ -151,18 +151,33 @@ private function compile($filename)
151151 // and will treat the @import line as css import
152152 $ scss ->setImportPaths (dirname ($ filename ));
153153
154- $ css = $ scss ->compileString (file_get_contents ($ filename ), $ filename )->getCss ();
154+ $ result = $ scss ->compileString (file_get_contents ($ filename ), $ filename );
155+ $ css = $ result ->getCss ();
155156 $ elapsed = round ((microtime (true ) - $ start ), 4 );
156157
157158 $ v = Version::VERSION ;
158159 $ ts = date ('r ' , (int ) $ start );
159160 $ css = "/* compiled by scssphp $ v on $ ts ( {$ elapsed }s) */ \n\n" . $ css ;
160161
161- $ imports = $ scss ->getParsedFiles ();
162-
163- $ updated = 0 ;
164- foreach ($ imports as $ mtime ) {
165- $ updated = max ($ updated , $ mtime );
162+ // scssphp 2.x removed Compiler::getParsedFiles(), use CompilationResult::getIncludedFiles() instead
163+ // scssphp 1.x uses Compiler::getParsedFiles() which returns [file => mtime]
164+ if (method_exists ($ scss , 'getParsedFiles ' )) {
165+ // scssphp 1.x
166+ $ imports = $ scss ->getParsedFiles ();
167+ $ updated = 0 ;
168+ foreach ($ imports as $ mtime ) {
169+ $ updated = max ($ updated , $ mtime );
170+ }
171+ } else {
172+ // scssphp 2.x: getIncludedFiles() returns file paths only
173+ $ includedFiles = $ result ->getIncludedFiles ();
174+ $ imports = array ();
175+ $ updated = 0 ;
176+ foreach ($ includedFiles as $ file ) {
177+ $ mtime = filemtime ($ file );
178+ $ imports [$ file ] = $ mtime ;
179+ $ updated = max ($ updated , $ mtime );
180+ }
166181 }
167182
168183 return array (
0 commit comments