From f9367787ea5bc86997a134f0ea9c20286ea01614 Mon Sep 17 00:00:00 2001 From: davidbyoung Date: Mon, 23 Sep 2024 17:53:46 +0530 Subject: [PATCH 1/2] Fixed PHP 8.4 deprecations --- src/Components/Blocks/Abbreviation.php | 2 +- src/Components/Blocks/DefinitionList.php | 4 ++-- src/Components/Blocks/Footnote.php | 2 +- src/Components/Blocks/Header.php | 2 +- src/Components/Blocks/SetextHeader.php | 2 +- src/Components/Inlines/Footnote.php | 2 +- src/Features/Abbreviations.php | 2 +- src/Features/CustomAttributes.php | 2 +- src/Features/Definitions.php | 2 +- src/Features/Footnotes.php | 2 +- src/ParsedownExtra.php | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Components/Blocks/Abbreviation.php b/src/Components/Blocks/Abbreviation.php index 3bf1965..d695ca9 100644 --- a/src/Components/Blocks/Abbreviation.php +++ b/src/Components/Blocks/Abbreviation.php @@ -28,7 +28,7 @@ private function __construct(State $State) public static function build( Context $Context, State $State, - Block $Block = null + ?Block $Block = null ) { if (\preg_match( '/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', diff --git a/src/Components/Blocks/DefinitionList.php b/src/Components/Blocks/DefinitionList.php index b6e6e7c..53b7166 100644 --- a/src/Components/Blocks/DefinitionList.php +++ b/src/Components/Blocks/DefinitionList.php @@ -51,8 +51,8 @@ private function __construct(Paragraph $StartingBlock, $Lis, $isLoose, $required */ public static function build( Context $Context, - State $State = null, - Block $Block = null + ?State $State = null, + ?Block $Block = null ) { if (! isset($Block) || ! $Block instanceof Paragraph || $Context->precedingEmptyLines() > 1) { return null; diff --git a/src/Components/Blocks/Footnote.php b/src/Components/Blocks/Footnote.php index 3bc21d3..289c146 100644 --- a/src/Components/Blocks/Footnote.php +++ b/src/Components/Blocks/Footnote.php @@ -39,7 +39,7 @@ private function __construct(State $State, string $title, Lines $Lines) public static function build( Context $Context, State $State, - Block $Block = null + ?Block $Block = null ) { if (\preg_match( '/^\[\^(.+?)\]:(.*+)$/', diff --git a/src/Components/Blocks/Header.php b/src/Components/Blocks/Header.php index cacc629..6c35f08 100644 --- a/src/Components/Blocks/Header.php +++ b/src/Components/Blocks/Header.php @@ -51,7 +51,7 @@ private function __construct($text, $level, $id, $classes) public static function build( Context $Context, State $State, - Block $Block = null + ?Block $Block = null ) { $BaseHeader = BaseHeader::build($Context, $State, $Block); diff --git a/src/Components/Blocks/SetextHeader.php b/src/Components/Blocks/SetextHeader.php index 1ef77ed..b547dab 100644 --- a/src/Components/Blocks/SetextHeader.php +++ b/src/Components/Blocks/SetextHeader.php @@ -52,7 +52,7 @@ private function __construct($text, $level, $id, $classes) public static function build( Context $Context, State $State, - Block $Block = null + ?Block $Block = null ) { $BaseHeader = BaseSetextHeader::build($Context, $State, $Block); diff --git a/src/Components/Inlines/Footnote.php b/src/Components/Inlines/Footnote.php index 1878334..fd99653 100644 --- a/src/Components/Inlines/Footnote.php +++ b/src/Components/Inlines/Footnote.php @@ -36,7 +36,7 @@ public function __construct(string $title, int $number, int $count) * @param State $State * @return static|null */ - public static function build(Excerpt $Excerpt, State $State = null) + public static function build(Excerpt $Excerpt, ?State $State = null) { $State = $State ?: new State; diff --git a/src/Features/Abbreviations.php b/src/Features/Abbreviations.php index b92a417..5eec874 100644 --- a/src/Features/Abbreviations.php +++ b/src/Features/Abbreviations.php @@ -18,7 +18,7 @@ final class Abbreviations implements StateBearer /** @var State */ private $State; - public function __construct(StateBearer $StateBearer = null) + public function __construct(?StateBearer $StateBearer = null) { $State = ($StateBearer ?? new State)->state(); diff --git a/src/Features/CustomAttributes.php b/src/Features/CustomAttributes.php index 32f6cce..2b3a4a0 100644 --- a/src/Features/CustomAttributes.php +++ b/src/Features/CustomAttributes.php @@ -30,7 +30,7 @@ final class CustomAttributes implements StateBearer /** @var State */ private $State; - public function __construct(StateBearer $StateBearer = null) + public function __construct(?StateBearer $StateBearer = null) { $State = ($StateBearer ?? new State)->state(); diff --git a/src/Features/Definitions.php b/src/Features/Definitions.php index ef249fa..e093155 100644 --- a/src/Features/Definitions.php +++ b/src/Features/Definitions.php @@ -12,7 +12,7 @@ final class Definitions implements StateBearer /** @var State */ private $State; - public function __construct(StateBearer $StateBearer = null) + public function __construct(?StateBearer $StateBearer = null) { $State = ($StateBearer ?? new State)->state(); diff --git a/src/Features/Footnotes.php b/src/Features/Footnotes.php index 8d3b1d0..2b94d45 100644 --- a/src/Features/Footnotes.php +++ b/src/Features/Footnotes.php @@ -22,7 +22,7 @@ final class Footnotes implements StateBearer /** @var State */ private $State; - public function __construct(StateBearer $StateBearer = null) + public function __construct(?StateBearer $StateBearer = null) { $State = ($StateBearer ?? new State)->state(); diff --git a/src/ParsedownExtra.php b/src/ParsedownExtra.php index 84addfc..94d3592 100644 --- a/src/ParsedownExtra.php +++ b/src/ParsedownExtra.php @@ -14,7 +14,7 @@ final class ParsedownExtra implements StateBearer /** @var State */ private $State; - public function __construct(StateBearer $StateBearer = null) + public function __construct(?StateBearer $StateBearer = null) { $StateBearer = Abbreviations::from($StateBearer ?? new State); $StateBearer = Definitions::from($StateBearer); From d9ea0b4a6456f973b7527e35071cc21f24b3e0f9 Mon Sep 17 00:00:00 2001 From: davidbyoung Date: Sun, 29 Sep 2024 09:14:58 -0500 Subject: [PATCH 2/2] Cleaned up composer.json, updated dependencies, added PHP 8.3 and 8.2 support to CI --- .github/workflows/ci.yml | 8 ++++---- .php-cs-fixer.dist.php | 5 +---- composer.json | 26 ++++++++++++++++---------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bd0c8d..2b35399 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.1, 8.0, 7.4, 7.3, 7.2, 7.1] + php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1] runs-on: ${{ matrix.os }} steps: @@ -29,7 +29,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.1] + php: [8.3] runs-on: ${{ matrix.os }} steps: @@ -50,7 +50,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.1] + php: [8.3] runs-on: ${{ matrix.os }} steps: @@ -74,7 +74,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.1] + php: [8.3] runs-on: ${{ matrix.os }} steps: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index cbd0b85..641953f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -10,9 +10,7 @@ 'array_syntax' => [ 'syntax' => 'short', ], - 'braces' => [ - 'allow_single_line_closure' => true, - ], + 'blank_lines_before_namespace' => true, 'logical_operators' => true, 'native_constant_invocation' => [ 'fix_built_in' => true, @@ -24,7 +22,6 @@ 'ordered_imports' => [ 'sort_algorithm' => 'alpha', ], - 'single_blank_line_before_namespace' => true, 'strict_comparison' => true, 'strict_param' => true, 'whitespace_after_comma_in_array' => true, diff --git a/composer.json b/composer.json index 06a55af..1b0de7f 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ { "name": "Emanuil Rusev", "email": "hello@erusev.com", - "homepage": "http://erusev.com" + "homepage": "https://erusev.com" } ], "require": { @@ -18,14 +18,16 @@ "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "^9.3.11||^8.5.21||^7.5.20", - "vimeo/psalm": "^4.10.0", - "friendsofphp/php-cs-fixer": "^3.0.0", - "infection/infection": "^0.25.0", - "roave/infection-static-analysis-plugin": "^1.10.0" + "phpunit/phpunit": "^10.1||^9.3.11||^8.5.21||^7.5.20", + "vimeo/psalm": "^5.26", + "friendsofphp/php-cs-fixer": "^3.0", + "infection/infection": "^0.27", + "roave/infection-static-analysis-plugin": "^1.35" }, "autoload": { - "psr-4": {"Erusev\\ParsedownExtra\\": "src/"} + "psr-4": { + "Erusev\\ParsedownExtra\\": "src/" + } }, "autoload-dev": { "psr-4": { @@ -43,10 +45,14 @@ "test-static": "vendor/bin/psalm", "test-dead-code": "vendor/bin/psalm --find-dead-code", "test-units": "vendor/bin/phpunit", - "test-commonmark": "vendor/bin/phpunit tests/CommonMarkTestStrict.php", - "test-commonmark-weak": "vendor/bin/phpunit tests/CommonMarkTestWeak.php", + "test-commonmark": "vendor/bin/phpunit vendor/erusev/parsedown/tests/CommonMarkTestStrict.php", + "test-commonmark-weak": "vendor/bin/phpunit vendor/erusev/parsedown/tests/CommonMarkTestWeak.php", "test-formatting": "@composer fix -- --dry-run", - "fix": "vendor/bin/php-cs-fixer fix --verbose --show-progress=dots --diff" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } } }