Update dependencies, min PHP 7.2

This commit is contained in:
Stéphane Goetz 2019-11-28 22:36:26 +01:00
parent f62b2bec96
commit e04335abeb
18 changed files with 409 additions and 330 deletions

View File

@ -9,7 +9,7 @@ jobs:
matrix:
# TODO : enable tests on windows
operating-system: [ubuntu-latest, macOS-latest]
php-versions: ['7.1', '7.2', '7.3']
php-versions: ['7.2', '7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
@ -21,8 +21,7 @@ jobs:
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extension-csv: mbstring, xdebug
coverage: xdebug
extension-csv: mbstring
- name: Get Composer Cache Directory
id: composer-cache
@ -43,3 +42,25 @@ jobs:
- name: Run test suite
run: composer run-script test
sonarcloud:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.4
extension-csv: mbstring, xdebug
coverage: xdebug
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run test suite
run: composer run-script test -- --coverage-clover=coverage.clover
- run: wget https://scrutinizer-ci.com/ocular.phar
- name: Upload code coverage
run: php ocular.phar code-coverage:upload --format=php-clover coverage.clover

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ node_modules
static
/vendor
.phpunit.result.cache
/prettier.config.js
/.eslintrc.js

View File

@ -1,9 +1,7 @@
language: php
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- nightly
matrix:
@ -11,27 +9,7 @@ matrix:
- php: nightly
before_script:
- composer install --dev --prefer-source
- composer install --prefer-dist --no-progress --no-suggest
script:
- vendor/bin/phpunit --coverage-clover=coverage.clover
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
jobs:
include:
- stage: "Deploy Documentation"
php: "7.3"
script: skip
before_deploy:
- composer install
- bin/daux generate
deploy:
provider: pages
local_dir: static
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
on:
branch: master
- vendor/bin/phpunit

View File

@ -234,7 +234,7 @@ You can then point your browser to http://localhost:8086
## PHP Requirements
Daux.io is compatible with PHP 7.1.3 and up.
Daux.io is compatible with PHP 7.2.0 and up.
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.

View File

@ -17,18 +17,19 @@
],
"bin": ["bin/daux"],
"require": {
"php": ">=7.1.3",
"php": ">=7.2",
"guzzlehttp/guzzle": "~6.0",
"league/commonmark": "^0.18",
"league/commonmark": "^1.0.0",
"league/commonmark-ext-table": "^2.0.0",
"league/plates": "~3.1",
"myclabs/deep-copy": "^1.5",
"symfony/console": "^4.0",
"symfony/http-foundation": "^4.0",
"symfony/console": "^5.0",
"symfony/http-foundation": "^5.0",
"symfony/polyfill-intl-icu": "^1.10",
"symfony/process": "^4.0",
"webuni/commonmark-table-extension": "0.9.*",
"symfony/process": "^5.0",
"webuni/front-matter": "^1.0.0",
"scrivo/highlight.php": "^9.15"
"scrivo/highlight.php": "^9.15",
"symfony/mime": "^5.0"
},
"suggest":{
"ext-intl": "Allows to translate the modified at date"
@ -42,7 +43,7 @@
"justinwalsh/daux.io": "*"
},
"require-dev": {
"phpunit/phpunit": "~7.4",
"phpunit/phpunit": "^8.0",
"mikey179/vfsstream": "^1.6"
},
"scripts": {

530
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -145,7 +145,7 @@ Now that you got the basics, you can also [see what you can configure](05_Config
## PHP Requirements
Daux.io is compatible with PHP 7.1.3 and up.
Daux.io is compatible with PHP 7.2.0 and up.
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.

View File

@ -3,8 +3,9 @@
use League\CommonMark\DocParser;
use League\CommonMark\Environment;
use League\CommonMark\HtmlRenderer;
use League\CommonMark\Ext\Table\TableExtension;
use League\CommonMark\Inline\Element as InlineElement;
use Todaymade\Daux\Config;
use Webuni\CommonMark\TableExtension\TableExtension;
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
{
@ -39,6 +40,6 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
protected function extendEnvironment(Environment $environment, Config $config)
{
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
$environment->addInlineRenderer(InlineElement\Link::class, $this->getLinkRenderer($environment));
}
}

View File

@ -4,12 +4,15 @@ use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Link;
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
use League\CommonMark\Util\ConfigurationAwareInterface;
use League\CommonMark\Util\ConfigurationInterface;
use Todaymade\Daux\Config;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Exception\LinkNotFoundException;
use Todaymade\Daux\Tree\Entry;
class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterface
{
/**
* @var Config
@ -66,6 +69,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
protected function isExternalUrl($url)
{
return preg_match('#^(?:[a-z]+:)?//|^mailto:#', $url);
$this->parent = new \League\CommonMark\Inline\Renderer\LinkRenderer();
}
/**
@ -87,7 +91,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
);
}
$element = parent::render($inline, $htmlRenderer);
$element = $this->parent->render($inline, $htmlRenderer);
$url = $inline->getUrl();
@ -116,7 +120,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
} catch (LinkNotFoundException $e) {
// For some reason, the filename could contain a # and thus the link needs to resolve to that.
try {
@ -148,4 +152,13 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
return $element;
}
/**
* @param ConfigurationInterface $configuration
*/
public function setConfiguration(ConfigurationInterface $configuration)
{
$this->config = $configuration;
$this->parent->setConfiguration($configuration);
}
}

View File

@ -12,17 +12,7 @@ class TableOfContents extends AbstractBlock
*
* @return bool
*/
public function canContain(AbstractBlock $block)
{
return false;
}
/**
* Returns true if block type can accept lines of text
*
* @return bool
*/
public function acceptsLines()
public function canContain(AbstractBlock $block): bool
{
return false;
}
@ -32,7 +22,7 @@ class TableOfContents extends AbstractBlock
*
* @return bool
*/
public function isCode()
public function isCode(): bool
{
return false;
}
@ -42,7 +32,7 @@ class TableOfContents extends AbstractBlock
*
* @return bool
*/
public function matchesNextLine(Cursor $cursor)
public function matchesNextLine(Cursor $cursor): bool
{
return false;
}

View File

@ -1,10 +1,10 @@
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
use League\CommonMark\Block\Parser\AbstractBlockParser;
use League\CommonMark\Block\Parser\BlockParserInterface;
use League\CommonMark\ContextInterface;
use League\CommonMark\Cursor;
class TableOfContentsParser extends AbstractBlockParser
class TableOfContentsParser implements BlockParserInterface
{
/**
* @param ContextInterface $context
@ -12,7 +12,7 @@ class TableOfContentsParser extends AbstractBlockParser
*
* @return bool
*/
public function parse(ContextInterface $context, Cursor $cursor)
public function parse(ContextInterface $context, Cursor $cursor): bool
{
if ($cursor->isIndented()) {
return false;

View File

@ -1,7 +1,10 @@
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
use League\CommonMark\Environment;
use League\CommonMark\Block\Element as BlockElement;
use League\CommonMark\Inline\Element as InlineElement;
use Todaymade\Daux\Config;
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
{
@ -14,12 +17,12 @@ class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMa
{
parent::extendEnvironment($environment, $config);
$environment->addBlockRenderer('Todaymade\Daux\ContentTypes\Markdown\TableOfContents', new TOCRenderer());
$environment->addBlockRenderer(TableOfContents::class, new TOCRenderer());
//Add code renderer
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
$environment->addBlockRenderer('IndentedCode', new IndentedCodeRenderer());
$environment->addBlockRenderer(BlockElement\FencedCode::class, new FencedCodeRenderer());
$environment->addBlockRenderer(BlockElement\IndentedCode::class, new IndentedCodeRenderer());
$environment->addInlineRenderer('Image', new ImageRenderer());
$environment->addInlineRenderer(InlineElement\Image::class, new ImageRenderer());
}
}

View File

@ -4,9 +4,20 @@ use League\CommonMark\ElementRendererInterface;
use League\CommonMark\HtmlElement;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Image;
use League\CommonMark\Util\ConfigurationAwareInterface;
use League\CommonMark\Util\ConfigurationInterface;
class ImageRenderer extends \League\CommonMark\Inline\Renderer\ImageRenderer
class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterface
{
/**
* @var ConfigurationInterface
*/
protected $config;
public function __construct() {
$this->parent = new \League\CommonMark\Inline\Renderer\ImageRenderer();
}
/**
* @param Image $inline
* @param ElementRendererInterface $htmlRenderer
@ -30,4 +41,13 @@ class ImageRenderer extends \League\CommonMark\Inline\Renderer\ImageRenderer
return parent::render($inline, $htmlRenderer);
}
/**
* @param ConfigurationInterface $configuration
*/
public function setConfiguration(ConfigurationInterface $configuration)
{
$this->config = $configuration;
$this->parent->setConfiguration($configuration);
}
}

View File

@ -1,7 +1,10 @@
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
use League\CommonMark\Environment;
use League\CommonMark\Block\Element as BlockElement;
use League\CommonMark\Event\DocumentParsedEvent;
use Todaymade\Daux\Config;
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
{
@ -9,9 +12,10 @@ class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMa
{
parent::extendEnvironment($environment, $config);
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
$environment->addBlockRenderer(BlockElement\FencedCode::class, new FencedCodeRenderer());
$environment->addDocumentProcessor(new TOC\Processor($config));
$environment->addBlockRenderer('Todaymade\Daux\ContentTypes\Markdown\TableOfContents', new TOC\Renderer($config));
$processor = new TOC\Processor($config);
$environment->addEventListener(DocumentParsedEvent::class, [$processor, 'onDocumentParsed']);
$environment->addBlockRenderer(TableOfContents::class, new TOC\Renderer($config));
}
}

View File

@ -7,7 +7,7 @@ use League\CommonMark\Block\Element\ListBlock;
use League\CommonMark\Block\Element\ListData;
use League\CommonMark\Block\Element\ListItem;
use League\CommonMark\Block\Element\Paragraph;
use League\CommonMark\DocumentProcessorInterface;
use League\CommonMark\Event\DocumentParsedEvent;
use League\CommonMark\Inline\Element\Link;
use League\CommonMark\Inline\Element\Text;
use League\CommonMark\Node\Node;
@ -15,7 +15,7 @@ use ReflectionMethod;
use Todaymade\Daux\Config;
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
class Processor implements DocumentProcessorInterface
class Processor
{
protected $config;
@ -30,12 +30,13 @@ class Processor implements DocumentProcessorInterface
}
/**
* @param Document $document
* @param DocumentParsedEvent $event
*
* @return void
*/
public function processDocument(Document $document)
public function onDocumentParsed(DocumentParsedEvent $event)
{
$document = $event->getDocument();
/** @var TableOfContents[] $tocs */
$tocs = [];

View File

@ -1,29 +1,12 @@
<?php namespace Todaymade\Daux\Server;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as FileMimeTypeGuesserInterface;
use Symfony\Component\Mime\MimeTypeGuesserInterface;
/**
* Guesses the mime type using the file's extension
*/
class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeTypeGuesserInterface
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
{
/**
* {@inheritdoc}
*/
public function guess($path)
{
$extension = pathinfo($path,PATHINFO_EXTENSION);
if ($extension == "css") {
return "text/css";
}
if ($extension == "js") {
return "application/javascript";
}
}
/**
* {@inheritdoc}
*/
@ -37,6 +20,14 @@ class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeType
*/
public function guessMimeType(string $path): ?string
{
return $this->guess($path);
$extension = pathinfo($path,PATHINFO_EXTENSION);
if ($extension == "css") {
return "text/css";
}
if ($extension == "js") {
return "application/javascript";
}
}
}

View File

@ -97,7 +97,8 @@ class Server
* @return Response
*/
public function createResponse(Page $page) {
// Add a custom MimeType guesser in case the default ones are not available
// This makes sure that at least CSS and JS work fine.
$mimeTypes = MimeTypes::getDefault();
$mimeTypes->registerGuesser(new ExtensionMimeTypeGuesser());

View File

@ -14,7 +14,7 @@ class BuilderIntegrationTest extends TestCase
*/
private $root;
public function setUp()
public function setUp(): void
{
$structure = [
'Contents' => [