Skip to content

Commit

Permalink
Merge pull request #17 from ARCANEDEV/update-laravel_7.x
Browse files Browse the repository at this point in the history
Update the package to support Laravel 7
  • Loading branch information
arcanedev-maroc committed Mar 5, 2020
2 parents 11d24e8 + 12771f9 commit 234961e
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 65 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: run-tests

on: [push]
on: [push, pull_request]

jobs:
tests:
Expand All @@ -10,7 +10,6 @@ jobs:
fail-fast: true
matrix:
php: [7.2, 7.3, 7.4]
laravel: [6.*]
dependency-version: [prefer-lowest, prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
Expand All @@ -23,10 +22,10 @@ jobs:
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
key: dependencies-laravel-7.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016-2019 | ARCANEDEV <arcanedev.maroc@gmail.com> - LaravelMarkdown
Copyright (c) 2016-2020 | ARCANEDEV <arcanedev.maroc@gmail.com> - LaravelMarkdown

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelMarkdo

### Features

* Laravel `5.1` to `6.x` are supported.
* Laravel `5.1` to `7.x` are supported.
* Easy setup & configuration.
* Well tested (100% code coverage with maximum code quality).
* Made with :heart: &amp; :coffee:.
Expand All @@ -43,7 +43,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.
- [All Contributors][link-contributors]

[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-markdown.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%206.x-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.1%20to%207.x-orange.svg?style=flat-square
[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/LaravelMarkdown/run-tests?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelMarkdown.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/LaravelMarkdown.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion _docs/0-Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelMarkdo

### Features

* Laravel `5.1` to `6.x` are Supported.
* Laravel `5.1` to `7.x` are Supported.
* Easy setup & configuration.
* Well tested (100% code coverage with maximum code quality).
* Made with :heart: &amp; :coffee:.
Expand Down
47 changes: 25 additions & 22 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,36 @@

| Laravel Markdown | Laravel |
|:----------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------|
| ![Laravel Markdown v1.1.x][laravel_markdown_1_1_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] |
| ![Laravel Markdown v1.2.x][laravel_markdown_1_2_x] | ![Laravel v5.4][laravel_5_4] |
| ![Laravel Markdown v1.3.x][laravel_markdown_1_3_x] | ![Laravel v5.5][laravel_5_5] |
| ![Laravel Markdown v1.4.x][laravel_markdown_1_4_x] | ![Laravel v5.6][laravel_5_6] |
| ![Laravel Markdown v1.5.x][laravel_markdown_1_5_x] | ![Laravel v5.7][laravel_5_7] |
| ![Laravel Markdown v1.6.x][laravel_markdown_1_6_x] | ![Laravel v5.8][laravel_5_8] |
| ![Laravel Markdown v4.x][laravel_markdown_4_x] | ![Laravel v7.x][laravel_7_x] |
| ![Laravel Markdown v2.x][laravel_markdown_2_x] ![Laravel Markdown v3.x][laravel_markdown_3_x] | ![Laravel v6.x][laravel_6_x] |
| ![Laravel Markdown v1.6.x][laravel_markdown_1_6_x] | ![Laravel v5.8][laravel_5_8] |
| ![Laravel Markdown v1.5.x][laravel_markdown_1_5_x] | ![Laravel v5.7][laravel_5_7] |
| ![Laravel Markdown v1.4.x][laravel_markdown_1_4_x] | ![Laravel v5.6][laravel_5_6] |
| ![Laravel Markdown v1.3.x][laravel_markdown_1_3_x] | ![Laravel v5.5][laravel_5_5] |
| ![Laravel Markdown v1.2.x][laravel_markdown_1_2_x] | ![Laravel v5.4][laravel_5_4] |
| ![Laravel Markdown v1.1.x][laravel_markdown_1_1_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] |

[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"
[laravel_7_x]: https://img.shields.io/badge/v7.x-supported-brightgreen.svg?style=flat-square "Laravel v7.x"
[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x"
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"

[laravel_markdown_1_1_x]: https://img.shields.io/badge/version-1.1.x-blue.svg?style=flat-square "Laravel Markdown v1.1.x"
[laravel_markdown_1_2_x]: https://img.shields.io/badge/version-1.2.x-blue.svg?style=flat-square "Laravel Markdown v1.2.x"
[laravel_markdown_1_3_x]: https://img.shields.io/badge/version-1.3.x-blue.svg?style=flat-square "Laravel Markdown v1.3.x"
[laravel_markdown_1_4_x]: https://img.shields.io/badge/version-1.4.x-blue.svg?style=flat-square "Laravel Markdown v1.4.x"
[laravel_markdown_1_5_x]: https://img.shields.io/badge/version-1.5.x-blue.svg?style=flat-square "Laravel Markdown v1.5.x"
[laravel_markdown_1_6_x]: https://img.shields.io/badge/version-1.6.x-blue.svg?style=flat-square "Laravel Markdown v1.6.x"
[laravel_markdown_2_x]: https://img.shields.io/badge/version-2.x-blue.svg?style=flat-square "Laravel Markdown v2.x"
[laravel_markdown_4_x]: https://img.shields.io/badge/version-4.x-blue.svg?style=flat-square "Laravel Markdown v4.x"
[laravel_markdown_3_x]: https://img.shields.io/badge/version-3.x-blue.svg?style=flat-square "Laravel Markdown v3.x"
[laravel_markdown_2_x]: https://img.shields.io/badge/version-2.x-blue.svg?style=flat-square "Laravel Markdown v2.x"
[laravel_markdown_1_6_x]: https://img.shields.io/badge/version-1.6.x-blue.svg?style=flat-square "Laravel Markdown v1.6.x"
[laravel_markdown_1_5_x]: https://img.shields.io/badge/version-1.5.x-blue.svg?style=flat-square "Laravel Markdown v1.5.x"
[laravel_markdown_1_4_x]: https://img.shields.io/badge/version-1.4.x-blue.svg?style=flat-square "Laravel Markdown v1.4.x"
[laravel_markdown_1_3_x]: https://img.shields.io/badge/version-1.3.x-blue.svg?style=flat-square "Laravel Markdown v1.3.x"
[laravel_markdown_1_2_x]: https://img.shields.io/badge/version-1.2.x-blue.svg?style=flat-square "Laravel Markdown v1.2.x"
[laravel_markdown_1_1_x]: https://img.shields.io/badge/version-1.1.x-blue.svg?style=flat-square "Laravel Markdown v1.1.x"

## Composer

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=7.2.0",
"arcanedev/support": "^5.1",
"league/commonmark": "^1.2",
"league/commonmark-ext-table": "^2.1"
"php": "^7.2.5",
"arcanedev/support": "^7.0",
"league/commonmark": "^1.3"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.0",
"phpunit/phpcov": "^6.0"
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^8.5|^9.0"
},
"autoload": {
"psr-4": {
Expand All @@ -42,5 +40,7 @@
"Arcanedev\\LaravelMarkdown\\Providers\\DeferredServicesProvider"
]
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 0 additions & 2 deletions src/Contracts/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Arcanedev\LaravelMarkdown\Contracts;

use Illuminate\Support\HtmlString;

/**
* Interface Markdown
*
Expand Down
21 changes: 19 additions & 2 deletions src/Exceptions/ParserBufferingException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
<?php namespace Arcanedev\LaravelMarkdown\Exceptions;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMarkdown\Exceptions;

use Exception;

/**
* Class ParserBufferingException
*
* @package Arcanedev\LaravelMarkdown\Exceptions
* @author ARCANEDEV <arcanedev.maroc@gmail.com>
*/
class ParserBufferingException extends \Exception {}
class ParserBufferingException extends Exception
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

public static function notStarted(): self
{
return new static('Markdown buffering have not been started.');
}
}
2 changes: 1 addition & 1 deletion src/Parsers/AbstractParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function begin(): void
public function end(): HtmlString
{
if ($this->buffering === false) {
throw new ParserBufferingException('Markdown buffering have not been started.');
throw ParserBufferingException::notStarted();
}

$markdown = ob_get_clean();
Expand Down
4 changes: 2 additions & 2 deletions src/Parsers/CommonMarkParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\HtmlString;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Ext\Table\TableExtension;
use League\CommonMark\Extension\Table\TableExtension;

/**
* Class CommonMarkParser
Expand All @@ -31,7 +31,7 @@ class CommonMarkParser extends AbstractParser
*/
public function parse(string $text): HtmlString
{
$environment = tap(Environment::createCommonMarkEnvironment())
$environment = Environment::createCommonMarkEnvironment()
->addExtension(new TableExtension);

$converter = new CommonMarkConverter([
Expand Down
6 changes: 5 additions & 1 deletion src/Providers/DeferredServicesProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMarkdown\Providers;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMarkdown\Providers;

use Arcanedev\LaravelMarkdown\Contracts\Markdown as MarkdownContract;
use Arcanedev\LaravelMarkdown\Contracts\Parser;
Expand Down
12 changes: 8 additions & 4 deletions tests/LaravelMarkdownServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMarkdown\Tests;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMarkdown\Tests;

use Arcanedev\LaravelMarkdown\LaravelMarkdownServiceProvider;

Expand Down Expand Up @@ -43,13 +47,13 @@ public function tearDown(): void
*/

/** @test */
public function it_can_be_instantiated()
public function it_can_be_instantiated(): void
{
$expectations = [
\Illuminate\Support\ServiceProvider::class,
\Arcanedev\Support\Providers\ServiceProvider::class,
\Arcanedev\Support\Providers\PackageServiceProvider::class,
\Arcanedev\LaravelMarkdown\LaravelMarkdownServiceProvider::class,
LaravelMarkdownServiceProvider::class,
];

foreach ($expectations as $expected) {
Expand All @@ -58,7 +62,7 @@ public function it_can_be_instantiated()
}

/** @test */
public function it_can_provides()
public function it_can_provides(): void
{
$expected = [];

Expand Down
20 changes: 9 additions & 11 deletions tests/MarkdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Arcanedev\LaravelMarkdown\Tests;

use Arcanedev\LaravelMarkdown\Parsers\AbstractParser;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Manager;

/**
* Class MarkdownParserTest
Expand All @@ -22,7 +20,7 @@ class MarkdownTest extends TestCase
*/

/** @test */
public function it_can_be_instantiated()
public function it_can_be_instantiated(): void
{
$markdown = $this->markdown();

Expand All @@ -38,7 +36,7 @@ public function it_can_be_instantiated()
}

/** @test */
public function it_can_get_parser()
public function it_can_get_parser(): void
{
$parser = $this->markdown()->parser();

Expand All @@ -54,7 +52,7 @@ public function it_can_get_parser()
}

/** @test */
public function it_can_parse_markdown_into_html()
public function it_can_parse_markdown_into_html(): void
{
$parsed = $this->markdown()->parse('# Hello');

Expand All @@ -63,7 +61,7 @@ public function it_can_parse_markdown_into_html()
}

/** @test */
public function it_parse_a_block_of_markdown_into_html()
public function it_parse_a_block_of_markdown_into_html(): void
{
$md = $this->markdown();

Expand All @@ -79,7 +77,7 @@ public function it_parse_a_block_of_markdown_into_html()
}

/** @test */
public function it_can_parse_via_blade_directive()
public function it_can_parse_via_blade_directive(): void
{
/** @var \Illuminate\Contracts\View\Factory $view */
$view = $this->app['view'];
Expand All @@ -95,7 +93,7 @@ public function it_can_parse_via_blade_directive()
}

/** @test */
public function it_can_clean_xss()
public function it_can_clean_xss(): void
{
static::assertStringContainsString(
'<p><a>Link</a></p>',
Expand All @@ -117,7 +115,7 @@ public function it_can_clean_xss()
);
}

public function it_can_skip_clean_xss()
public function it_can_skip_clean_xss(): void
{
$this->app['config']->set('markdown.parser.options.allow_unsafe_links', true);

Expand All @@ -128,7 +126,7 @@ public function it_can_skip_clean_xss()
}

/** @test */
public function it_can_skip_escape_markups()
public function it_can_skip_escape_markups(): void
{
$this->app['config']->set('markdown.parser.options.html_input', false);

Expand All @@ -139,7 +137,7 @@ public function it_can_skip_escape_markups()
}

/** @test */
public function it_must_throw_an_exception_when_the_buffering_is_not_started()
public function it_must_throw_an_exception_when_the_buffering_is_not_started(): void
{
$this->expectException(\Arcanedev\LaravelMarkdown\Exceptions\ParserBufferingException::class);
$this->expectExceptionMessage('Markdown buffering have not been started.');
Expand Down
10 changes: 7 additions & 3 deletions tests/Providers/DeferredServiceProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMarkdown\Tests\Providers;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMarkdown\Tests\Providers;

use Arcanedev\LaravelMarkdown\Providers\DeferredServicesProvider;
use Arcanedev\LaravelMarkdown\Tests\TestCase;
Expand Down Expand Up @@ -44,7 +48,7 @@ public function tearDown(): void
*/

/** @test */
public function it_can_be_instantiated()
public function it_can_be_instantiated(): void
{
$expectations = [
\Illuminate\Support\ServiceProvider::class,
Expand All @@ -58,7 +62,7 @@ public function it_can_be_instantiated()
}

/** @test */
public function it_can_provides()
public function it_can_provides(): void
{
$expected = [
\Arcanedev\LaravelMarkdown\Contracts\Markdown::class,
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Arcanedev\LaravelMarkdown\Tests;
<?php

declare(strict_types=1);

namespace Arcanedev\LaravelMarkdown\Tests;

use Orchestra\Testbench\TestCase as BaseTestCase;

Expand Down

0 comments on commit 234961e

Please sign in to comment.