From 7aeb72e2a1b0625cae073a339d5ec32d89c9c28c Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 00:37:46 +0200 Subject: [PATCH 1/9] Fix: correctly removing/adding TinyMCE license files --- .../ComposerPlugin/Copy/Plugins/TinyMce.php | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index 553eb09..a0c629b 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -14,6 +14,7 @@ use Composer\Package\BasePackage; use OpenMage\ComposerPlugin\Copy; use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Filesystem\Filesystem; /** * Class TinyMce @@ -23,21 +24,6 @@ class TinyMce extends Copy\AbstractCopyPlugin implements Copy\CopyFromComposerIn public const TINYMCE_LICENSE_FILE = 'LICENSE_TINYMCE.txt'; public const TINYMCE_LICENSE_NOTE = 'LICENSE_TINYMCE_OPENMAGE.txt'; - public const TINYMCE_LICENSE_FILE_TEXT = <<event)) { - return; - } - $package = $this->getComposerPackage(); if (!$package instanceof BasePackage) { + $this->removedTinyMceLicenseFiles(); return; } $version = $package->getVersion(); - switch ((int) $version[0]) { + $versionMain = explode('.', $version, 1); + $versionMain = (int) $version[0]; + + switch ($versionMain) { case 6: $this->removedTinyMceLicenseFiles(); break; - case 7: + case $versionMain >= 7: $this->addTinyMceLicenseFile(); $this->addTinyMceLicenseNote(); break; @@ -85,20 +71,37 @@ public function processComposerInstall(): void private function addTinyMceLicenseFile(): void { + $content = <<getFileSystem()->dumpFile($this->getCwd() . '/' . self::TINYMCE_LICENSE_FILE, self::TINYMCE_LICENSE_FILE_TEXT); - if (!is_null($this->event) && $this->event->getIO()->isVerbose()) { + $filesystem->dumpFile($this->getCwd() . '/' . self::TINYMCE_LICENSE_FILE, $content); + if ($this->event->getIO()->isVerbose()) { $this->event->getIO()->write(sprintf('Added %s', self::TINYMCE_LICENSE_FILE)); } - } catch (IOException $exception) { - if (!is_null($this->event)) { - $this->event->getIO()->write($exception->getMessage()); - } + } catch (IOException $IOException) { + $this->event->getIO()->write($IOException->getMessage()); } } private function addTinyMceLicenseNote(): void { + $content = <<getFileSystem()->dumpFile($filePath, self::TINYMCE_LICENSE_NOTE_TEXT); - if (!is_null($this->event) && $this->event->getIO()->isVerbose()) { + $filesystem->dumpFile($filePath, $content); + if ($this->event->getIO()->isVerbose()) { $this->event->getIO()->write(sprintf('Added %s', self::TINYMCE_LICENSE_NOTE)); } - } catch (IOException $exception) { - if (!is_null($this->event)) { - $this->event->getIO()->write($exception->getMessage()); - } + } catch (IOException $IOException) { + $this->event->getIO()->write($IOException->getMessage()); } } @@ -125,15 +126,15 @@ private function removedTinyMceLicenseFiles(): void $this->getComposerSource() . '/' . self::TINYMCE_LICENSE_NOTE, ]; + $filesystem = new Filesystem(); + try { - $this->getFileSystem()->remove($files); - if (!is_null($this->event) && $this->event->getIO()->isVeryVerbose()) { + $filesystem->remove($files); + if ($this->event->getIO()->isVeryVerbose()) { $this->event->getIO()->write(sprintf('Removed %s and %s', self::TINYMCE_LICENSE_FILE, self::TINYMCE_LICENSE_NOTE)); } - } catch (IOException $exception) { - if (!is_null($this->event)) { - $this->event->getIO()->write($exception->getMessage()); - } + } catch (IOException $IOException) { + $this->event->getIO()->write($IOException->getMessage()); } } } From bc869a32b6c4729294b1192a6d1dc9d8e84c5608 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:01:28 +0200 Subject: [PATCH 2/9] Update src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index a0c629b..bcd612f 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -53,8 +53,8 @@ public function processComposerInstall(): void } $version = $package->getVersion(); - $versionMain = explode('.', $version, 1); - $versionMain = (int) $version[0]; + $versionParts = explode('.', $version); + $versionMain = (int) $versionParts[0]; switch ($versionMain) { case 6: From 846596855bcca8aff7c478f6e702d053786d67db Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:10:03 +0200 Subject: [PATCH 3/9] Fix 1 --- .../ComposerPlugin/Copy/Plugins/TinyMce.php | 73 ++++++++++--------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index bcd612f..746ff03 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -14,7 +14,6 @@ use Composer\Package\BasePackage; use OpenMage\ComposerPlugin\Copy; use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; /** * Class TinyMce @@ -24,6 +23,21 @@ class TinyMce extends Copy\AbstractCopyPlugin implements Copy\CopyFromComposerIn public const TINYMCE_LICENSE_FILE = 'LICENSE_TINYMCE.txt'; public const TINYMCE_LICENSE_NOTE = 'LICENSE_TINYMCE_OPENMAGE.txt'; + public const TINYMCE_LICENSE_FILE_TEXT = <<event)) { + return; + } + $package = $this->getComposerPackage(); if (!$package instanceof BasePackage) { $this->removedTinyMceLicenseFiles(); @@ -60,7 +78,7 @@ public function processComposerInstall(): void case 6: $this->removedTinyMceLicenseFiles(); break; - case $versionMain >= 7: + default: $this->addTinyMceLicenseFile(); $this->addTinyMceLicenseNote(); break; @@ -71,37 +89,20 @@ public function processComposerInstall(): void private function addTinyMceLicenseFile(): void { - $content = <<dumpFile($this->getCwd() . '/' . self::TINYMCE_LICENSE_FILE, $content); - if ($this->event->getIO()->isVerbose()) { + $this->getFileSystem()->dumpFile($this->getCwd() . '/' . self::TINYMCE_LICENSE_FILE, self::TINYMCE_LICENSE_FILE_TEXT); + if (!is_null($this->event) && $this->event->getIO()->isVerbose()) { $this->event->getIO()->write(sprintf('Added %s', self::TINYMCE_LICENSE_FILE)); } - } catch (IOException $IOException) { - $this->event->getIO()->write($IOException->getMessage()); + } catch (IOException $exception) { + if (!is_null($this->event)) { + $this->event->getIO()->write($exception->getMessage()); + } } } private function addTinyMceLicenseNote(): void { - $content = <<dumpFile($filePath, $content); - if ($this->event->getIO()->isVerbose()) { + $this->getFileSystem()->dumpFile($filePath, self::TINYMCE_LICENSE_NOTE_TEXT); + if (!is_null($this->event) && $this->event->getIO()->isVerbose()) { $this->event->getIO()->write(sprintf('Added %s', self::TINYMCE_LICENSE_NOTE)); } - } catch (IOException $IOException) { - $this->event->getIO()->write($IOException->getMessage()); + } catch (IOException $exception) { + if (!is_null($this->event)) { + $this->event->getIO()->write($exception->getMessage()); + } } } @@ -126,15 +129,15 @@ private function removedTinyMceLicenseFiles(): void $this->getComposerSource() . '/' . self::TINYMCE_LICENSE_NOTE, ]; - $filesystem = new Filesystem(); - try { - $filesystem->remove($files); - if ($this->event->getIO()->isVeryVerbose()) { + $this->getFileSystem()->remove($files); + if (!is_null($this->event) && $this->event->getIO()->isVeryVerbose()) { $this->event->getIO()->write(sprintf('Removed %s and %s', self::TINYMCE_LICENSE_FILE, self::TINYMCE_LICENSE_NOTE)); } - } catch (IOException $IOException) { - $this->event->getIO()->write($IOException->getMessage()); + } catch (IOException $exception) { + if (!is_null($this->event)) { + $this->event->getIO()->write($exception->getMessage()); + } } } } From d0dffa5d138260d6ba7ec5ae650244d7e1cd0009 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:26:29 +0200 Subject: [PATCH 4/9] Refactor version extraction for TinyMce plugin --- src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index 746ff03..be72869 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -72,10 +72,10 @@ public function processComposerInstall(): void $version = $package->getVersion(); $versionParts = explode('.', $version); - $versionMain = (int) $versionParts[0]; + $versionMain = (int) array_first($versionParts); switch ($versionMain) { - case 6: + case $versionMain <= 6: $this->removedTinyMceLicenseFiles(); break; default: From 6b389f5dba8237a164e8f3adcd7e27541fbf9a6f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:27:17 +0200 Subject: [PATCH 5/9] Add symfony/polyfill-php85 to composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 705353f..c003467 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "phpstan/phpstan-phpunit": "^2.0", "phpunit/phpunit": "^9.6", "phpmd/phpmd": "^2.15", - "friendsofphp/php-cs-fixer": "^3.67" + "friendsofphp/php-cs-fixer": "^3.67", + "symfony/polyfill-php85": "^v1.33.0" }, "extra": { "class": "OpenMage\\ComposerPlugin\\Plugin" From 2960a1b6febf182ff8396c22f520e910c4f6e76a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:31:24 +0200 Subject: [PATCH 6/9] Add symfony/polyfill-php85 to composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index c003467..4048ece 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "php": ">=7.4", "composer-plugin-api": "^2.0", "symfony/filesystem": "*", - "symfony/finder": "*" + "symfony/finder": "*", + "symfony/polyfill-php85": "^v1.33.0" }, "require-dev": { "composer/composer": "^2.8", @@ -33,8 +34,7 @@ "phpstan/phpstan-phpunit": "^2.0", "phpunit/phpunit": "^9.6", "phpmd/phpmd": "^2.15", - "friendsofphp/php-cs-fixer": "^3.67", - "symfony/polyfill-php85": "^v1.33.0" + "friendsofphp/php-cs-fixer": "^3.67" }, "extra": { "class": "OpenMage\\ComposerPlugin\\Plugin" From 2db33c1a03e97620cc7e783f5fa00a50e3fecc8a Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:33:08 +0200 Subject: [PATCH 7/9] Fix switch case for TinyMCE version handling --- src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index be72869..ed36d66 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -75,7 +75,7 @@ public function processComposerInstall(): void $versionMain = (int) array_first($versionParts); switch ($versionMain) { - case $versionMain <= 6: + case 6: $this->removedTinyMceLicenseFiles(); break; default: From bcfe88577a9f820da19771f8252b2aa79a9295d6 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:39:11 +0200 Subject: [PATCH 8/9] Refactor version extraction for TinyMce plugin --- src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php index ed36d66..746ff03 100644 --- a/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php +++ b/src/OpenMage/ComposerPlugin/Copy/Plugins/TinyMce.php @@ -72,7 +72,7 @@ public function processComposerInstall(): void $version = $package->getVersion(); $versionParts = explode('.', $version); - $versionMain = (int) array_first($versionParts); + $versionMain = (int) $versionParts[0]; switch ($versionMain) { case 6: From 1dd4aad2eea1fbad40a00df1daca0fcdce51d26f Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 2 Oct 2025 01:39:38 +0200 Subject: [PATCH 9/9] Fix formatting in composer.json dependencies --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4048ece..705353f 100644 --- a/composer.json +++ b/composer.json @@ -23,8 +23,7 @@ "php": ">=7.4", "composer-plugin-api": "^2.0", "symfony/filesystem": "*", - "symfony/finder": "*", - "symfony/polyfill-php85": "^v1.33.0" + "symfony/finder": "*" }, "require-dev": { "composer/composer": "^2.8",