From f1a7abf1e5dccdc8cc89897c559d1f85bc87832e Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:22:58 -0500 Subject: [PATCH 1/8] add github actions --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ composer.json | 17 ++++++++++++++++- test/phpstan.neon | 2 ++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 test/phpstan.neon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8ae9f41 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI +on: + pull_request: null + push: + branches: + - master +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.3', '7.4', '8.0'] + + name: Linting - PHP ${{ matrix.php }} + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + extensions: intl + - run: composer install --no-progress + - run: composer codestyle + - run: composer phpstan + - run: composer tests diff --git a/composer.json b/composer.json index 9990ce1..ab00995 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,21 @@ "psr-4": { "Michelf\\": "Michelf/" } }, "require-dev": { - "phpunit/phpunit": ">= 9.5" + "phpspec/prophecy": "^1.6", + "friendsofphp/php-cs-fixer": "^3.0", + "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-phpunit": "^1.0" + }, + + "scripts": { + "tests": "vendor/bin/phpunit test/", + "phpstan": [ + "vendor/bin/phpstan analyse Michelf/ --level=5", + "vendor/bin/phpstan analyse -c test/phpstan.neon test/ --level=5" + ], + "codestyle": "vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none", + "codestyle-fix": "vendor/bin/php-cs-fixer fix" } + } diff --git a/test/phpstan.neon b/test/phpstan.neon new file mode 100644 index 0000000..e385cc8 --- /dev/null +++ b/test/phpstan.neon @@ -0,0 +1,2 @@ +includes: + - ../vendor/phpstan/phpstan-phpunit/extension.neon From 7605be8059f0da6faf369214502d8953a5b77a3b Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:31:52 -0500 Subject: [PATCH 2/8] add more ci --- .github/workflows/ci.yml | 2 +- Readme.md | 2 ++ composer.json | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ae9f41..d53892d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ on: pull_request: null push: branches: - - master + - lib jobs: tests: runs-on: ubuntu-latest diff --git a/Readme.md b/Readme.md index e1eb306..904e254 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,8 @@ PHP Markdown ============ +![ci.yml](https://github.com/tacman/php-markdown/actions/workflows/ci.yml/badge.svg) + PHP Markdown Lib 1.9.0 - 1 Dec 2019 by Michel Fortin diff --git a/composer.json b/composer.json index ab00995..dd7b42d 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ "vendor/bin/phpstan analyse Michelf/ --level=5", "vendor/bin/phpstan analyse -c test/phpstan.neon test/ --level=5" ], - "codestyle": "vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none", - "codestyle-fix": "vendor/bin/php-cs-fixer fix" + "codestyle": "vendor/bin/php-cs-fixer fix Michelf --dry-run --verbose --show-progress=none", + "codestyle-fix": "vendor/bin/php-cs-fixer fix Michelf" } } From 050e6e6751036367c30fe3c37d1686d40eab1741 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:33:10 -0500 Subject: [PATCH 3/8] drop 7.3 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d53892d..ebbc7ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: ['7.3', '7.4', '8.0'] + php: ['7.4', '8.0'] name: Linting - PHP ${{ matrix.php }} steps: From d0dc7afcfe4f4923d0978a4ce72b26efa630ca63 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:34:13 -0500 Subject: [PATCH 4/8] drop codestyle check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebbc7ba..6e49b83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,6 @@ jobs: coverage: none extensions: intl - run: composer install --no-progress - - run: composer codestyle +# - run: composer codestyle - run: composer phpstan - run: composer tests From fd531bd53e6c6832c49111ceead5a74432e1031a Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:39:21 -0500 Subject: [PATCH 5/8] replace hard-coded links to badges --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 904e254..4370613 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,7 @@ PHP Markdown ============ -![ci.yml](https://github.com/tacman/php-markdown/actions/workflows/ci.yml/badge.svg) +![ci.yml](https://github.com///actions/workflows/ci.yml/badge.svg) PHP Markdown Lib 1.9.0 - 1 Dec 2019 From 284ee15c8f76a8483205577ff25fdd367f0775ed Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:47:27 -0500 Subject: [PATCH 6/8] always exists, no need to check for isset() --- Michelf/Markdown.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index b1ebee1..8ab24d2 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -765,7 +765,7 @@ class Markdown implements MarkdownInterface { $url = $this->encodeURLAttribute($url); $result = "encodeAttribute($title); $result .= " title=\"$title\""; } From ea3e24f85650148ddba43d9bd75f2bb3c3d86067 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:48:06 -0500 Subject: [PATCH 7/8] remove badge link --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 4370613..904e254 100644 --- a/Readme.md +++ b/Readme.md @@ -1,7 +1,7 @@ PHP Markdown ============ -![ci.yml](https://github.com///actions/workflows/ci.yml/badge.svg) +![ci.yml](https://github.com/tacman/php-markdown/actions/workflows/ci.yml/badge.svg) PHP Markdown Lib 1.9.0 - 1 Dec 2019 From e60f9373a391243314db0be974d890199bc31072 Mon Sep 17 00:00:00 2001 From: Tac Tacelosky Date: Mon, 8 Nov 2021 07:52:44 -0500 Subject: [PATCH 8/8] fix some errors reported by phpstan --- Michelf/Markdown.php | 6 +++--- Michelf/MarkdownExtra.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index 8ab24d2..e7a5976 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -708,7 +708,7 @@ class Markdown implements MarkdownInterface { /** * Callback method to parse referenced anchors - * @param string $matches + * @param array $matches * @return string */ protected function _doAnchors_reference_callback($matches) { @@ -747,7 +747,7 @@ class Markdown implements MarkdownInterface { /** * Callback method to parse inline anchors - * @param string $matches + * @param array $matches * @return string */ protected function _doAnchors_inline_callback($matches) { @@ -1808,7 +1808,7 @@ class Markdown implements MarkdownInterface { /** * String length function for detab. `_initDetab` will create a function to * handle UTF-8 if the default function does not exist. - * @var string + * can be a string or function */ protected $utf8_strlen = 'mb_strlen'; diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index 8485c5c..060a4ae 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -1222,6 +1222,7 @@ class MarkdownExtra extends \Michelf\Markdown { $head = $matches[1]; $underline = $matches[2]; $content = $matches[3]; + $attr = []; // Remove any tailing pipes for each line. $head = preg_replace('/[|] *$/m', '', $head);