FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
lessphp/tests/sort.php at master · shipcloud/lessphp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
shipcloud
/
lessphp
Public
forked from
leafo/lessphp
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
lessphp
/
tests
/
sort.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (42 loc) · 1.33 KB
Breadcrumbs
lessphp
/
tests
/
sort.php
Copy path
File metadata and controls
56 lines (42 loc) · 1.33 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
error_reporting
(
E_ALL
);
require
realpath
(
dirname
(
__FILE__
)) .
'
/../lessc.inc.php
'
;
// sorts the selectors in stylesheet in order to normalize it for comparison
$
exe
=
array_shift
(
$
argv
);
// remove filename
if
(!
$
fname
=
array_shift
(
$
argv
)) {
$
fname
=
"
php://stdin
"
;
}
class
lesscNormalized
extends
lessc {
public
$
numberPrecision
=
3
;
public
function
compileValue
(
$
value
) {
if
(
$
value
[
0
] ===
"
raw_color
"
) {
$
value
=
$
this
->
coerceColor
(
$
value
);
}
return
parent
::
compileValue
(
$
value
);
}
}
class
SortingFormatter
extends
lessc_formatter_lessjs {
public
function
sortKey
(
$
block
) {
if
(!
isset
(
$
block
->
sortKey
)) {
sort
(
$
block
->
selectors
,
SORT_STRING
);
$
block
->
sortKey
=
implode
(
"
,
"
,
$
block
->
selectors
);
}
return
$
block
->
sortKey
;
}
public
function
sortBlock
(
$
block
) {
usort
(
$
block
->
children
,
function
(
$
a
,
$
b
) {
$
sort
=
strcmp
(
$
this
->
sortKey
(
$
a
),
$
this
->
sortKey
(
$
b
));
if
(
$
sort
==
0
) {
// TODO
}
return
$
sort
;
});
}
public
function
block
(
$
block
) {
$
this
->
sortBlock
(
$
block
);
return
parent
::
block
(
$
block
);
}
}
$
less
=
new
lesscNormalized
();
$
less
->
setFormatter
(
new
SortingFormatter
);
echo
$
less
->
parse
(
file_get_contents
(
$
fname
));
Back
|
FazBrowse Home
|
New Git URL