From 0e03aef51623294d5f0de94e356a0cc4084a3d88 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Tue, 27 Dec 2016 15:53:00 +0100 Subject: [PATCH 1/4] Switch to kadet/keylighter for syntax highlighting --- app/config.php | 7 +- composer.json | 3 +- composer.lock | 171 +++++++++++------- src/ResultRenderer/ResultsRenderer.php | 21 ++- src/Solution/SolutionFile.php | 10 + .../AbstractResultRendererTest.php | 4 +- test/ResultRenderer/ResultsRendererTest.php | 25 ++- test/Solution/SolutionFileTest.php | 12 ++ .../test-render-success-with-solution.txt | 2 +- 9 files changed, 171 insertions(+), 84 deletions(-) diff --git a/app/config.php b/app/config.php index 104183b0..f2a3328f 100644 --- a/app/config.php +++ b/app/config.php @@ -3,6 +3,7 @@ use Colors\Color; use function DI\object; use function DI\factory; +use Kadet\Highlighter\KeyLighter; use function PhpSchool\PhpWorkshop\Event\containerListener; use Interop\Container\ContainerInterface; use League\CommonMark\DocParser; @@ -312,11 +313,15 @@ function (CgiResult $result) use ($c) { $c->get(Color::class), $c->get(TerminalInterface::class), $c->get(ExerciseRepository::class), - $c->get(SyntaxHighlighter::class), + $c->get(KeyLighter::class), $c->get(ResultRendererFactory::class) ); }, + KeyLighter::class => function () { + return new KeyLighter; + }, + 'coreContributors' => [ '@AydinHassan' => 'Aydin Hassan', '@mikeymike' => 'Michael Woodward', diff --git a/composer.json b/composer.json index a8cd2975..6e6d784f 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ "psr/http-message": "^1.0", "zendframework/zend-diactoros": "^1.3.6", "myclabs/php-enum": "^1.4", - "nikic/php-parser": "^2.1" + "nikic/php-parser": "^2.1", + "kadet/keylighter": "^0.8.2" }, "require-dev": { "composer/composer": "^1.2", diff --git a/composer.lock b/composer.lock index b334ba93..2efb6e6e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "bea3db6062cfb2b8d5bbcac5c9cfc1e9", + "content-hash": "205b31ee5354bbeae6bbe1ac5af6744e", "packages": [ { "name": "aydin-hassan/cli-md-renderer", @@ -51,16 +51,16 @@ }, { "name": "beberlei/assert", - "version": "v2.6.7", + "version": "v2.6.8", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "2b4c9249a7ceef51402d39bd797aae16cfd8f36f" + "reference": "848c8f0bde97b48d1e159075e20a6667583f3978" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/2b4c9249a7ceef51402d39bd797aae16cfd8f36f", - "reference": "2b4c9249a7ceef51402d39bd797aae16cfd8f36f", + "url": "https://api.github.com/repos/beberlei/assert/zipball/848c8f0bde97b48d1e159075e20a6667583f3978", + "reference": "848c8f0bde97b48d1e159075e20a6667583f3978", "shasum": "" }, "require": { @@ -68,13 +68,13 @@ "php": ">=5.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "2.0.0-alpha", + "friendsofphp/php-cs-fixer": "^2.0", "phpunit/phpunit": "@stable" }, "type": "library", "autoload": { - "psr-0": { - "Assert": "lib/" + "psr-4": { + "Assert\\": "lib/Assert" }, "files": [ "lib/Assert/functions.php" @@ -102,7 +102,7 @@ "assertion", "validation" ], - "time": "2016-11-14T16:46:13+00:00" + "time": "2016-12-05T11:33:17+00:00" }, { "name": "container-interop/container-interop", @@ -179,6 +179,55 @@ ], "time": "2016-04-29T12:21:54+00:00" }, + { + "name": "kadet/keylighter", + "version": "v0.8.2", + "source": { + "type": "git", + "url": "https://github.com/kadet1090/KeyLighter.git", + "reference": "0d2e6e4e542c282c22c66567174554ad67d047be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kadet1090/KeyLighter/zipball/0d2e6e4e542c282c22c66567174554ad67d047be", + "reference": "0d2e6e4e542c282c22c66567174554ad67d047be", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "4.8.*", + "symfony/console": "^2.8|^3.0" + }, + "suggest": { + "symfony/console": "Allows usage of keylighters CLI utility." + }, + "bin": [ + "bin/keylighter" + ], + "type": "library", + "autoload": { + "psr-4": { + "Kadet\\Highlighter\\": "." + }, + "files": [ + "./functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kacper Donat", + "email": "contact@kadet.net" + } + ], + "description": "Yet another syntax highlighter for PHP", + "time": "2016-09-16T21:34:34+00:00" + }, { "name": "kevinlebrun/colors.php", "version": "0.4.1", @@ -682,7 +731,7 @@ }, { "name": "symfony/filesystem", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -731,7 +780,7 @@ }, { "name": "symfony/process", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -890,32 +939,32 @@ }, { "name": "composer/composer", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "e7f19286a7e7f940950c9069a0f549d483c30ba7" + "reference": "e53f9e5381e70f76e098136343e27d92601eade7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/e7f19286a7e7f940950c9069a0f549d483c30ba7", - "reference": "e7f19286a7e7f940950c9069a0f549d483c30ba7", + "url": "https://api.github.com/repos/composer/composer/zipball/e53f9e5381e70f76e098136343e27d92601eade7", + "reference": "e53f9e5381e70f76e098136343e27d92601eade7", "shasum": "" }, "require": { "composer/ca-bundle": "^1.0", "composer/semver": "^1.0", "composer/spdx-licenses": "^1.0", - "justinrainbow/json-schema": "^1.6 || ^2.0", + "justinrainbow/json-schema": "^1.6 || ^2.0 || ^3.0 || ^4.0", "php": "^5.3.2 || ^7.0", "psr/log": "^1.0", "seld/cli-prompt": "^1.0", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.0", - "symfony/console": "^2.5 || ^3.0", - "symfony/filesystem": "^2.5 || ^3.0", - "symfony/finder": "^2.2 || ^3.0", - "symfony/process": "^2.1 || ^3.0" + "symfony/console": "^2.7 || ^3.0", + "symfony/filesystem": "^2.7 || ^3.0", + "symfony/finder": "^2.7 || ^3.0", + "symfony/process": "^2.7 || ^3.0" }, "require-dev": { "phpunit/phpunit": "^4.5 || ^5.0.5", @@ -932,7 +981,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -963,7 +1012,7 @@ "dependency", "package" ], - "time": "2016-12-01T13:33:53+00:00" + "time": "2016-12-23T23:47:04+00:00" }, { "name": "composer/semver", @@ -1144,16 +1193,16 @@ }, { "name": "justinrainbow/json-schema", - "version": "2.0.5", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/justinrainbow/json-schema.git", - "reference": "6b2a33e6a768f96bdc2ead5600af0822eed17d67" + "reference": "d39c56a46b3ebe1f3696479966cd2b9f50aaa24f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/6b2a33e6a768f96bdc2ead5600af0822eed17d67", - "reference": "6b2a33e6a768f96bdc2ead5600af0822eed17d67", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/d39c56a46b3ebe1f3696479966cd2b9f50aaa24f", + "reference": "d39c56a46b3ebe1f3696479966cd2b9f50aaa24f", "shasum": "" }, "require": { @@ -1170,7 +1219,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -1206,7 +1255,7 @@ "json", "schema" ], - "time": "2016-06-02T10:59:52+00:00" + "time": "2016-12-22T16:43:46+00:00" }, { "name": "myclabs/deep-copy", @@ -1461,16 +1510,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "903fd6318d0a90b4770a009ff73e4a4e9c437929" + "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/903fd6318d0a90b4770a009ff73e4a4e9c437929", - "reference": "903fd6318d0a90b4770a009ff73e4a4e9c437929", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c14196e64a78570034afd0b7a9f3757ba71c2a0a", + "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a", "shasum": "" }, "require": { @@ -1520,7 +1569,7 @@ "testing", "xunit" ], - "time": "2016-11-28T16:00:31+00:00" + "time": "2016-12-20T15:22:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1705,16 +1754,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.2", + "version": "5.7.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "336aff0ac52e306c98e7455bc3e8d7b0bf777a5e" + "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/336aff0ac52e306c98e7455bc3e8d7b0bf777a5e", - "reference": "336aff0ac52e306c98e7455bc3e8d7b0bf777a5e", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09", + "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09", "shasum": "" }, "require": { @@ -1725,7 +1774,7 @@ "ext-xml": "*", "myclabs/deep-copy": "~1.3", "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.3.1", + "phpspec/prophecy": "^1.6.2", "phpunit/php-code-coverage": "^4.0.3", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", @@ -1735,7 +1784,7 @@ "sebastian/diff": "~1.2", "sebastian/environment": "^1.3.4 || ^2.0", "sebastian/exporter": "~2.0", - "sebastian/global-state": "~1.0", + "sebastian/global-state": "^1.0 || ^2.0", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", "sebastian/version": "~1.0|~2.0", @@ -1783,20 +1832,20 @@ "testing", "xunit" ], - "time": "2016-12-03T08:33:00+00:00" + "time": "2016-12-13T16:19:44+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.4.2", + "version": "3.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "90a08f5deed5f7ac35463c161f2e8fa0e5652faf" + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/90a08f5deed5f7ac35463c161f2e8fa0e5652faf", - "reference": "90a08f5deed5f7ac35463c161f2e8fa0e5652faf", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", "shasum": "" }, "require": { @@ -1842,7 +1891,7 @@ "mock", "xunit" ], - "time": "2016-11-27T07:52:03+00:00" + "time": "2016-12-08T20:27:08+00:00" }, { "name": "psr/log", @@ -2622,16 +2671,16 @@ }, { "name": "symfony/console", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "09d0fd33560e3573185a2ea17614e37ba38716c5" + "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/09d0fd33560e3573185a2ea17614e37ba38716c5", - "reference": "09d0fd33560e3573185a2ea17614e37ba38716c5", + "url": "https://api.github.com/repos/symfony/console/zipball/d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", + "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", "shasum": "" }, "require": { @@ -2681,11 +2730,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-11-16T22:18:16+00:00" + "time": "2016-12-11T14:34:22+00:00" }, { "name": "symfony/debug", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", @@ -2742,16 +2791,16 @@ }, { "name": "symfony/finder", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "4263e35a1e342a0f195c9349c0dee38148f8a14f" + "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/4263e35a1e342a0f195c9349c0dee38148f8a14f", - "reference": "4263e35a1e342a0f195c9349c0dee38148f8a14f", + "url": "https://api.github.com/repos/symfony/finder/zipball/a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", + "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", "shasum": "" }, "require": { @@ -2787,7 +2836,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-11-03T08:11:03+00:00" + "time": "2016-12-13T09:39:43+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2850,16 +2899,16 @@ }, { "name": "symfony/yaml", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f2300ba8fbb002c028710b92e1906e7457410693" + "reference": "a7095af4b97a0955f85c8989106c249fa649011f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f2300ba8fbb002c028710b92e1906e7457410693", - "reference": "f2300ba8fbb002c028710b92e1906e7457410693", + "url": "https://api.github.com/repos/symfony/yaml/zipball/a7095af4b97a0955f85c8989106c249fa649011f", + "reference": "a7095af4b97a0955f85c8989106c249fa649011f", "shasum": "" }, "require": { @@ -2901,7 +2950,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-11-18T21:17:59+00:00" + "time": "2016-12-10T10:07:06+00:00" }, { "name": "webmozart/assert", diff --git a/src/ResultRenderer/ResultsRenderer.php b/src/ResultRenderer/ResultsRenderer.php index bc1ebd76..c589fd29 100644 --- a/src/ResultRenderer/ResultsRenderer.php +++ b/src/ResultRenderer/ResultsRenderer.php @@ -3,6 +3,8 @@ namespace PhpSchool\PhpWorkshop\ResultRenderer; use Colors\Color; +use Kadet\Highlighter\Formatter\CliFormatter; +use Kadet\Highlighter\KeyLighter; use PhpSchool\CliMenu\Terminal\TerminalInterface; use PhpSchool\CliMenu\Util\StringUtil; use PhpSchool\PhpWorkshop\Exercise\ProvidesSolution; @@ -45,9 +47,9 @@ class ResultsRenderer private $terminal; /** - * @var SyntaxHighlighter + * @var KeyLighter */ - private $syntaxHighlighter; + private $keyLighter; /** * @var ResultRendererFactory @@ -59,7 +61,7 @@ class ResultsRenderer * @param Color $color A instance of `Color` used to colour strings with ANSI escape codes. * @param TerminalInterface $terminal A helper to get information regarding the current terminal. * @param ExerciseRepository $exerciseRepository The exercise repository. - * @param SyntaxHighlighter $syntaxHighlighter A PHP syntax highlighter for the terminal, uses ANSI escape codes. + * @param KeyLighter $keyLighter A syntax highlighter * @param ResultRendererFactory $resultRendererFactory */ public function __construct( @@ -67,13 +69,13 @@ public function __construct( Color $color, TerminalInterface $terminal, ExerciseRepository $exerciseRepository, - SyntaxHighlighter $syntaxHighlighter, + KeyLighter $keyLighter, ResultRendererFactory $resultRendererFactory ) { $this->color = $color; $this->terminal = $terminal; $this->exerciseRepository = $exerciseRepository; - $this->syntaxHighlighter = $syntaxHighlighter; + $this->keyLighter = $keyLighter; $this->appName = $appName; $this->resultRendererFactory = $resultRendererFactory; } @@ -186,10 +188,11 @@ private function renderSuccessInformation( $output->writeLine($this->style($file->getRelativePath(), ['bold', 'cyan', 'underline'])); $output->emptyLine(); - $code = $file->getContents(); - if (pathinfo($file->getRelativePath(), PATHINFO_EXTENSION) === 'php') { - $code = $this->syntaxHighlighter->highlight($code); - } + $code = $this->keyLighter->highlight( + $file->getContents(), + $this->keyLighter->languageByExt('.' . $file->getExtension()), + new CliFormatter + ); //make sure there is a new line at the end $code = preg_replace('/\n$/', '', $code) . "\n"; diff --git a/src/Solution/SolutionFile.php b/src/Solution/SolutionFile.php index b8afe4c9..a9e0c2e3 100644 --- a/src/Solution/SolutionFile.php +++ b/src/Solution/SolutionFile.php @@ -89,6 +89,16 @@ public function getContents() return file_get_contents($this->getAbsolutePath()); } + /** + * Get the file extension. + * + * @return string + */ + public function getExtension() + { + return pathinfo($this->getRelativePath(), PATHINFO_EXTENSION); + } + /** * Proxy to the absolute path. * diff --git a/test/ResultRenderer/AbstractResultRendererTest.php b/test/ResultRenderer/AbstractResultRendererTest.php index 842763ce..724010cc 100644 --- a/test/ResultRenderer/AbstractResultRendererTest.php +++ b/test/ResultRenderer/AbstractResultRendererTest.php @@ -3,6 +3,7 @@ namespace PhpSchool\PhpWorkshopTest\ResultRenderer; use Colors\Color; +use Kadet\Highlighter\KeyLighter; use PhpSchool\CliMenu\Terminal\TerminalInterface; use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory; use PhpSchool\PSX\Factory; @@ -52,13 +53,12 @@ protected function getRenderer() $terminal->getWidth()->willReturn(50); $exerciseRepo = $this->createMock(ExerciseRepository::class); - $syntaxHighlighter = (new Factory)->__invoke(); $this->renderer = new ResultsRenderer( 'appName', $color, $terminal->reveal(), $exerciseRepo, - $syntaxHighlighter, + new KeyLighter, $this->getResultRendererFactory() ); } diff --git a/test/ResultRenderer/ResultsRendererTest.php b/test/ResultRenderer/ResultsRendererTest.php index ff444b13..82448d8f 100644 --- a/test/ResultRenderer/ResultsRendererTest.php +++ b/test/ResultRenderer/ResultsRendererTest.php @@ -3,6 +3,9 @@ namespace PhpSchool\PhpWorkshopTest\ResultRenderer; use Colors\Color; +use Kadet\Highlighter\Formatter\CliFormatter; +use Kadet\Highlighter\KeyLighter; +use Kadet\Highlighter\Language\Php; use PhpSchool\CliMenu\Terminal\TerminalInterface; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\Exercise\ProvidesSolution; @@ -47,7 +50,7 @@ public function testRenderIndividualResult() $color, $terminal->reveal(), new ExerciseRepository([]), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); @@ -69,7 +72,7 @@ public function testLineBreak() $color, $terminal->reveal(), new ExerciseRepository([]), - (new Factory)->__invoke(), + new KeyLighter, new ResultRendererFactory ); @@ -95,7 +98,7 @@ public function testRenderSuccess() $color, $terminal, $exerciseRepo->reveal(), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); @@ -142,7 +145,7 @@ public function testRenderSuccessWithSolution() $color, $terminal, $exerciseRepo->reveal(), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); @@ -187,8 +190,12 @@ public function testRenderSuccessWithPhpSolutionFileIsSyntaxHighlighted() $exercise->willImplement(ProvidesSolution::class); $exercise->getSolution()->willReturn($solution); - $syntaxHighlighter = $this->prophesize(SyntaxHighlighter::class); - $syntaxHighlighter->highlight('FILE CONTENTS')->willReturn('FILE CONTENTS'); + $syntaxHighlighter = $this->prophesize(KeyLighter::class); + $php = new Php; + $syntaxHighlighter->languageByExt('.php')->willReturn($php); + $syntaxHighlighter + ->highlight('FILE CONTENTS', $php, Argument::type(CliFormatter::class)) + ->willReturn('FILE CONTENTS'); $renderer = new ResultsRenderer( 'app', @@ -240,7 +247,7 @@ public function testRenderSuccessAndFailure() $color, $terminal, $exerciseRepo->reveal(), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); @@ -283,7 +290,7 @@ public function testAllSuccessResultsAreHoistedToTheTop() $color, $terminal, $exerciseRepo->reveal(), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); @@ -327,7 +334,7 @@ public function testRenderAllFailures() $color, $terminal, $exerciseRepo->reveal(), - (new Factory)->__invoke(), + new KeyLighter, $resultRendererFactory ); diff --git a/test/Solution/SolutionFileTest.php b/test/Solution/SolutionFileTest.php index b5329e07..8e02e7af 100644 --- a/test/Solution/SolutionFileTest.php +++ b/test/Solution/SolutionFileTest.php @@ -92,4 +92,16 @@ public function testConstructionWithManualBaseDirectory() unlink($filePath); rmdir($tempPath); } + + public function testGetExtension() + { + $tempPath = sprintf('%s/%s/sub-dir', sys_get_temp_dir(), $this->getName()); + $filePath = sprintf('%s/test.php', $tempPath); + + @mkdir($tempPath, 0775, true); + touch($filePath); + + $file = new SolutionFile('test.php', $tempPath); + $this->assertSame('php', $file->getExtension()); + } } diff --git a/test/res/exercise-renderer/test-render-success-with-solution.txt b/test/res/exercise-renderer/test-render-success-with-solution.txt index 47afaf8b..93453380 100644 --- a/test/res/exercise-renderer/test-render-success-with-solution.txt +++ b/test/res/exercise-renderer/test-render-success-with-solution.txt @@ -20,7 +20,7 @@ ──────────────────────────────────────────────────────────────────────────────────────────────────── some-file -FILE CONTENTS +FILE CONTENTS ──────────────────────────────────────────────────────────────────────────────────────────────────── You have 1 challenges left. From 22669aa049c1369b3fcff8cce072ca0d7ba495d9 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sat, 4 Mar 2017 20:17:35 +0100 Subject: [PATCH 2/4] Update to PHP Parser 3 --- composer.json | 7 +- composer.lock | 356 +++++++++++---------- src/Factory/MarkdownCliRendererFactory.php | 4 +- test/CodePatcherTest.php | 4 +- 4 files changed, 194 insertions(+), 177 deletions(-) diff --git a/composer.json b/composer.json index 6e6d784f..d4d6eadf 100644 --- a/composer.json +++ b/composer.json @@ -23,15 +23,14 @@ "symfony/process": "^2.3|^3.0", "symfony/filesystem": "^2.3|^3.0", "fzaninotto/faker": "^1.5", - "aydin-hassan/cli-md-renderer": "^2.1", - "php-school/psx": "~1.0", + "aydin-hassan/cli-md-renderer": "dev-use-keylighter", "php-school/cli-menu": "^2.0", "beberlei/assert": "^2.4", "psr/http-message": "^1.0", "zendframework/zend-diactoros": "^1.3.6", "myclabs/php-enum": "^1.4", - "nikic/php-parser": "^2.1", - "kadet/keylighter": "^0.8.2" + "kadet/keylighter": "^0.8.2", + "nikic/php-parser": "^3.0" }, "require-dev": { "composer/composer": "^1.2", diff --git a/composer.lock b/composer.lock index 2efb6e6e..999bf795 100644 --- a/composer.lock +++ b/composer.lock @@ -4,27 +4,27 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "205b31ee5354bbeae6bbe1ac5af6744e", + "content-hash": "fb844a308c2e30db2f86e3707b2d8b18", "packages": [ { "name": "aydin-hassan/cli-md-renderer", - "version": "2.1.0", + "version": "dev-use-keylighter", "source": { "type": "git", "url": "https://github.com/AydinHassan/cli-md-renderer.git", - "reference": "acde5854fd82e37e88e39f95b5fc19cc395df159" + "reference": "8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/AydinHassan/cli-md-renderer/zipball/acde5854fd82e37e88e39f95b5fc19cc395df159", - "reference": "acde5854fd82e37e88e39f95b5fc19cc395df159", + "url": "https://api.github.com/repos/AydinHassan/cli-md-renderer/zipball/8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f", + "reference": "8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f", "shasum": "" }, "require": { + "kadet/keylighter": "^0.8.2", + "kevinlebrun/colors.php": "^1.0", "league/commonmark": "^0.13", - "nikic/php-parser": "^2.0", - "php": ">=5.5", - "php-school/psx": "^1.1.1" + "php": ">=5.5" }, "require-dev": { "phpunit/phpunit": "~4.1", @@ -47,20 +47,20 @@ } ], "description": "A CLI Markdown Render for league/commonmark compatibile AST", - "time": "2016-10-27T17:47:22+00:00" + "time": "2017-03-04 19:11:13" }, { "name": "beberlei/assert", - "version": "v2.6.8", + "version": "v2.7.3", "source": { "type": "git", "url": "https://github.com/beberlei/assert.git", - "reference": "848c8f0bde97b48d1e159075e20a6667583f3978" + "reference": "5972776d6a9eedfd3c55216341434e19cb50418f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/beberlei/assert/zipball/848c8f0bde97b48d1e159075e20a6667583f3978", - "reference": "848c8f0bde97b48d1e159075e20a6667583f3978", + "url": "https://api.github.com/repos/beberlei/assert/zipball/5972776d6a9eedfd3c55216341434e19cb50418f", + "reference": "5972776d6a9eedfd3c55216341434e19cb50418f", "shasum": "" }, "require": { @@ -102,22 +102,25 @@ "assertion", "validation" ], - "time": "2016-12-05T11:33:17+00:00" + "time": "2017-01-24T15:14:39+00:00" }, { "name": "container-interop/container-interop", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/container-interop/container-interop.git", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", "shasum": "" }, + "require": { + "psr/container": "^1.0" + }, "type": "library", "autoload": { "psr-4": { @@ -129,7 +132,8 @@ "MIT" ], "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", - "time": "2014-12-30T15:22:37+00:00" + "homepage": "https://github.com/container-interop/container-interop", + "time": "2017-02-14T19:40:03+00:00" }, { "name": "fzaninotto/faker", @@ -230,16 +234,16 @@ }, { "name": "kevinlebrun/colors.php", - "version": "0.4.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/kevinlebrun/colors.php.git", - "reference": "d132f36d06e48ea080855af19b4bcb1fb615224a" + "reference": "6d7140aeedef46c97c2324f09b752c599ef17dac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/d132f36d06e48ea080855af19b4bcb1fb615224a", - "reference": "d132f36d06e48ea080855af19b4bcb1fb615224a", + "url": "https://api.github.com/repos/kevinlebrun/colors.php/zipball/6d7140aeedef46c97c2324f09b752c599ef17dac", + "reference": "6d7140aeedef46c97c2324f09b752c599ef17dac", "shasum": "" }, "require": { @@ -247,7 +251,7 @@ }, "require-dev": { "phpunit/phpunit": "3.7.*", - "satooshi/php-coveralls": "dev-master", + "satooshi/php-coveralls": "1.0.*", "squizlabs/php_codesniffer": "1.*" }, "type": "library", @@ -277,7 +281,7 @@ "console", "shell" ], - "time": "2014-12-23T01:23:37+00:00" + "time": "2016-04-12T20:58:34+00:00" }, { "name": "league/commonmark", @@ -394,24 +398,24 @@ }, { "name": "nikic/php-parser", - "version": "v2.1.1", + "version": "v3.0.4", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0" + "reference": "0bf561dfe75ba80441c22adecc0529056671a7d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0", - "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0bf561dfe75ba80441c22adecc0529056671a7d2", + "reference": "0bf561dfe75ba80441c22adecc0529056671a7d2", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.4" + "php": ">=5.5" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.0|~5.0" }, "bin": [ "bin/php-parse" @@ -419,7 +423,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -441,7 +445,7 @@ "parser", "php" ], - "time": "2016-09-16T12:04:44+00:00" + "time": "2017-02-10T20:20:03+00:00" }, { "name": "php-di/invoker", @@ -585,16 +589,16 @@ }, { "name": "php-school/cli-menu", - "version": "2.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-school/cli-menu.git", - "reference": "5472d7d4fc7b5753820cfb2628f4bf907937e90c" + "reference": "f08d25e2818d9e2e60286cef4a11b45fd8c72de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/cli-menu/zipball/5472d7d4fc7b5753820cfb2628f4bf907937e90c", - "reference": "5472d7d4fc7b5753820cfb2628f4bf907937e90c", + "url": "https://api.github.com/repos/php-school/cli-menu/zipball/f08d25e2818d9e2e60286cef4a11b45fd8c72de3", + "reference": "f08d25e2818d9e2e60286cef4a11b45fd8c72de3", "shasum": "" }, "require": { @@ -635,35 +639,34 @@ "phpschool", "terminal" ], - "time": "2016-10-27T21:31:02+00:00" + "time": "2017-03-01T21:55:27+00:00" }, { - "name": "php-school/psx", - "version": "1.1.2", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/php-school/psx.git", - "reference": "4063d9ac62e057897a41be11ec979424ed93035c" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-school/psx/zipball/4063d9ac62e057897a41be11ec979424ed93035c", - "reference": "4063d9ac62e057897a41be11ec979424ed93035c", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { - "kevinlebrun/colors.php": "^0.4.1", - "nikic/php-parser": "^2.0", - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "~4.1", - "squizlabs/php_codesniffer": "~2.0" + "php": ">=5.3.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { "psr-4": { - "PhpSchool\\PSX\\": "src" + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -672,12 +675,20 @@ ], "authors": [ { - "name": "Aydin Hassan", - "email": "aydin@hotmail.co.uk" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "PHP CLI Syntax Highlighter", - "time": "2016-03-30T22:07:50+00:00" + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" }, { "name": "psr/http-message", @@ -731,16 +742,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4" + "reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4", - "reference": "8d4cf7561a5b17e5eb7a02b80d0b8f014a3796d4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/a0c6ef2dc78d33b58d91d3a49f49797a184d06f4", + "reference": "a0c6ef2dc78d33b58d91d3a49f49797a184d06f4", "shasum": "" }, "require": { @@ -776,20 +787,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-11-24T00:46:43+00:00" + "time": "2017-01-08T20:47:33+00:00" }, { "name": "symfony/process", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "02ea84847aad71be7e32056408bb19f3a616cdd3" + "reference": "0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/02ea84847aad71be7e32056408bb19f3a616cdd3", - "reference": "02ea84847aad71be7e32056408bb19f3a616cdd3", + "url": "https://api.github.com/repos/symfony/process/zipball/0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856", + "reference": "0ab87c1e7570b3534a6e51eb4ca8e9f6d7327856", "shasum": "" }, "require": { @@ -825,20 +836,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2016-11-24T10:40:28+00:00" + "time": "2017-02-16T14:07:22+00:00" }, { "name": "zendframework/zend-diactoros", - "version": "1.3.7", + "version": "1.3.10", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "969ff423d3f201da3ff718a5831bb999bb0669b0" + "reference": "83e8d98b9915de76c659ce27d683c02a0f99fa90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/969ff423d3f201da3ff718a5831bb999bb0669b0", - "reference": "969ff423d3f201da3ff718a5831bb999bb0669b0", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/83e8d98b9915de76c659ce27d683c02a0f99fa90", + "reference": "83e8d98b9915de76c659ce27d683c02a0f99fa90", "shasum": "" }, "require": { @@ -850,7 +861,7 @@ }, "require-dev": { "phpunit/phpunit": "^4.6 || ^5.5", - "squizlabs/php_codesniffer": "^2.3.1" + "zendframework/zend-coding-standard": "~1.0.0" }, "type": "library", "extra": { @@ -875,7 +886,7 @@ "psr", "psr-7" ], - "time": "2016-10-11T13:25:21+00:00" + "time": "2017-01-23T04:53:24+00:00" } ], "packages-dev": [ @@ -939,16 +950,16 @@ }, { "name": "composer/composer", - "version": "1.3.0", + "version": "1.3.2", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "e53f9e5381e70f76e098136343e27d92601eade7" + "reference": "e7569edb4a5eadcbb2e4ad5ed753282260f281df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/e53f9e5381e70f76e098136343e27d92601eade7", - "reference": "e53f9e5381e70f76e098136343e27d92601eade7", + "url": "https://api.github.com/repos/composer/composer/zipball/e7569edb4a5eadcbb2e4ad5ed753282260f281df", + "reference": "e7569edb4a5eadcbb2e4ad5ed753282260f281df", "shasum": "" }, "require": { @@ -1012,7 +1023,7 @@ "dependency", "package" ], - "time": "2016-12-23T23:47:04+00:00" + "time": "2017-01-27T17:23:42+00:00" }, { "name": "composer/semver", @@ -1259,16 +1270,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.5.5", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108" + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe", + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe", "shasum": "" }, "require": { @@ -1297,7 +1308,7 @@ "object", "object graph" ], - "time": "2016-10-31T17:19:45+00:00" + "time": "2017-01-26T22:05:40+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1447,27 +1458,27 @@ }, { "name": "phpspec/prophecy", - "version": "v1.6.2", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb" + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0|^2.0" + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.0", + "phpspec/phpspec": "^2.5|^3.2", "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", @@ -1506,39 +1517,39 @@ "spy", "stub" ], - "time": "2016-11-21T14:58:47+00:00" + "time": "2017-03-02T20:05:34+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "4.0.4", + "version": "4.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a" + "reference": "09e2277d14ea467e5a984010f501343ef29ffc69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c14196e64a78570034afd0b7a9f3757ba71c2a0a", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/09e2277d14ea467e5a984010f501343ef29ffc69", + "reference": "09e2277d14ea467e5a984010f501343ef29ffc69", "shasum": "" }, "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "~1.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "~1.0|~2.0" + "sebastian/version": "^1.0 || ^2.0" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "^5.4" + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.4.0", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.5.1" }, "type": "library", "extra": { @@ -1569,7 +1580,7 @@ "testing", "xunit" ], - "time": "2016-12-20T15:22:42+00:00" + "time": "2017-03-01T09:12:17+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1661,25 +1672,30 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4|~5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1701,20 +1717,20 @@ "keywords": [ "timer" ], - "time": "2016-05-12T18:03:57+00:00" + "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.9", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -1750,20 +1766,20 @@ "keywords": [ "tokenizer" ], - "time": "2016-11-15T14:06:22+00:00" + "time": "2017-02-27T10:12:30+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.4", + "version": "5.7.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09" + "reference": "b99112aecc01f62acf3d81a3f59646700a1849e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b99112aecc01f62acf3d81a3f59646700a1849e5", + "reference": "b99112aecc01f62acf3d81a3f59646700a1849e5", "shasum": "" }, "require": { @@ -1775,19 +1791,19 @@ "myclabs/deep-copy": "~1.3", "php": "^5.6 || ^7.0", "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.3", + "phpunit/php-code-coverage": "^4.0.4", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "~1.2.2", + "sebastian/comparator": "^1.2.4", "sebastian/diff": "~1.2", "sebastian/environment": "^1.3.4 || ^2.0", "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.0 || ^2.0", + "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0|~2.0", + "sebastian/version": "~1.0.3|~2.0", "symfony/yaml": "~2.1|~3.0" }, "conflict": { @@ -1832,7 +1848,7 @@ "testing", "xunit" ], - "time": "2016-12-13T16:19:44+00:00" + "time": "2017-03-02T15:22:43+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -1942,23 +1958,23 @@ }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "shasum": "" }, "require": { - "php": ">=5.6" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^5.7 || ^6.0" }, "type": "library", "extra": { @@ -1983,20 +1999,20 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2016-02-13T06:45:14+00:00" + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", - "version": "1.2.2", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { @@ -2047,7 +2063,7 @@ "compare", "equality" ], - "time": "2016-11-19T09:18:40+00:00" + "time": "2017-01-29T09:50:25+00:00" }, { "name": "sebastian/diff", @@ -2271,16 +2287,16 @@ }, { "name": "sebastian/object-enumerator", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35" + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", "shasum": "" }, "require": { @@ -2313,7 +2329,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-11-19T07:35:10+00:00" + "time": "2017-02-18T15:18:39+00:00" }, { "name": "sebastian/recursion-context", @@ -2593,16 +2609,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.7.1", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f" + "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9b324f3a1132459a7274a0ace2e1b766ba80930f", - "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", + "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "shasum": "" }, "require": { @@ -2667,20 +2683,20 @@ "phpcs", "standards" ], - "time": "2016-11-30T04:02:31+00:00" + "time": "2017-03-01T22:17:45+00:00" }, { "name": "symfony/console", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa" + "reference": "0e5e6899f82230fcb1153bcaf0e106ffaa44b870" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", - "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", + "url": "https://api.github.com/repos/symfony/console/zipball/0e5e6899f82230fcb1153bcaf0e106ffaa44b870", + "reference": "0e5e6899f82230fcb1153bcaf0e106ffaa44b870", "shasum": "" }, "require": { @@ -2730,20 +2746,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-12-11T14:34:22+00:00" + "time": "2017-02-16T14:07:22+00:00" }, { "name": "symfony/debug", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231" + "reference": "9b98854cb45bc59d100b7d4cc4cf9e05f21026b9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/9f923e68d524a3095c5a2ae5fc7220c7cbc12231", - "reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231", + "url": "https://api.github.com/repos/symfony/debug/zipball/9b98854cb45bc59d100b7d4cc4cf9e05f21026b9", + "reference": "9b98854cb45bc59d100b7d4cc4cf9e05f21026b9", "shasum": "" }, "require": { @@ -2787,20 +2803,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2016-11-16T22:18:16+00:00" + "time": "2017-02-16T16:34:18+00:00" }, { "name": "symfony/finder", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b" + "reference": "8c71141cae8e2957946b403cc71a67213c0380d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", - "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", + "url": "https://api.github.com/repos/symfony/finder/zipball/8c71141cae8e2957946b403cc71a67213c0380d6", + "reference": "8c71141cae8e2957946b403cc71a67213c0380d6", "shasum": "" }, "require": { @@ -2836,7 +2852,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-12-13T09:39:43+00:00" + "time": "2017-01-02T20:32:22+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -2899,16 +2915,16 @@ }, { "name": "symfony/yaml", - "version": "v3.2.1", + "version": "v3.2.4", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f" + "reference": "9724c684646fcb5387d579b4bfaa63ee0b0c64c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a7095af4b97a0955f85c8989106c249fa649011f", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f", + "url": "https://api.github.com/repos/symfony/yaml/zipball/9724c684646fcb5387d579b4bfaa63ee0b0c64c8", + "reference": "9724c684646fcb5387d579b4bfaa63ee0b0c64c8", "shasum": "" }, "require": { @@ -2950,7 +2966,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-12-10T10:07:06+00:00" + "time": "2017-02-16T22:46:52+00:00" }, { "name": "webmozart/assert", @@ -3005,7 +3021,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "aydin-hassan/cli-md-renderer": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Factory/MarkdownCliRendererFactory.php b/src/Factory/MarkdownCliRendererFactory.php index 10e57e83..40949984 100644 --- a/src/Factory/MarkdownCliRendererFactory.php +++ b/src/Factory/MarkdownCliRendererFactory.php @@ -6,6 +6,7 @@ use AydinHassan\CliMdRenderer\Renderer\ListItemRenderer; use Colors\Color; use Interop\Container\ContainerInterface; +use Kadet\Highlighter\KeyLighter; use League\CommonMark\Block\Element\Heading; use League\CommonMark\Block\Element\ListBlock; use League\CommonMark\Block\Element\ListItem; @@ -49,9 +50,8 @@ public function __invoke(ContainerInterface $c) { $terminal = $c->get(TerminalInterface::class); - $highlighterFactory = new PSXFactory; $codeRender = new FencedCodeRenderer(); - $codeRender->addSyntaxHighlighter('php', new PhpHighlighter($highlighterFactory->__invoke())); + $codeRender->addSyntaxHighlighter('php', new PhpHighlighter(new KeyLighter)); $blockRenderers = [ Document::class => new DocumentRenderer, diff --git a/test/CodePatcherTest.php b/test/CodePatcherTest.php index 7bd2b6e3..36323681 100644 --- a/test/CodePatcherTest.php +++ b/test/CodePatcherTest.php @@ -108,7 +108,7 @@ public function codeProvider() (new Patch) ->withTransformer(function (array $statements) { return [ - new TryCatch($statements, [new Catch_(new Name(\Exception::class), 'e', [])]) + new TryCatch($statements, [new Catch_([new Name(\Exception::class)], 'e', [])]) ]; }), "withInsertion(new Insertion(Insertion::TYPE_BEFORE, '$before = "here";')) ->withTransformer(function (array $statements) { return [ - new TryCatch($statements, [new Catch_(new Name(\Exception::class), 'e', [])]) + new TryCatch($statements, [new Catch_([new Name(\Exception::class)], 'e', [])]) ]; }), " Date: Sun, 5 Mar 2017 09:43:53 +0100 Subject: [PATCH 3/4] Update constraint --- composer.json | 2 +- composer.lock | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index d4d6eadf..85653c69 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "symfony/process": "^2.3|^3.0", "symfony/filesystem": "^2.3|^3.0", "fzaninotto/faker": "^1.5", - "aydin-hassan/cli-md-renderer": "dev-use-keylighter", + "aydin-hassan/cli-md-renderer": "^2.2", "php-school/cli-menu": "^2.0", "beberlei/assert": "^2.4", "psr/http-message": "^1.0", diff --git a/composer.lock b/composer.lock index 999bf795..5930dc21 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "fb844a308c2e30db2f86e3707b2d8b18", + "content-hash": "c73a3c5ce8050c3481c108a0a9ff0194", "packages": [ { "name": "aydin-hassan/cli-md-renderer", - "version": "dev-use-keylighter", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/AydinHassan/cli-md-renderer.git", - "reference": "8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f" + "reference": "7b4280cb482a6ff08ff629863b37f04d079b4de9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/AydinHassan/cli-md-renderer/zipball/8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f", - "reference": "8b95ba98ebf5c1c58aa830f0b3c6df00c77b6d6f", + "url": "https://api.github.com/repos/AydinHassan/cli-md-renderer/zipball/7b4280cb482a6ff08ff629863b37f04d079b4de9", + "reference": "7b4280cb482a6ff08ff629863b37f04d079b4de9", "shasum": "" }, "require": { @@ -47,7 +47,7 @@ } ], "description": "A CLI Markdown Render for league/commonmark compatibile AST", - "time": "2017-03-04 19:11:13" + "time": "2017-03-05T08:32:08+00:00" }, { "name": "beberlei/assert", @@ -3021,9 +3021,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "aydin-hassan/cli-md-renderer": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 1770ec4579155bb8d6f7634f72fd70c53bf2ddf6 Mon Sep 17 00:00:00 2001 From: Aydin Hassan Date: Sun, 5 Mar 2017 09:54:08 +0100 Subject: [PATCH 4/4] Remove PSX references --- app/config.php | 4 ---- src/Factory/MarkdownCliRendererFactory.php | 1 - src/ResultRenderer/ResultsRenderer.php | 1 - test/ResultRenderer/AbstractResultRendererTest.php | 1 - test/ResultRenderer/ResultsRendererTest.php | 4 ---- 5 files changed, 11 deletions(-) diff --git a/app/config.php b/app/config.php index f2a3328f..0724abcf 100644 --- a/app/config.php +++ b/app/config.php @@ -56,9 +56,7 @@ use PhpSchool\PhpWorkshop\ResultRenderer\Cli\RequestFailureRenderer as CliRequestFailureRenderer; use PhpSchool\PhpWorkshop\ResultRenderer\Cgi\RequestFailureRenderer as CgiRequestFailureRenderer; use PhpSchool\PhpWorkshop\Utils\RequestRenderer; -use PhpSchool\PSX\Factory as PsxFactory; use PhpSchool\PhpWorkshop\WorkshopType; -use PhpSchool\PSX\SyntaxHighlighter; use PhpSchool\PhpWorkshop\Check\FileExistsCheck; use PhpSchool\PhpWorkshop\Check\FunctionRequirementsCheck; use PhpSchool\PhpWorkshop\Check\PhpLintCheck; @@ -280,8 +278,6 @@ UserState::class => function (ContainerInterface $c) { return $c->get(UserStateSerializer::class)->deSerialize(); }, - SyntaxHighlighter::class => factory(PsxFactory::class), - PsxFactory::class => object(), ResetProgress::class => function (ContainerInterface $c) { return new ResetProgress($c->get(UserStateSerializer::class)); }, diff --git a/src/Factory/MarkdownCliRendererFactory.php b/src/Factory/MarkdownCliRendererFactory.php index 40949984..a79225a8 100644 --- a/src/Factory/MarkdownCliRendererFactory.php +++ b/src/Factory/MarkdownCliRendererFactory.php @@ -21,7 +21,6 @@ use League\CommonMark\Inline\Element\Newline; use League\CommonMark\Inline\Element\Strong; use League\CommonMark\Inline\Element\Text; -use PhpSchool\PSX\Factory as PSXFactory; use AydinHassan\CliMdRenderer\Highlighter\PhpHighlighter; use AydinHassan\CliMdRenderer\InlineRenderer\CodeRenderer; use AydinHassan\CliMdRenderer\InlineRenderer\EmphasisRenderer; diff --git a/src/ResultRenderer/ResultsRenderer.php b/src/ResultRenderer/ResultsRenderer.php index c589fd29..5593d375 100644 --- a/src/ResultRenderer/ResultsRenderer.php +++ b/src/ResultRenderer/ResultsRenderer.php @@ -12,7 +12,6 @@ use PhpSchool\PhpWorkshop\Output\OutputInterface; use PhpSchool\PhpWorkshop\Result\ResultGroupInterface; use PhpSchool\PhpWorkshop\Result\SuccessInterface; -use PhpSchool\PSX\SyntaxHighlighter; use PhpSchool\PhpWorkshop\Exercise\ExerciseInterface; use PhpSchool\PhpWorkshop\ExerciseRepository; use PhpSchool\PhpWorkshop\Result\ResultInterface; diff --git a/test/ResultRenderer/AbstractResultRendererTest.php b/test/ResultRenderer/AbstractResultRendererTest.php index 724010cc..ac9ed905 100644 --- a/test/ResultRenderer/AbstractResultRendererTest.php +++ b/test/ResultRenderer/AbstractResultRendererTest.php @@ -6,7 +6,6 @@ use Kadet\Highlighter\KeyLighter; use PhpSchool\CliMenu\Terminal\TerminalInterface; use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory; -use PhpSchool\PSX\Factory; use PHPUnit\Framework\TestCase; use PhpSchool\PhpWorkshop\ExerciseRepository; use PhpSchool\PhpWorkshop\ResultRenderer\ResultsRenderer; diff --git a/test/ResultRenderer/ResultsRendererTest.php b/test/ResultRenderer/ResultsRendererTest.php index 82448d8f..945bf9d8 100644 --- a/test/ResultRenderer/ResultsRendererTest.php +++ b/test/ResultRenderer/ResultsRendererTest.php @@ -13,16 +13,12 @@ use PhpSchool\PhpWorkshop\Factory\ResultRendererFactory; use PhpSchool\PhpWorkshop\Output\StdOutput; use PhpSchool\PhpWorkshop\Result\Failure; -use PhpSchool\PhpWorkshop\Result\ResultInterface; use PhpSchool\PhpWorkshop\Result\Success; use PhpSchool\PhpWorkshop\ResultAggregator; use PhpSchool\PhpWorkshop\ResultRenderer\FailureRenderer; -use PhpSchool\PhpWorkshop\ResultRenderer\ResultRendererInterface; use PhpSchool\PhpWorkshop\ResultRenderer\ResultsRenderer; use PhpSchool\PhpWorkshop\Solution\SingleFileSolution; use PhpSchool\PhpWorkshop\UserState; -use PhpSchool\PSX\Factory; -use PhpSchool\PSX\SyntaxHighlighter; use PHPUnit_Framework_TestCase; use Prophecy\Argument;