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..113f6cb 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 @@ -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 @@ -37,32 +39,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 +48,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - version: ['~5.0'] + version: ['~5.0.0', '^5.0'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index f1deeba..7fda956 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,12 @@ "require": { "php": "^8.1", "cakephp/cakephp": "^5.0", - "kcs/class-finder": "^0.3" + "kcs/class-finder": "^0.6" }, "require-dev": { - "cakephp/cakephp-codesniffer": "^5.0", - "phpmd/phpmd": "^2.10", - "phpstan/phpstan": "^1.8.5", + "cakephp/cakephp-codesniffer": "~5.3.0", + "phpmd/phpmd": "~2.15.0", + "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 deleted file mode 100644 index 09a01f7..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/src/Utility/NamespaceUtility.php b/src/Utility/NamespaceUtility.php index 6a44409..d7bfe7c 100644 --- a/src/Utility/NamespaceUtility.php +++ b/src/Utility/NamespaceUtility.php @@ -42,7 +42,9 @@ public static function findClasses(?string $namespace = null, array $paths = []) $finder = (new ComposerFinder()) ->inNamespace($namespace) - ->in($paths); + ->in($paths) + ->useAutoloading(false); + $classes = []; foreach ($finder as $className => $reflector) { $classes[] = $className; diff --git a/tests/TestCase/Response/ResponseModifierTest.php b/tests/TestCase/Response/ResponseModifierTest.php deleted file mode 100644 index fedbd57..0000000 --- a/tests/TestCase/Response/ResponseModifierTest.php +++ /dev/null @@ -1,33 +0,0 @@ -listen(); - $eventManager = EventManager::instance(); - $listeners = $eventManager->matchingListeners('Controller.initialize'); - $names = []; - foreach ($listeners['Controller.initialize'] as $listens) { - foreach ($listens as $listen) { - $names[] = (new ReflectionFunction($listen['callable']))->name; - } - } - - $results = array_filter($names, function($name) { - return strstr($name, 'MixerApi\Core\Response\{closure}'); - }); - - $this->assertNotEmpty($results); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3fa28a2..2add66d 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'); @@ -66,6 +59,7 @@ define('TMP', sys_get_temp_dir() . DS); define('CACHE', TMP . 'cache' . DS); + Cache::setConfig([ '_cake_core_' => [ 'engine' => 'File',