diff --git a/.gitattributes b/.gitattributes index 578c8b8c..1bd9af7f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,7 +5,7 @@ .env.dist export-ignore .gitattributes export-ignore .gitignore export-ignore -.php_cs export-ignore +.php-cs-fixer.php export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore .styleci.yml export-ignore diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index dc07f8e6..b1a12c8d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,16 +11,15 @@ jobs: strategy: matrix: php-version: - - 7.2 - - 7.3 - - 7.4 - 8.0 - 8.1 + - 8.2 + - 8.3 dependencies: [highest] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install PHP with extensions uses: shivammathur/setup-php@v2 @@ -31,7 +30,7 @@ jobs: extensions: zip - name: Install Composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{ matrix.dependencies }} composer-options: --prefer-dist diff --git a/.gitignore b/.gitignore index 2c98ebac..ead77b1f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ /.env # PHP CS Fixer -/.php_cs.cache +/.php-cs-fixer.cache # PHPUnit /build diff --git a/.php_cs b/.php-cs-fixer.php similarity index 67% rename from .php_cs rename to .php-cs-fixer.php index 78909329..deb868f5 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -16,12 +16,14 @@ ->in(__DIR__) ->exclude('vendor'); -return Config::create() +$config = new Config(); + +return $config ->setUsingCache(true) ->setRules([ - '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => true, - 'yoda_style' => false, + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => true, + 'yoda_style' => false, ]) ->setFinder($finder); diff --git a/composer.json b/composer.json index 3e37a512..0685a97e 100644 --- a/composer.json +++ b/composer.json @@ -17,21 +17,21 @@ } ], "require": { - "php": "^7.1|^8.0", + "php": "^8.0", "ext-zip": "*", "ext-json": "*", - "symfony/asset": "^4.4 || ^5.0 || ^6.0", - "symfony/config": "^4.4 || ^5.0 || ^6.0", - "symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0", - "symfony/expression-language": "^4.4 || ^5.0 || ^6.0", - "symfony/form": "^4.4 || ^5.0 || ^6.0", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/http-foundation": "^4.4 || ^5.0 || ^6.0", - "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", - "symfony/options-resolver": "^4.4 || ^5.0 || ^6.0", - "symfony/property-access": "^4.4 || ^5.0 || ^6.0", - "symfony/routing": "^4.4 || ^5.0 || ^6.0", - "symfony/twig-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/asset": "^5.4 || ^6.0 || ^7.0", + "symfony/config": "^5.4 || ^6.0 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", + "symfony/expression-language": "^5.4 || ^6.0 || ^7.0", + "symfony/form": "^5.4 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/http-foundation": "^5.4 || ^6.0 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/property-access": "^5.4 || ^6.0 || ^7.0", + "symfony/routing": "^5.4 || ^6.0 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0", "twig/twig": "^2.4 || ^3.0" }, "conflict": { @@ -39,11 +39,11 @@ "sebastian/exporter": "<2.0.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0", - "symfony/console": "^4.4 || ^5.0 || ^6.0", - "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0", - "symfony/yaml": "^4.4 || ^5.0 || ^6.0" + "friendsofphp/php-cs-fixer": "^3.41", + "matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { "egeloen/form-extra-bundle": "Allows to load CKEditor asynchronously" diff --git a/src/Builder/JsonBuilder.php b/src/Builder/JsonBuilder.php index 8bf0c62f..f73003b8 100644 --- a/src/Builder/JsonBuilder.php +++ b/src/Builder/JsonBuilder.php @@ -83,10 +83,7 @@ public function setValues(array $values, string $pathPrefix = null): self return $this; } - /** - * @param mixed $value - */ - public function setValue(string $path, $value, bool $escapeValue = true): self + public function setValue(string $path, mixed $value, bool $escapeValue = true): self { if (!$escapeValue) { $placeholder = uniqid('friendsofsymfony', true); diff --git a/src/Config/CKEditorConfiguration.php b/src/Config/CKEditorConfiguration.php index 611bddcc..1af49d0e 100644 --- a/src/Config/CKEditorConfiguration.php +++ b/src/Config/CKEditorConfiguration.php @@ -275,7 +275,7 @@ public function getToolbar(string $name): array foreach ($this->toolbarConfigs[$name] as $name => $item) { $items[] = is_string($item) && '@' === substr($item, 0, 1) - ? $this->toolbarItems[(substr($item, 1))] + ? $this->toolbarItems[substr($item, 1)] : $item; } diff --git a/src/Exception/BadProxyUrlException.php b/src/Exception/BadProxyUrlException.php index 1f00f258..9d2aa812 100644 --- a/src/Exception/BadProxyUrlException.php +++ b/src/Exception/BadProxyUrlException.php @@ -12,12 +12,10 @@ namespace FOS\CKEditorBundle\Exception; -use RuntimeException; - /** * @author Marko Kunic */ -final class BadProxyUrlException extends RuntimeException implements FOSCKEditorException +final class BadProxyUrlException extends \RuntimeException implements FOSCKEditorException { public static function fromEnvUrl(string $url): self { diff --git a/src/Exception/ConfigException.php b/src/Exception/ConfigException.php index b05e6df0..bdfaf419 100644 --- a/src/Exception/ConfigException.php +++ b/src/Exception/ConfigException.php @@ -12,12 +12,10 @@ namespace FOS\CKEditorBundle\Exception; -use RuntimeException; - /** * @author GeLo */ -final class ConfigException extends RuntimeException implements FOSCKEditorException +final class ConfigException extends \RuntimeException implements FOSCKEditorException { public static function configDoesNotExist(string $name): self { diff --git a/src/Exception/FOSCKEditorException.php b/src/Exception/FOSCKEditorException.php index a808fc8c..7129a6cb 100644 --- a/src/Exception/FOSCKEditorException.php +++ b/src/Exception/FOSCKEditorException.php @@ -12,11 +12,9 @@ namespace FOS\CKEditorBundle\Exception; -use Throwable; - /** * @author GeLo */ -interface FOSCKEditorException extends Throwable +interface FOSCKEditorException extends \Throwable { } diff --git a/src/Installer/CKEditorInstaller.php b/src/Installer/CKEditorInstaller.php index 1b9727a5..e4927ae3 100644 --- a/src/Installer/CKEditorInstaller.php +++ b/src/Installer/CKEditorInstaller.php @@ -21,49 +21,49 @@ */ final class CKEditorInstaller { - const RELEASE_BASIC = 'basic'; + public const RELEASE_BASIC = 'basic'; - const RELEASE_FULL = 'full'; + public const RELEASE_FULL = 'full'; - const RELEASE_STANDARD = 'standard'; + public const RELEASE_STANDARD = 'standard'; - const RELEASE_CUSTOM = 'custom'; + public const RELEASE_CUSTOM = 'custom'; - const VERSION_LATEST = 'latest'; + public const VERSION_LATEST = 'latest'; - const CLEAR_DROP = 'drop'; + public const CLEAR_DROP = 'drop'; - const CLEAR_KEEP = 'keep'; + public const CLEAR_KEEP = 'keep'; - const CLEAR_SKIP = 'skip'; + public const CLEAR_SKIP = 'skip'; - const NOTIFY_CLEAR = 'clear'; + public const NOTIFY_CLEAR = 'clear'; - const NOTIFY_CLEAR_ARCHIVE = 'clear-archive'; + public const NOTIFY_CLEAR_ARCHIVE = 'clear-archive'; - const NOTIFY_CLEAR_COMPLETE = 'clear-complete'; + public const NOTIFY_CLEAR_COMPLETE = 'clear-complete'; - const NOTIFY_CLEAR_PROGRESS = 'clear-progress'; + public const NOTIFY_CLEAR_PROGRESS = 'clear-progress'; - const NOTIFY_CLEAR_QUESTION = 'clear-question'; + public const NOTIFY_CLEAR_QUESTION = 'clear-question'; - const NOTIFY_CLEAR_SIZE = 'clear-size'; + public const NOTIFY_CLEAR_SIZE = 'clear-size'; - const NOTIFY_DOWNLOAD = 'download'; + public const NOTIFY_DOWNLOAD = 'download'; - const NOTIFY_DOWNLOAD_COMPLETE = 'download-complete'; + public const NOTIFY_DOWNLOAD_COMPLETE = 'download-complete'; - const NOTIFY_DOWNLOAD_PROGRESS = 'download-progress'; + public const NOTIFY_DOWNLOAD_PROGRESS = 'download-progress'; - const NOTIFY_DOWNLOAD_SIZE = 'download-size'; + public const NOTIFY_DOWNLOAD_SIZE = 'download-size'; - const NOTIFY_EXTRACT = 'extract'; + public const NOTIFY_EXTRACT = 'extract'; - const NOTIFY_EXTRACT_COMPLETE = 'extract-complete'; + public const NOTIFY_EXTRACT_COMPLETE = 'extract-complete'; - const NOTIFY_EXTRACT_PROGRESS = 'extract-progress'; + public const NOTIFY_EXTRACT_PROGRESS = 'extract-progress'; - const NOTIFY_EXTRACT_SIZE = 'extract-size'; + public const NOTIFY_EXTRACT_SIZE = 'extract-size'; /** * @var string @@ -306,16 +306,13 @@ private function extractFile(string $file, string $rewrite, string $origin, arra } } - /** - * @param mixed $data - * - * @return mixed - */ - private function notify(callable $notifier = null, string $type, $data = null) + private function notify(callable $notifier = null, string $type = null, mixed $data = null): mixed { if (null !== $notifier) { return $notifier($type, $data); } + + return null; } private function createException(string $message): \RuntimeException diff --git a/tests/DependencyInjection/FOSCKEditorExtensionTest.php b/tests/DependencyInjection/FOSCKEditorExtensionTest.php index 04e2e395..0148ee0f 100644 --- a/tests/DependencyInjection/FOSCKEditorExtensionTest.php +++ b/tests/DependencyInjection/FOSCKEditorExtensionTest.php @@ -29,6 +29,7 @@ public function testHasServiceDefinitionForTwigExtension(): void /** * @group legacy + * * @expectedDeprecation IvoryCKEditorBundle isn't maintained anymore and should be replaced with FOSCKEditorBundle. */ public function testIvoryDeprecation(): void diff --git a/tests/Installer/CKEditorInstallerTest.php b/tests/Installer/CKEditorInstallerTest.php index 303d0189..50ae8264 100644 --- a/tests/Installer/CKEditorInstallerTest.php +++ b/tests/Installer/CKEditorInstallerTest.php @@ -76,7 +76,7 @@ public function testInstallWithRelease(): void public function testInstallWithCustomBuild(): void { - $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM, 'custom_build_id' => '459c358ccf2e34f083e3c8847d3af23e']); + $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM, 'custom_build_id' => 'ffbb0c61721cb8543bfa54315374592d']); $this->assertInstall($options); } @@ -86,7 +86,7 @@ public function testInstallWithCustomBuildWithInvalidVersion(): void $this->expectException(\RuntimeException::class); $this->expectExceptionMessageMatches('/Specifying version for custom build is not supported/'); - $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM, 'custom_build_id' => '459c358ccf2e34f083e3c8847d3af23e', 'version' => '4.11.4']); + $this->installer->install(['release' => CKEditorInstaller::RELEASE_CUSTOM, 'custom_build_id' => 'ffbb0c61721cb8543bfa54315374592d', 'version' => '4.11.4']); } public function testInstallWithCustomBuildWithMissingId(): void @@ -94,7 +94,7 @@ public function testInstallWithCustomBuildWithMissingId(): void $this->expectException(\RuntimeException::class); $this->expectExceptionMessageMatches('/Custom build ID is not specified/'); - $this->installer->install($options = ['release' => CKEditorInstaller::RELEASE_CUSTOM]); + $this->installer->install(['release' => CKEditorInstaller::RELEASE_CUSTOM]); } public function testInstallWithVersion(): void @@ -262,13 +262,13 @@ private function assertRelease(string $release): void case CKEditorInstaller::RELEASE_BASIC: $this->assertFileExists($this->path.'/plugins/link'); - $this->assertFileNotExists($this->path.'/plugins/image'); + $this->assertFileDoesNotExist($this->path.'/plugins/image'); break; case CKEditorInstaller::RELEASE_STANDARD: $this->assertFileExists($this->path.'/plugins/image'); - $this->assertFileNotExists($this->path.'/plugins/copyformatting'); + $this->assertFileDoesNotExist($this->path.'/plugins/copyformatting'); break; } @@ -289,7 +289,7 @@ private function assertVersion(string $version): void private function assertExcludes(array $excludes): void { foreach ($excludes as $exclude) { - $this->assertFileNotExists($this->path.'/'.$exclude); + $this->assertFileDoesNotExist($this->path.'/'.$exclude); } } } diff --git a/tests/Renderer/CKEditorRendererTest.php b/tests/Renderer/CKEditorRendererTest.php index 2f15d722..0203e09c 100644 --- a/tests/Renderer/CKEditorRendererTest.php +++ b/tests/Renderer/CKEditorRendererTest.php @@ -190,14 +190,16 @@ public function testRenderWidgetWithStringContentsCss(string $path, string $asse */ public function testRenderWidgetWithArrayContentsCss(array $paths, array $assets, array $urls): void { + $callMap = []; foreach (array_keys($paths) as $key) { - $this->packages - ->expects($this->at($key)) - ->method('getUrl') - ->with($this->equalTo($paths[$key])) - ->will($this->returnValue($assets[$key])); + $callMap[] = [$paths[$key], null, $assets[$key]]; } + $this->packages + ->expects($this->exactly(count($paths))) + ->method('getUrl') + ->willReturnMap($callMap); + $this->assertSame( 'CKEDITOR.replace("foo", {"contentsCss":'.json_encode($urls).'});', $this->renderer->renderWidget('foo', ['contentsCss' => $paths])