diff --git a/composer.json b/composer.json index 8b96fe9ba..4b49224c0 100644 --- a/composer.json +++ b/composer.json @@ -58,7 +58,6 @@ "symfony/finder": "^3.4 || ^4.0", "symfony/process": "^3.4 || ^4.0", "symfony/var-dumper": "^3.4 || ^4.0", - "tedivm/jshrink": "~1.0", "webmozart/path-util": "^2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 04c001d42..df476b4f7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9f08b403d0e9bf3ea33c5fc1dfb5d7f7", + "content-hash": "a79228b0119a9f3dbcd3ade691c7ad33", "packages": [ { "name": "amphp/amp", @@ -2373,52 +2373,6 @@ ], "time": "2018-04-04T05:10:37+00:00" }, - { - "name": "tedivm/jshrink", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/tedious/JShrink.git", - "reference": "68ce379b213741e86f02bf6053b0d26b9f833448" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tedious/JShrink/zipball/68ce379b213741e86f02bf6053b0d26b9f833448", - "reference": "68ce379b213741e86f02bf6053b0d26b9f833448", - "shasum": "" - }, - "require": { - "php": "^5.6|^7.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.8", - "php-coveralls/php-coveralls": "^1.1.0", - "phpunit/phpunit": "^6" - }, - "type": "library", - "autoload": { - "psr-0": { - "JShrink": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Robert Hafner", - "email": "tedivm@tedivm.com" - } - ], - "description": "Javascript Minifier built in PHP", - "homepage": "http://github.com/tedious/JShrink", - "keywords": [ - "javascript", - "minifier" - ], - "time": "2017-12-08T00:59:56+00:00" - }, { "name": "webmozart/assert", "version": "1.3.0", diff --git a/scoper.inc.php b/scoper.inc.php index a540a190a..7bbea8e42 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -102,8 +102,6 @@ function (string $filePath, string $prefix, string $contents): string { 'whitelist' => [ \Composer\Autoload\ClassLoader::class, - \Herrera\Box\Compactor\Javascript::class, - \KevinGH\Box\Compactor\Javascript::class, \Herrera\Box\Compactor\Json::class, \KevinGH\Box\Compactor\Json::class, \Herrera\Box\Compactor\Php::class, diff --git a/src/Compactor/Javascript.php b/src/Compactor/Javascript.php deleted file mode 100644 index df4331338..000000000 --- a/src/Compactor/Javascript.php +++ /dev/null @@ -1,61 +0,0 @@ - - * Théo Fidry - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace KevinGH\Box\Compactor; - -use Exception; -use JShrink\Minifier; - -/** - * Compacts Javascript files using JShrink. - * - * @author Robert Hafner - * @private - */ -final class Javascript extends FileExtensionCompactor -{ - /** - * {@inheritdoc} - */ - public function __construct(array $extensions = ['js']) - { - parent::__construct($extensions); - } - - /** - * {@inheritdoc} - */ - protected function compactContent(string $contents): string - { - try { - return Minifier::minify($contents); - } catch (Exception $e) { - // Returns unchanged content - - return $contents; - } - } - - /** - * {@inheritdoc} - */ - protected function supports(string $file): bool - { - if (!parent::supports($file)) { - return false; - } - - return '.min.js' !== substr($file, -7); - } -} diff --git a/src/functions.php b/src/functions.php index 402726fcf..02b75a069 100644 --- a/src/functions.php +++ b/src/functions.php @@ -76,10 +76,6 @@ class_alias(\Symfony\Component\Finder\Finder::class, \Isolated\Symfony\Component } // Register compactors aliases - if (false === class_exists(\Herrera\Box\Compactor\Javascript::class, false)) { - class_alias(\KevinGH\Box\Compactor\Javascript::class, \Herrera\Box\Compactor\Javascript::class); - } - if (false === class_exists(\Herrera\Box\Compactor\Json::class, false)) { class_alias(\KevinGH\Box\Compactor\Json::class, \Herrera\Box\Compactor\Json::class); } diff --git a/tests/Compactor/JavascriptTest.php b/tests/Compactor/JavascriptTest.php deleted file mode 100644 index 727e1f0ba..000000000 --- a/tests/Compactor/JavascriptTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * Théo Fidry - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace KevinGH\Box; - -use KevinGH\Box\Compactor\Javascript; -use PHPUnit\Framework\TestCase; - -/** - * @covers \KevinGH\Box\Compactor\Javascript - */ -class JavascriptTest extends TestCase -{ - /** - * @var Compactor - */ - private $compactor; - - protected function setUp(): void - { - $this->compactor = new Javascript(); - } - - /** - * @dataProvider provideFiles - */ - public function test_it_supports_javascript_files(string $file, bool $supports): void - { - $contents = <<<'JS' - - -var foo = function ( ) { - // with a lot of spaces - - var bar = ' '; -} - -JS; - $actual = $this->compactor->compact($file, $contents); - - $this->assertSame($supports, $contents !== $actual); - } - - /** - * @dataProvider provideJavascriptContent - */ - public function test_it_compacts_javascript_files(string $content, string $expected): void - { - $file = 'foo.js'; - - $actual = $this->compactor->compact($file, $content); - - $this->assertSame($expected, $actual); - } - - public function provideFiles() - { - yield 'no extension' => ['test', false]; - - yield 'JS file' => ['test.js', true]; - - yield 'minified JS file' => ['test', false]; - } - - public function provideJavascriptContent() - { - yield [ - 'new Array();', - 'new Array();', - ]; - - yield [ - <<<'JS' -(function(){ - var Array = function(){}; - - return new Array(1, 2, 3, 4); -})(); -JS - , - <<<'JS' -(function(){var Array=function(){};return new Array(1,2,3,4);})(); -JS - ]; - - yield 'invalid JavaScript' => [ - <<<'JS' -var x = "Unclosed string -JS - , - <<<'JS' -var x = "Unclosed string -JS - ]; - } -} diff --git a/tests/RequirementChecker/AppRequirementsFactoryTest.php b/tests/RequirementChecker/AppRequirementsFactoryTest.php index 98638bc33..a91fccd21 100644 --- a/tests/RequirementChecker/AppRequirementsFactoryTest.php +++ b/tests/RequirementChecker/AppRequirementsFactoryTest.php @@ -20,7 +20,7 @@ /** * @coversNothing */ -class pAppRequirementsFactoryTest extends TestCase +class AppRequirementsFactoryTest extends TestCase { /** * @dataProvider provideLockContents