129 Commits

Author SHA1 Message Date
Matthias Mullie
64f7d8a83b Add test for issue #136 2016-09-14 17:07:23 +02:00
Matthias Mullie
52139dad41 Add test for issue #136 2016-09-14 13:31:25 +02:00
Matthias Mullie
f03da3f743 Don't shorten bools if they're object literal keys
Fixes issue #134
2016-09-14 13:27:15 +02:00
Matthias Mullie
9e0dfaf1b1 Only strip whitespace after other operations
Property notation, for example, alters the content. If we've stripped
whitespace first, the transformations in propertynotation may no
longer be correct.

Fixed issue #133
2016-09-14 13:22:15 +02:00
Matthias Mullie
97a8f64bab Improve whitespace stripping around certain operators
1: some were not stripped agressively enough. E.g.:
   return !0 -> return!0
2: some were stripped too aggressive. E.g.:
   func()
   {1+2}
   Should not be joined on 1 line, since func() could be a function
   call and {1+2} an unrelated piece of code

Fixes issue #130
2016-09-14 13:13:59 +02:00
Matthias Mullie
d63980b5cf Regular expressions can also be followed by }
Fixes issue #124
2016-09-14 11:51:12 +02:00
Matthias Mullie
ac88354d6d Simplify regex & add test case for issue 120 2016-09-14 10:41:50 +02:00
aalvarado
54bdf69431 Feature: Add ability to pass an array of css and js assets as an argument
add() will now accept an array of js/css files, useful when your list of assets live in a config file
Add unit tests
Simplify test harness
2016-08-12 12:44:25 -04:00
Matthias Mullie
dcdedb0389 Improve regex extraction
Fixes issue #115
2016-06-09 21:04:46 +02:00
Matthias Mullie
2552412426 Also don't fork if it's simply not available 2016-06-09 19:01:25 +02:00
Matthias Mullie
8f76616c40 Don't run fork test on HHVM 2016-06-09 18:05:40 +02:00
Matthias Mullie
75eff20d29 Suppress is_file errors, which may be caused by open_basedir
Fixes issue #111
2016-06-09 17:53:59 +02:00
Matthias Mullie
9c9c286776 Add tests for issue #108 2016-04-27 13:12:17 +02:00
Matthias Mullie
42bcd8c16e Add tests for issue #102 2016-04-27 12:49:27 +02:00
Matthias Mullie
8fa45a1be0 Add test for issue #100 2016-04-27 12:40:09 +02:00
Matthias Mullie
272e461134 Fix '0' being replaces by first string's value
Fixes #99
2016-03-01 09:00:27 +01:00
Matthias Mullie
3518f595e5 Restore original Exception class
I admit, having just this 1 Exception class in the root of the
project was a bad idea...
But now I can't take it away without breaking backwards compatibility:
people could be catching errors of this class.
So all new Exception classes have to inherit from this old one (it's
not worth breaking BC over, imo)
Also renamed the new ones to be "Exceptions" (plural), to avoid
confusing that namespace with the original exception class name.
2016-02-17 11:43:01 +01:00
Matthias Mullie
c17eb048da Restore earlier method of safeguarding newlines after regex
This replacement was a bit unsafe as it could confuse devision /
for end-of-regex
2016-02-17 10:09:38 +01:00
Matthias Mullie
b0c3c1a522 Restore original test 2016-02-17 10:04:30 +01:00
Matthias Mullie
b77673f350 php-cs-fixer fixes 2016-02-17 09:58:12 +01:00
Gino Pane
4049b6eed3 Test and prevent file import loops.
Issue: https://github.com/matthiasmullie/minify/issues/96

Updates:
- Added css files for testing and a new test-case;
- created new exception types and grouped them into separated directory;
- reuse some parts of the code.
2016-02-15 22:56:01 +03:00
Gino Pane
db9383b8aa Increase code coverage.
- Fix contents of "tests\css\sample\convert_relative_path\source\absolute.css" to test @import without url();
- Change index in array of matches (Minify.php:321) to correctly replace empty strings.
2016-02-09 17:12:30 +03:00
Gino Pane
ddfe262a62 Tests for filesystem operations.
- Split Minify::save() to easily testable methods;
- Add tests.
2016-02-09 15:53:15 +03:00
Gino Pane
21851b65bb Code cleanup. 2016-02-09 00:43:12 +03:00
Gino Pane
35a7553660 - Add shell script to convert symlinks;
- Fix JSTest data for cross-system compatibility;
- Update test-case for https://github.com/matthiasmullie/minify/issues/56 and perform fixes;
- Some code simplifications, remove some code duplicates;
- Ignore test samples for convenience of running tests;
- Update readme.
2016-02-09 00:23:23 +03:00
Matthias Mullie
13641aee3c php-cs-fixer fixes 2016-01-06 16:44:12 -08:00
Matthias Mullie
31371a6a67 Strip empty else-statements
Fixes #91
2016-01-04 14:59:19 -08:00
Matthias Mullie
72c862d141 Improve check for invalid (too long) paths (which are likely content)
Fixes #90
2016-01-04 14:22:38 -08:00
Matthias Mullie
da03f6d13c Don't strip double simicolons inside for
Fixes issue #89
2015-12-17 22:35:42 +01:00
Matthias Mullie
44cbb9c0f5 Add test for issue #66 2015-09-07 21:35:28 +02:00
Matthias Mullie
fe80dc7657 Alternative double-semicolon removal fix
Previous one didn't sufficiently remove double semicolons.
This one should be too eager, but then restore them if they
were valid in a for loop.

Fixes #70
2015-09-07 21:26:29 +02:00
Kait Todesk
f2f072ad54 Preserve for-loop semicolons when 2nd statement is empty 2015-09-07 12:05:27 +03:00
Matthias Mullie
bdbb91277b php-cs-fixer 2015-09-05 21:49:18 +02:00
Matthias Mullie
c1b61592f4 Update cache repo location 2015-09-04 11:02:35 +02:00
Matthias Mullie
c7dcdc4934 Add test for issue #64 2015-08-20 16:32:14 +02:00
Matthias Mullie
ea809e7d06 Improve string-extraction regex
Fixes bug #58
2015-08-20 16:09:10 +02:00
Matthias Mullie
c37967744d Recognize regular expressions after reserved words
Fixes issue #59
2015-08-19 16:48:35 +02:00
Matthias Mullie
76cf88faaa Add test for issue #58 2015-08-19 16:20:20 +02:00
Matthias Mullie
4cf2880e51 Preserve newline immediately after regex
Fixes issue #56
2015-08-19 16:05:08 +02:00
Matthias Mullie
5497bea3d1 Don't collapse line feeds after "return"
return is not guaranteed to be followed by a return value.
It could just be "return", followed by nothing (void return),
not even a semicolon, just line feed (ASI)
Whatever is next could, for example, be another operator.
We may just need ASI to kick in there, so keep the line feed
after return.

Fixes issue #54
2015-06-29 17:51:16 +02:00
Matthias Mullie
894928f067 Add test case for issue #53 2015-06-29 17:51:00 +02:00
Matthias Mullie
7d68b7da3b Add tests for multibyte char paths
Meanwhile also made it possible to stub a path in the tests, and
stop writing out the minifier result.
2015-05-13 17:43:25 +02:00
Matthias Mullie
49a2aca294 Allow minified data to be written to cache 2015-05-05 16:43:08 +02:00
Matthias Mullie
90837a6886 Don't replace while if it's part of a do-while
Fixes issue #50
2015-05-05 16:27:10 +02:00
Matthias Mullie
30a459229f Add gzip method
Fixed #47
2015-04-07 15:47:36 +02:00
Matthias Mullie
2a70744313 Shorten while(true) to for(;;) 2015-04-07 15:35:03 +02:00
Matthias Mullie
ecd1a04d88 Allow for-loops with empty bodies
Fixed #42
2015-04-07 15:26:37 +02:00
Matthias Mullie
e15f77b7f6 Don't convert standalone arrays
"return" looks like it could be a variable of which ['x']
is a key. I've improved the code to also check for keywords.
If whatever preceeds it is one of the keywords, don't convert.

Fixes issue #44
2015-03-12 16:11:36 +01:00
Matthias Mullie
0916262056 Don't override already restored data
Fixes issue #43
2015-03-10 10:01:13 +01:00
Matthias Mullie
d34af3d323 php-cs-fixer fixes 2015-03-06 13:17:33 +01:00