feat: Import parsing through an ImportParser#803
Draft
Cerdic wants to merge 2 commits intoscssphp:mainfrom
Draft
feat: Import parsing through an ImportParser#803Cerdic wants to merge 2 commits intoscssphp:mainfrom
Cerdic wants to merge 2 commits intoscssphp:mainfrom
Conversation
…the compiler before compilation for caching purpose
stof
reviewed
Aug 19, 2025
| /** | ||
| * @throws SassFormatException when parsing fails | ||
| */ | ||
| public static function parse(string $contents, Syntax $syntax, ?LoggerInterface $logger = null, ?UriInterface $sourceUrl = null): Stylesheet; |
Member
There was a problem hiding this comment.
I would not make it a static method, as this prevents making configurable implementations.
There is no reason to make it static as you inject an instance of the ImportParserInterface anyway, so there is no need to call it statically.
src/Importer/ImportParser.php
Outdated
| /** | ||
| * @throws SassFormatException when parsing fails | ||
| */ | ||
| public static function parse(string $contents, Syntax $syntax, ?LoggerInterface $logger = null, ?UriInterface $sourceUrl = null): Stylesheet |
Member
There was a problem hiding this comment.
I have an in-progress branch synchronizing some dart-sass changes in which the logger will disappear from the signature of Stylesheet::parse (which is totally fine as it is marked as internal and so not covered by semver), but which would break this proposal as the whole point of this ImportParser is that it is a public extension point.
Collaborator
Author
There was a problem hiding this comment.
we'll see then, for now the PR is on hold as you said
…ot a static method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ImportParser can be changed in the compiler with the
setImportParsermethod before compilation.This allow to implement an alternative ImportParser that can integrate a cache on parsed files.
See https://git.spip.net/spip-contrib-extensions/scssphp/-/merge_requests/20 for an example of usage.
This proposal follows #800 and the discussion there