From ce5230bf30288594746032e0947105b2b0bf4ab0 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 21 Oct 2025 21:26:12 -0400 Subject: [PATCH 01/13] Update dependency to deal with deprecations in depedency tree --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f1deeba..d17dbbf 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "^8.1", "cakephp/cakephp": "^5.0", - "kcs/class-finder": "^0.3" + "kcs/class-finder": "^0.3|^0.6" }, "require-dev": { "cakephp/cakephp-codesniffer": "^5.0", From 45584eacd397ceb40674bfa95caa5b364875e339 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 21 Oct 2025 22:23:59 -0400 Subject: [PATCH 02/13] Upgrade kcs class finder and Resolve breaking change in kcs --- composer.json | 4 ++-- src/Utility/NamespaceUtility.php | 1 + tests/bootstrap.php | 11 ++--------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index d17dbbf..d91daa3 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "keywords": ["mixerapi","cakephp"], "require": { "php": "^8.1", - "cakephp/cakephp": "^5.0", - "kcs/class-finder": "^0.3|^0.6" + "cakephp/cakephp": "~5.2.0", + "kcs/class-finder": "^0.6" }, "require-dev": { "cakephp/cakephp-codesniffer": "^5.0", diff --git a/src/Utility/NamespaceUtility.php b/src/Utility/NamespaceUtility.php index 6a44409..970623f 100644 --- a/src/Utility/NamespaceUtility.php +++ b/src/Utility/NamespaceUtility.php @@ -41,6 +41,7 @@ public static function findClasses(?string $namespace = null, array $paths = []) } $finder = (new ComposerFinder()) + ->useAutoloading(false) ->inNamespace($namespace) ->in($paths); $classes = []; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3fa28a2..520d67f 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -26,28 +26,21 @@ * Add additional configuration/setup your application needs when running * unit tests in this file. */ -require dirname(__DIR__) . '/vendor/autoload.php'; - // Path constants to a few helpful things. if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } + define('ROOT', dirname(__DIR__)); -define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp'); define('CORE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp' . DS); define('CAKE', CORE_PATH . 'src' . DS); -define('TESTS', ROOT . DS . 'tests'); define('APP', ROOT . DS . 'tests' . DS . 'test_app' . DS); define('APP_DIR', 'test_app'); -define('WEBROOT_DIR', 'webroot'); -define('WWW_ROOT', APP . 'webroot' . DS); require_once CORE_PATH . 'config/bootstrap.php'; $_SERVER['PHP_SELF'] = '/'; -define('IS_TEST', true); - Configure::write('App.fullBaseUrl', 'http://localhost'); putenv('DB=sqlite'); @@ -67,7 +60,7 @@ define('TMP', sys_get_temp_dir() . DS); define('CACHE', TMP . 'cache' . DS); Cache::setConfig([ - '_cake_core_' => [ + '_cake_translations_' => [ 'engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, From 0d87c648f02664e32289fac46b21fed9427edeb1 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 21 Oct 2025 22:27:55 -0400 Subject: [PATCH 03/13] appease the linters --- composer.json | 4 ++-- phpcs.xml | 1 - src/Model/Model.php | 2 +- src/Model/ModelFactory.php | 2 +- src/Model/ModelPropertyFactory.php | 2 +- src/Response/ResponseModifier.php | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index d91daa3..e89a21f 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,9 @@ "kcs/class-finder": "^0.6" }, "require-dev": { - "cakephp/cakephp-codesniffer": "^5.0", + "cakephp/cakephp-codesniffer": "~5.3.0", "phpmd/phpmd": "^2.10", - "phpstan/phpstan": "^1.8.5", + "phpstan/phpstan": "~1.12.0", "phpunit/phpunit": "^10" }, "autoload": { diff --git a/phpcs.xml b/phpcs.xml index e231060..f3d0172 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,5 +1,4 @@ - \ No newline at end of file diff --git a/src/Model/Model.php b/src/Model/Model.php index f5a45f3..48a11da 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -27,7 +27,7 @@ class Model public function __construct( private TableSchema $schema, private Table $table, - private EntityInterface $entity + private EntityInterface $entity, ) { $this->assignProperties(); } diff --git a/src/Model/ModelFactory.php b/src/Model/ModelFactory.php index 13446b5..8be8c37 100644 --- a/src/Model/ModelFactory.php +++ b/src/Model/ModelFactory.php @@ -31,7 +31,7 @@ public function create(): ?Model return new Model( $this->connection->getSchemaCollection()->describe($this->table->getTable()), $this->table, - new $entityFqn() + new $entityFqn(), ); } } diff --git a/src/Model/ModelPropertyFactory.php b/src/Model/ModelPropertyFactory.php index 282da8a..10b4516 100644 --- a/src/Model/ModelPropertyFactory.php +++ b/src/Model/ModelPropertyFactory.php @@ -25,7 +25,7 @@ public function __construct( private TableSchema $schema, private Table $table, private string $columnName, - private EntityInterface $entity + private EntityInterface $entity, ) { } diff --git a/src/Response/ResponseModifier.php b/src/Response/ResponseModifier.php index 09a01f7..ff84937 100644 --- a/src/Response/ResponseModifier.php +++ b/src/Response/ResponseModifier.php @@ -34,7 +34,7 @@ public function listen(): void if ($controller->components()->has('RequestHandler')) { $controller->RequestHandler->setConfig( 'viewClassMap.' . $this->type, - $this->viewClass + $this->viewClass, ); } }); From 545790afb4b3d03e5251e90433a9b32adccf94cf Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 21 Oct 2025 22:31:01 -0400 Subject: [PATCH 04/13] cakephp compat checks for ~5.0 and ^5.0, php compat check for 8.1 and 8.4 --- .github/workflows/master.yml | 2 +- .github/workflows/pull-request.yml | 32 +++--------------------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a63166f..15455fb 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['8.1'] + php-versions: ['8.4'] name: Upload coverage report steps: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7b6013c..d154b41 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,7 +5,7 @@ on: jobs: analyze: - name: PHP 8.1 Test / Analysis / Coverage + name: PHP 8.4 Test / Analysis / Coverage runs-on: ubuntu-latest steps: - name: Checkout @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.4' extensions: mbstring, intl, xdebug, sqlite3, xml, simplexml tools: composer:v2 coverage: xdebug @@ -37,32 +37,6 @@ jobs: composer global require php-coveralls/php-coveralls export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=clover.xml php-coveralls --coverage_clover=clover.xml -v - test: - name: PHP 8.3 Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.3' - extensions: mbstring, intl, xdebug, sqlite3 - - - name: PHP Version - run: php -v - - - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: | - composer self-update - composer validate - composer install --prefer-dist --no-progress - - - name: Test Suite - run: | - composer test # # CakePHP version compatability @@ -72,7 +46,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: ['~5.0'] + version: ['~5.0.0', '^5.0'] steps: - name: Checkout uses: actions/checkout@v2 From 2525c015fc4ab449568a6313cb2c7607f1e87e0c Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Tue, 21 Oct 2025 22:37:05 -0400 Subject: [PATCH 05/13] support both versions because dude can't semver --- composer.json | 2 +- src/Utility/NamespaceUtility.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index e89a21f..9819d19 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "^8.1", "cakephp/cakephp": "~5.2.0", - "kcs/class-finder": "^0.6" + "kcs/class-finder": "^0.3 || ^0.6" }, "require-dev": { "cakephp/cakephp-codesniffer": "~5.3.0", diff --git a/src/Utility/NamespaceUtility.php b/src/Utility/NamespaceUtility.php index 970623f..67b91cb 100644 --- a/src/Utility/NamespaceUtility.php +++ b/src/Utility/NamespaceUtility.php @@ -40,10 +40,11 @@ public static function findClasses(?string $namespace = null, array $paths = []) } } - $finder = (new ComposerFinder()) - ->useAutoloading(false) - ->inNamespace($namespace) - ->in($paths); + $finder = (new ComposerFinder())->inNamespace($namespace)->in($paths); + if (method_exists(ComposerFinder::class, 'useAutoloading')) { + $finder->useAutoloading(false); + } + $classes = []; foreach ($finder as $className => $reflector) { $classes[] = $className; From 767e6ade1d38648ab22707c3ccef1d1a5f42523b Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:06:30 -0400 Subject: [PATCH 06/13] wip --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 9819d19..7fda956 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,12 @@ "keywords": ["mixerapi","cakephp"], "require": { "php": "^8.1", - "cakephp/cakephp": "~5.2.0", - "kcs/class-finder": "^0.3 || ^0.6" + "cakephp/cakephp": "^5.0", + "kcs/class-finder": "^0.6" }, "require-dev": { "cakephp/cakephp-codesniffer": "~5.3.0", - "phpmd/phpmd": "^2.10", + "phpmd/phpmd": "~2.15.0", "phpstan/phpstan": "~1.12.0", "phpunit/phpunit": "^10" }, From b06ba042e4aed022741d733f9cba26ee8ebb3ac8 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:10:46 -0400 Subject: [PATCH 07/13] restore deprecation for BC --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 520d67f..881f373 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -60,7 +60,7 @@ define('TMP', sys_get_temp_dir() . DS); define('CACHE', TMP . 'cache' . DS); Cache::setConfig([ - '_cake_translations_' => [ + '_cake_core_' => [ 'engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, From 1d4ea07dc30625555e3c8b3e04251282b7c10abe Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:19:31 -0400 Subject: [PATCH 08/13] handle dep --- tests/TestCase/Response/ResponseModifierTest.php | 5 ++--- tests/bootstrap.php | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/TestCase/Response/ResponseModifierTest.php b/tests/TestCase/Response/ResponseModifierTest.php index fedbd57..214085a 100644 --- a/tests/TestCase/Response/ResponseModifierTest.php +++ b/tests/TestCase/Response/ResponseModifierTest.php @@ -1,10 +1,9 @@ = 520) { + $configName = '_cake_translations_'; +} + Cache::setConfig([ - '_cake_core_' => [ + "$configName" => [ 'engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, From e9e769e2d83a1683fe3a7b5eb9b5d4b70494897c Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:21:52 -0400 Subject: [PATCH 09/13] leave dep --- .github/workflows/pull-request.yml | 4 ++-- tests/bootstrap.php | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d154b41..bfbf6bf 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,7 +5,7 @@ on: jobs: analyze: - name: PHP 8.4 Test / Analysis / Coverage + name: PHP 8.3 Test / Analysis / Coverage runs-on: ubuntu-latest steps: - name: Checkout @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.4' + php-version: '8.3' extensions: mbstring, intl, xdebug, sqlite3, xml, simplexml tools: composer:v2 coverage: xdebug diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d10839b..2add66d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -60,14 +60,8 @@ define('TMP', sys_get_temp_dir() . DS); define('CACHE', TMP . 'cache' . DS); -$version = (int)preg_replace('/[^0-9]/', '', Configure::version()); -$configName = '_cake_core_'; -if ($version >= 520) { - $configName = '_cake_translations_'; -} - Cache::setConfig([ - "$configName" => [ + '_cake_core_' => [ 'engine' => 'File', 'prefix' => 'cake_core_', 'serialize' => true, From c9675a1d504ec414ebb4ef3497169aac7026811a Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:27:04 -0400 Subject: [PATCH 10/13] wip --- .github/workflows/pull-request.yml | 6 ++++-- tests/TestCase/Response/ResponseModifierTest.php | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index bfbf6bf..113f6cb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,7 +5,7 @@ on: jobs: analyze: - name: PHP 8.3 Test / Analysis / Coverage + name: PHP 8.4 Test / Analysis / Coverage runs-on: ubuntu-latest steps: - name: Checkout @@ -14,7 +14,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.3' + php-version: '8.4' extensions: mbstring, intl, xdebug, sqlite3, xml, simplexml tools: composer:v2 coverage: xdebug @@ -24,6 +24,8 @@ jobs: - name: Install run: | + composer self-update + rm -rf composer.lock composer install --prefer-dist --no-interaction --no-progress composer update diff --git a/tests/TestCase/Response/ResponseModifierTest.php b/tests/TestCase/Response/ResponseModifierTest.php index 214085a..9334687 100644 --- a/tests/TestCase/Response/ResponseModifierTest.php +++ b/tests/TestCase/Response/ResponseModifierTest.php @@ -12,10 +12,8 @@ class ResponseModifierTest extends TestCase { public function test_event_listener(): void { - $modifier = new ResponseModifier('jsonld', 'MixerApi/JsonLdView.JsonLd'); - $modifier->listen(); - $eventManager = EventManager::instance(); - $listeners = $eventManager->matchingListeners('Controller.initialize'); + (new ResponseModifier('jsonld', 'MixerApi/JsonLdView.JsonLd'))->listen(); + $listeners = EventManager::instance()->matchingListeners('Controller.initialize'); $names = []; foreach ($listeners['Controller.initialize'] as $listens) { foreach ($listens as $listen) { From a2a04bf137f1b68e2769befbdc5a752e677ecc79 Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:33:16 -0400 Subject: [PATCH 11/13] debug --- tests/TestCase/Response/ResponseModifierTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TestCase/Response/ResponseModifierTest.php b/tests/TestCase/Response/ResponseModifierTest.php index 9334687..3386dd9 100644 --- a/tests/TestCase/Response/ResponseModifierTest.php +++ b/tests/TestCase/Response/ResponseModifierTest.php @@ -14,12 +14,14 @@ public function test_event_listener(): void { (new ResponseModifier('jsonld', 'MixerApi/JsonLdView.JsonLd'))->listen(); $listeners = EventManager::instance()->matchingListeners('Controller.initialize'); + print_r($listeners); $names = []; foreach ($listeners['Controller.initialize'] as $listens) { foreach ($listens as $listen) { $names[] = (new ReflectionFunction($listen['callable']))->name; } } + print_r($names); $results = array_filter($names, function ($name) { return strstr($name, 'MixerApi\Core\Response\{closure}'); From 0182a6e347903b1df96cfe1214d78e551f364cad Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:56:35 -0400 Subject: [PATCH 12/13] remove response modifier which interacts with the deprecated requesthandlercomponent --- src/Response/ResponseModifier.php | 42 ------------------- .../Response/ResponseModifierTest.php | 32 -------------- 2 files changed, 74 deletions(-) delete mode 100644 src/Response/ResponseModifier.php delete mode 100644 tests/TestCase/Response/ResponseModifierTest.php diff --git a/src/Response/ResponseModifier.php b/src/Response/ResponseModifier.php deleted file mode 100644 index ff84937..0000000 --- a/src/Response/ResponseModifier.php +++ /dev/null @@ -1,42 +0,0 @@ -type alias - */ - public function __construct(private string $type, private string $viewClass) - { - } - - /** - * Registers Controller.initialize listener which performs the following actions: - * - Modifies the CakePHP Response type map if necessary to add additional mime types (note: this will be removed - * in a future version of the application). - * - Sets the view class map to render responses in the requested mime type. - * - * @return void - */ - public function listen(): void - { - EventManager::instance() - ->on('Controller.initialize', function (Event $event): void { - - /** @var \Cake\Controller\Controller $controller */ - $controller = $event->getSubject(); - if ($controller->components()->has('RequestHandler')) { - $controller->RequestHandler->setConfig( - 'viewClassMap.' . $this->type, - $this->viewClass, - ); - } - }); - } -} diff --git a/tests/TestCase/Response/ResponseModifierTest.php b/tests/TestCase/Response/ResponseModifierTest.php deleted file mode 100644 index 3386dd9..0000000 --- a/tests/TestCase/Response/ResponseModifierTest.php +++ /dev/null @@ -1,32 +0,0 @@ -listen(); - $listeners = EventManager::instance()->matchingListeners('Controller.initialize'); - print_r($listeners); - $names = []; - foreach ($listeners['Controller.initialize'] as $listens) { - foreach ($listens as $listen) { - $names[] = (new ReflectionFunction($listen['callable']))->name; - } - } - print_r($names); - - $results = array_filter($names, function ($name) { - return strstr($name, 'MixerApi\Core\Response\{closure}'); - }); - - $this->assertNotEmpty($results); - } -} From 3c3a59e7c70c0212e9c3b43259484cd0e277b65f Mon Sep 17 00:00:00 2001 From: Chris Nizzardini Date: Wed, 22 Oct 2025 08:58:22 -0400 Subject: [PATCH 13/13] wip --- src/Utility/NamespaceUtility.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utility/NamespaceUtility.php b/src/Utility/NamespaceUtility.php index 67b91cb..d7bfe7c 100644 --- a/src/Utility/NamespaceUtility.php +++ b/src/Utility/NamespaceUtility.php @@ -40,10 +40,10 @@ public static function findClasses(?string $namespace = null, array $paths = []) } } - $finder = (new ComposerFinder())->inNamespace($namespace)->in($paths); - if (method_exists(ComposerFinder::class, 'useAutoloading')) { - $finder->useAutoloading(false); - } + $finder = (new ComposerFinder()) + ->inNamespace($namespace) + ->in($paths) + ->useAutoloading(false); $classes = []; foreach ($finder as $className => $reflector) {