/* Static Methods */
/**
- * Gets a list of local file paths which are referenced in a CSS style sheet.
- *
- * If you wish non-existent files to be listed too, use getAllLocalFileReferences().
- *
- * For backwards-compatibility, if the second parameter is not given or null,
- * this function will return an empty array instead of erroring out.
- *
- * @param string $source CSS stylesheet source to process
- * @param string $path File path where the source was read from
- * @return array List of local file references
- */
- public static function getLocalFileReferences( $source, $path = null ) {
- if ( $path === null ) {
- return [];
- }
-
- $files = self::getAllLocalFileReferences( $source, $path );
-
- // Skip non-existent files
- $files = array_filter( $files, function ( $file ) {
- return file_exists( $file );
- } );
-
- return $files;
- }
-
- /**
- * Gets a list of local file paths which are referenced in a CSS style sheet, including
- * non-existent files.
+ * Get a list of local files referenced in a stylesheet (includes non-existent files).
*
* @param string $source CSS stylesheet source to process
* @param string $path File path where the source was read from
* @return array List of local file references
*/
- public static function getAllLocalFileReferences( $source, $path ) {
+ public static function getLocalFileReferences( $source, $path ) {
$stripped = preg_replace( '/' . self::COMMENT_REGEX . '/s', '', $source );
$path = rtrim( $path, '/' ) . '/';
$files = [];
$localDir = dirname( $localPath );
$remoteDir = dirname( $remotePath );
// Get and register local file references
- $localFileRefs = CSSMin::getAllLocalFileReferences( $style, $localDir );
+ $localFileRefs = CSSMin::getLocalFileReferences( $style, $localDir );
foreach ( $localFileRefs as $file ) {
if ( file_exists( $file ) ) {
$this->localFileRefs[] = $file;
}
/**
- * CSSMin::getAllLocalFileReferences should ignore url(...) expressions
+ * CSSMin::getLocalFileReferences should ignore url(...) expressions
* that have been commented out.
*/
public function testCommentedLocalFileReferences() {
$basepath = __DIR__ . '/../data/css/';
$css = file_get_contents( $basepath . 'comments.css' );
- $files = CSSMin::getAllLocalFileReferences( $css, $basepath );
+ $files = CSSMin::getLocalFileReferences( $css, $basepath );
$expected = [ $basepath . 'not-commented.gif' ];
$this->assertArrayEquals(
$expected,