Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scss support via leafo/scssphp #549

Merged
merged 6 commits into from
Oct 16, 2016
Merged

add scss support via leafo/scssphp #549

merged 6 commits into from
Oct 16, 2016

Conversation

glensc
Copy link
Collaborator

@glensc glensc commented Oct 12, 2016

Implemented by same design as lib/Minify/LessCssSource.php

the functionality we are using is present
this is needed for @import to be able to resolve included files
tested cache dependencies
Copy link

@lauripiisang lauripiisang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would like some answers and some explanation on the visibility logic, along with cleaner test & composer version.

Nothing broken though, so not exactly blocking merge.

*
* @link https://github.com/leafo/scssphp/
*/
class Minify_ScssCssSource extends Minify_Source {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be Minify_ScssCssSource or Minify_ScssSource? If Minify_ScssCssSource, shouldn't it extend Minify_CssSource?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they both should rather depend on new Base Source class or the support that these classes have added to Source class. i.e some kind of cleanup/refactoring (in separate PR)

*
* @var array
*/
private $parsed;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the class isn't final, Why have private properties in favor of protected ones?

}

/**
* Make a unique cache id for for this source.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"unique" amounts to common string + md5 hash these days?
Either provide some actual uniqueness (via UUID or similar) or drop the word unique

}
}

$input = $cache ? $cache : $this->filepath;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 90 - 96 look like something that belongs inside a cache adapter

}
}

return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the implementation of this method, if $cache is an array with at least one value OR an instance of ArrayAccess , it isn't considered "stale", regardless of contents (as long as there's no 'files' index).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code assumes the cache is not corrupted. so there is always 'files' key present with at least one entry.

*
* @return boolean True if compile required.
*/
public function cacheIsStale($cache)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the public visibility all of a sudden, if most of the rest of this class seems to be private?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed this myself too. will fix.

$scss->setImportPaths(dirname($filename));

$css = $scss->compile(file_get_contents($filename), $filename);
$elapsed = round((microtime(true) - $start), 4);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STYLE: seems that half of this method is shifted by one space, here's where the shift starts

$mtime1 = filemtime($mainLess);
var_dump($mtime1);
$mtime2 = filemtime($includedLess);
var_dump($mtime2);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does test include var_dumps ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove from here and other tests after PR being merged.

@@ -34,6 +34,7 @@
},
"require-dev": {
"leafo/lessphp": "~0.4.0",
"leafo/scssphp": "^0.3.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find "~0.3" a bit more expressive than this.
This gives off the notion of a very specific version, but actually, it's ">= 0.3.0 <1.0.0" (at least since composer 1.0.0 ) https://getcomposer.org/doc/articles/versions.md#caret

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the library is semver compliant and pick 0.3 for php 5.3 and 0.6 for php 5.4+

@glensc
Copy link
Collaborator Author

glensc commented Oct 13, 2016

@mrclay i would like to get this merged. the PR is ready for merge.

Copy link
Owner

@mrclay mrclay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides style issues seems OK.

@glensc glensc merged commit a9891a0 into master Oct 16, 2016
@glensc glensc deleted the scssphp branch October 16, 2016 10:51
glensc added a commit that referenced this pull request Oct 17, 2016
glensc added a commit that referenced this pull request Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants