diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 497639ed..b51ffd98 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -23,7 +23,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer:v2 + tools: composer:v2, cs2pr - name: Install PHP Dependencies run: composer install --prefer-dist @@ -32,7 +32,7 @@ jobs: run: composer phpunit - name: Run phpcs - run: composer cs + run: composer cs:ci - name: Run PHPStan - run: composer static \ No newline at end of file + run: composer static diff --git a/.gitignore b/.gitignore index bd3ab1e1..067390d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea node_modules .DS_Store +.php-cs-fixer.cache npm-debug.log /vendor/ /logs/* diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..df8b0a6c --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,15 @@ +in(__DIR__ . '/src') + ->in(__DIR__ . '/test') + ->in(__DIR__ . '/app') +; + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PER-CS2.0' => true, + 'declare_strict_types' => true, + 'no_unused_imports' => true, + ]) + ->setFinder($finder); \ No newline at end of file diff --git a/app/config.php b/app/config.php index 6404bd1d..27558bab 100644 --- a/app/config.php +++ b/app/config.php @@ -1,5 +1,7 @@ addRoutingMiddleware(); - $app->add(function (Request $request, RequestHandler $handler) use($c) : Response { + $app->add(function (Request $request, RequestHandler $handler) use ($c): Response { /** @var Session $session */ $session = $this->get(Session::class); @@ -139,7 +140,7 @@ }), 'cache' => factory(function (ContainerInterface $c): CacheInterface { if (!$c->get('config')['enableCache']) { - return new NullAdapter; + return new NullAdapter(); } $redisConnection = new \Predis\Client(['host' => $c->get('config')['redisHost']]); @@ -157,10 +158,10 @@ return new RedisAdapter($redisConnection, 'default'); }), - LoggerInterface::class => factory(function (ContainerInterface $c): LoggerInterface{ + LoggerInterface::class => factory(function (ContainerInterface $c): LoggerInterface { $settings = $c->get('config')['logger']; $logger = new Logger($settings['name']); - $logger->pushProcessor(new UidProcessor); + $logger->pushProcessor(new UidProcessor()); $logger->pushHandler(new StreamHandler($settings['path'], Logger::DEBUG)); return $logger; }), @@ -168,7 +169,7 @@ SessionStorageInterface::class => get(Session::class), Session::class => function (ContainerInterface $c): Session { - return new Session; + return new Session(); }, FormHandlerFactory::class => function (ContainerInterface $c): FormHandlerFactory { @@ -230,7 +231,7 @@ Login::class => \DI\factory(function (ContainerInterface $c): Login { return new Login( $c->get(AdminAuthenticationService::class), - $c->get(FormHandlerFactory::class)->create(new LoginInputFilter), + $c->get(FormHandlerFactory::class)->create(new LoginInputFilter()), $c->get('config')['jwtSecret'] ); }), @@ -365,7 +366,7 @@ }, 'form.event' => function (ContainerInterface $c): FormHandler { - return $c->get(FormHandlerFactory::class)->create(new EventInputFilter); + return $c->get(FormHandlerFactory::class)->create(new EventInputFilter()); }, EventAll::class => function (ContainerInterface $c): EventAll { @@ -474,7 +475,7 @@ Generator::class => function (ContainerInterface $c): Generator { return new Generator( - new Parser(null, new class implements \Mni\FrontYAML\Markdown\MarkdownParser { + new Parser(null, new class () implements \Mni\FrontYAML\Markdown\MarkdownParser { public function parse($markdown): string { return (new Parsedown())->parse($markdown); @@ -523,7 +524,7 @@ public function parse($markdown): string ); }, - JwtAuthentication::class => function (ContainerInterface $c): JwtAuthentication { + JwtAuthentication::class => function (ContainerInterface $c): JwtAuthentication { return new JwtAuthentication([ 'secret' => $c->get('config')['jwtSecret'], 'path' => '/api/admin', @@ -566,7 +567,7 @@ public function parse($markdown): string 'src/User/Entity', ], 'auto_generate_proxies' => true, - 'proxy_dir' => __DIR__.'/../cache/proxies', + 'proxy_dir' => __DIR__ . '/../cache/proxies', ], 'connection' => [ 'driver' => 'pdo_mysql', diff --git a/composer.json b/composer.json index 786123d1..69687763 100644 --- a/composer.json +++ b/composer.json @@ -61,11 +61,11 @@ } }, "require-dev": { - "squizlabs/php_codesniffer": "^3.6", "phpunit/phpunit": "^9.5", "weirdan/doctrine-psalm-plugin": "^1.0", "doctrine/data-fixtures": "^1.5", - "phpstan/phpstan": "^1.9" + "phpstan/phpstan": "^1.9", + "friendsofphp/php-cs-fixer": "^3.51" }, "scripts" : { "test": [ @@ -73,8 +73,9 @@ "@cs" ], "phpunit": "phpunit", - "cs" : "phpcs", - "cs-fix": "phpcbf", + "cs" : "php-cs-fixer fix --dry-run --allow-risky=yes", + "cs:ci" : "php-cs-fixer fix --dry-run --allow-risky=yes --format=checkstyle | cs2pr", + "cs-fix": "php-cs-fixer --allow-risky=yes fix", "static": "phpstan --ansi analyse --level max src", "app:cc": "php bin/app clear-cache", "app:gen:blog": "php bin/app generate-blog", diff --git a/composer.lock b/composer.lock index 7239633d..3543ac09 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e82b3fe07c060412174d3c6596582201", + "content-hash": "36667f33b4e3741c4c9fdcfb66f63d63", "packages": [ { "name": "ahinkle/packagist-latest-version", @@ -9024,6 +9024,98 @@ }, "time": "2022-03-02T22:36:06+00:00" }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.51.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "127fa74f010da99053e3f5b62672615b72dd6efd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/127fa74f010da99053e3f5b62672615b72dd6efd", + "reference": "127fa74f010da99053e3f5b62672615b72dd6efd", + "shasum": "" + }, + "require": { + "composer/semver": "^3.4", + "composer/xdebug-handler": "^3.0.3", + "ext-filter": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/polyfill-mbstring": "^1.28", + "symfony/polyfill-php80": "^1.28", + "symfony/polyfill-php81": "^1.28", + "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.1", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.7", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", + "phpunit/phpunit": "^9.6 || ^10.5.5 || ^11.0.2", + "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz RumiƄski", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.51.0" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2024-02-28T19:50:06+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.11.1", @@ -10004,6 +10096,56 @@ ], "time": "2024-02-23T13:14:51+00:00" }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "time": "2019-01-08T18:20:26+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -10969,84 +11111,298 @@ "time": "2020-09-28T06:39:44+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.9.0", + "name": "symfony/event-dispatcher", + "version": "v7.0.3", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "834c28d533dd0636f910909d01b9ff45cc094b5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", - "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/834c28d533dd0636f910909d01b9ff45cc094b5e", + "reference": "834c28d533dd0636f910909d01b9ff45cc094b5e", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "php": ">=8.2", + "symfony/event-dispatcher-contracts": "^2.5|^3" + }, + "conflict": { + "symfony/dependency-injection": "<6.4", + "symfony/service-contracts": "<2.5" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/error-handler": "^6.4|^7.0", + "symfony/expression-language": "^6.4|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^6.4|^7.0" }, - "bin": [ - "bin/phpcbf", - "bin/phpcs" + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T15:02:46+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df", + "reference": "a76aed96a42d2b521153fb382d418e30d18b59df", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/event-dispatcher": "^1" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Greg Sherwood", - "role": "Former lead" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" }, { - "name": "Juliette Reinders Folmer", - "role": "Current lead" + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", "keywords": [ - "phpcs", - "standards", - "static analysis" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", - "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", - "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", - "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" }, "funding": [ { - "url": "https://github.com/PHPCSStandards", + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", "type": "github" }, { - "url": "https://github.com/jrfnl", + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "983900d6fddf2b0cbaacacbbad07610854bd8112" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/983900d6fddf2b0cbaacacbbad07610854bd8112", + "reference": "983900d6fddf2b0cbaacacbbad07610854bd8112", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/service-contracts": "^2.5|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", "type": "github" }, { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "time": "2024-02-16T15:06:51+00:00" + "time": "2024-01-23T15:02:46+00:00" }, { "name": "theseer/tokenizer", diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 847eb5dc..00000000 --- a/phpcs.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - PHP School coding standard - - - - - - - - - - - - - - - - - - src - test - \ No newline at end of file diff --git a/src/Action/Admin/ClearCache.php b/src/Action/Admin/ClearCache.php index 6e42d715..4fd6f6af 100644 --- a/src/Action/Admin/ClearCache.php +++ b/src/Action/Admin/ClearCache.php @@ -1,5 +1,7 @@ $exercise->getName(), 'slug' => $this->slug($exercise->getName()), 'description' => $exercise->getDescription(), - 'type' => $exercise->getType() + 'type' => $exercise->getType()->getValue() ], 'problem' => $this->problemFileConverter->htmlFromExercise($exercise), 'totalExerciseCount' => $this->installedWorkshops->totalExerciseCount(), @@ -137,7 +137,7 @@ private function addInitialCode(array $data, ExerciseInterface $exercise): array } $data['initial_files'] = array_map( - fn (SolutionFile $file) => [ + fn(SolutionFile $file) => [ 'name' => $file->getRelativePath(), 'content' => $file->getContents(), ], diff --git a/src/Action/Online/Workshops.php b/src/Action/Online/Workshops.php index f7bdd979..dfeab990 100644 --- a/src/Action/Online/Workshops.php +++ b/src/Action/Online/Workshops.php @@ -1,5 +1,7 @@ |string>> $errors */ - public function __construct(private array $errors) - { - } + public function __construct(private array $errors) {} /** * @return array|string>> diff --git a/src/Form/FormHandler.php b/src/Form/FormHandler.php index 2d4890c7..6d9562ae 100644 --- a/src/Form/FormHandler.php +++ b/src/Form/FormHandler.php @@ -1,9 +1,10 @@ findAll()) - ->map(fn (CloudInstalledWorkshop $worksop) => count($worksop->findAllExercises())) + ->map(fn(CloudInstalledWorkshop $workshop) => count($workshop->findAllExercises())) ->sum(); return $total; diff --git a/src/Online/Command/DownloadComposerPackageList.php b/src/Online/Command/DownloadComposerPackageList.php index 182bb750..a9190f64 100644 --- a/src/Online/Command/DownloadComposerPackageList.php +++ b/src/Online/Command/DownloadComposerPackageList.php @@ -1,5 +1,7 @@ workshopState) ->pluck('completedExercises') - ->map(fn (array $completed) => count($completed)) + ->map(fn(array $completed) => count($completed)) ->sum(); return $total; diff --git a/src/Online/StudentWorkshopState.php b/src/Online/StudentWorkshopState.php index 72edf91f..06b40339 100644 --- a/src/Online/StudentWorkshopState.php +++ b/src/Online/StudentWorkshopState.php @@ -1,10 +1,11 @@ $data */ - public function __construct(private array $data = []) - { - } + public function __construct(private array $data = []) {} public function get(string $key, mixed $default = null): mixed { diff --git a/src/User/DoctrineORMStudentRepository.php b/src/User/DoctrineORMStudentRepository.php index 13c9043c..99447a8c 100644 --- a/src/User/DoctrineORMStudentRepository.php +++ b/src/User/DoctrineORMStudentRepository.php @@ -1,5 +1,7 @@ phpSchoolEmail = $phpSchoolEmail; } - public function approved(Workshop $workshop): void - { - } + public function approved(Workshop $workshop): void {} - public function new(Workshop $workshop): void - { - } + public function new(Workshop $workshop): void {} } diff --git a/src/WorkshopFeed.php b/src/WorkshopFeed.php index 944036fc..2d234835 100644 --- a/src/WorkshopFeed.php +++ b/src/WorkshopFeed.php @@ -1,5 +1,7 @@ ['error2'], ] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -114,7 +114,7 @@ public function testSubmitReturnsErrorResponseIfWorkshopCannotBeCreated(): void 'field2' => ['error2'], ] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -162,7 +162,7 @@ public function testErrorIsLoggedIfEmailNotificationEmailNotSent(): void $this->assertEquals(200, $actualResponse->getStatusCode()); $this->assertEquals('application/json', $actualResponse->getHeaderLine('Content-Type')); - $this->assertEquals(['success' => true], json_decode($actualResponse->getBody(), true)); + $this->assertEquals(['success' => true], json_decode($actualResponse->getBody()->__toString(), true)); $this->assertTrue($logger->hasErrorThatContains('Email could not be sent. Error: "Could not send"')); } @@ -204,7 +204,7 @@ public function testSuccessfulCreation(): void $this->assertEquals(200, $actualResponse->getStatusCode()); $this->assertEquals('application/json', $actualResponse->getHeaderLine('Content-Type')); - $this->assertEquals(['success' => true], json_decode($actualResponse->getBody(), true)); + $this->assertEquals(['success' => true], json_decode($actualResponse->getBody()->__toString(), true)); $this->assertEmpty($logger->records); } } diff --git a/test/Action/TrackDownloadsTest.php b/test/Action/TrackDownloadsTest.php index 392dd915..5ec1123c 100644 --- a/test/Action/TrackDownloadsTest.php +++ b/test/Action/TrackDownloadsTest.php @@ -1,5 +1,7 @@ 'error', 'message' => 'Workshop: "non-existent-workshop" not found.' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -86,6 +88,6 @@ public function testNewWorkshopInstallIsCreated(): void $this->assertEquals(200, $actualResponse->getStatusCode()); $this->assertEquals('application/json', $actualResponse->getHeaderLine('Content-Type')); - $this->assertEquals(['success' => true], json_decode($actualResponse->getBody(), true)); + $this->assertEquals(['success' => true], json_decode($actualResponse->getBody()->__toString(), true)); } } diff --git a/test/Asset/CliExerciseImpl.php b/test/Asset/CliExerciseImpl.php index ef59ea16..db3c87cc 100644 --- a/test/Asset/CliExerciseImpl.php +++ b/test/Asset/CliExerciseImpl.php @@ -1,11 +1,12 @@ false, 'error' => 'Cannot find workshop' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -83,7 +85,7 @@ public function testErrorIsReturnedIfExerciseDoesNotExist(): void 'success' => false, 'error' => 'Cannot find exercise' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -112,7 +114,7 @@ public function testErrorIsReturnedIfUploaderThrowsException(): void 'success' => false, 'error' => 'Some error' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -149,7 +151,7 @@ public function testWithDefaultEntryPoint(): void 'success' => true, 'runs' => [] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); $this->assertFileDoesNotExist($solution->getBaseDirectory()); } @@ -188,7 +190,7 @@ public function testRunFail(): void 'success' => false, 'runs' => [] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); $this->assertFileDoesNotExist($solution->getBaseDirectory()); } diff --git a/test/Cloud/Action/TourCompleteTest.php b/test/Cloud/Action/TourCompleteTest.php index 47a7298e..3320df9c 100644 --- a/test/Cloud/Action/TourCompleteTest.php +++ b/test/Cloud/Action/TourCompleteTest.php @@ -1,5 +1,7 @@ __invoke($this->createMock(ServerRequestInterface::class), new Response()); - $this->assertEquals(['success' => true], json_decode($response->getBody(), true)); + $this->assertEquals(['success' => true], json_decode($response->getBody()->__toString(), true)); } } diff --git a/test/Cloud/Action/VerifyExerciseTest.php b/test/Cloud/Action/VerifyExerciseTest.php index f078bf9e..0a956770 100644 --- a/test/Cloud/Action/VerifyExerciseTest.php +++ b/test/Cloud/Action/VerifyExerciseTest.php @@ -1,5 +1,7 @@ false, 'error' => 'Cannot find workshop' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -88,7 +90,7 @@ public function testErrorIsReturnedIfExerciseDoesNotExist(): void 'success' => false, 'error' => 'Cannot find exercise' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -117,7 +119,7 @@ public function testErrorIsReturnedIfUploaderThrowsException(): void 'success' => false, 'error' => 'Some error' ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); } @@ -156,7 +158,7 @@ public function testWithDefaultEntryPoint(): void 'success' => true, 'results' => [] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); $this->assertFileDoesNotExist($solution->getBaseDirectory()); } @@ -196,7 +198,7 @@ public function testWithCustomEntryPoint(): void 'success' => true, 'results' => [] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); $this->assertFileDoesNotExist($solution->getBaseDirectory()); } @@ -239,7 +241,7 @@ public function testVerifyFail(): void 'success' => false, 'results' => [] ], - json_decode($actualResponse->getBody(), true) + json_decode($actualResponse->getBody()->__toString(), true) ); $this->assertFileDoesNotExist($solution->getBaseDirectory()); } diff --git a/test/Cloud/CloudInstalledWorkshopTest.php b/test/Cloud/CloudInstalledWorkshopTest.php index e7bdb11c..3273d991 100644 --- a/test/Cloud/CloudInstalledWorkshopTest.php +++ b/test/Cloud/CloudInstalledWorkshopTest.php @@ -1,5 +1,7 @@ $f->getAbsolutePath(), $result->getFiles()) + array_map(fn(SolutionFile $f) => $f->getAbsolutePath(), $result->getFiles()) ); $this->assertFileExists($path . '/solution.php'); @@ -216,7 +215,7 @@ public function testComposerDependenciesAreInstalledIfDependenciesAreSpecified() $this->assertEquals( [$path . '/composer.json', $path . '/solution.php'], - array_map(fn (SolutionFile $f) => $f->getAbsolutePath(), $result->getFiles()) + array_map(fn(SolutionFile $f) => $f->getAbsolutePath(), $result->getFiles()) ); $this->assertFileExists($path . '/solution.php'); @@ -266,7 +265,7 @@ public function testWithAlternateEntryPoint(): void $path . '/folder/nested/file3.php', $path . '/program.php', ], - array_map(fn (SolutionFile $f) => $f->getAbsolutePath(), $result->getFiles()) + array_map(fn(SolutionFile $f) => $f->getAbsolutePath(), $result->getFiles()) ); $this->assertFileExists($path . '/program.php'); diff --git a/test/Cloud/StudentCloudStateTest.php b/test/Cloud/StudentCloudStateTest.php index c0e90f76..e847fd84 100644 --- a/test/Cloud/StudentCloudStateTest.php +++ b/test/Cloud/StudentCloudStateTest.php @@ -1,5 +1,7 @@ function () { - return new class { + return new class () { public $name = 'my-service'; }; }, diff --git a/test/InputFilter/EventTest.php b/test/InputFilter/EventTest.php index 79fcaa65..53446780 100644 --- a/test/InputFilter/EventTest.php +++ b/test/InputFilter/EventTest.php @@ -1,5 +1,7 @@ assertEquals( ['Event 5', 'Event 4', 'Event 3', 'Event 2', 'Event 1'], - array_map(fn (Event $event) => $event->getName(), $events) + array_map(fn(Event $event) => $event->getName(), $events) ); } @@ -31,7 +33,7 @@ public function testFindUpcomingEventsReturnsOnlyEventsInTheFuture(): void $this->assertEquals( ['Event 6', 'Event 7', 'Event 8', 'Event 9', 'Event 10'], - array_map(fn (Event $event) => $event->getName(), $events) + array_map(fn(Event $event) => $event->getName(), $events) ); } @@ -45,7 +47,7 @@ public function testFindAll(): void $this->assertEquals( ['Event 10', 'Event 9', 'Event 8', 'Event 7', 'Event 6', 'Event 5', 'Event 4', 'Event 3', 'Event 2', 'Event 1'], - array_map(fn (Event $event) => $event->getName(), $events) + array_map(fn(Event $event) => $event->getName(), $events) ); } @@ -63,7 +65,7 @@ public function testFindById(): void $this->assertEquals( 'Event 1', - $this->getRepository(Event::class)->findById($fixture->event1Id)->getName() + $this->getRepository(Event::class)->findById($fixture->event1Id->toString())->getName() ); } @@ -103,7 +105,7 @@ public function testRemove(): void $this->assertEquals( ['Event 10', 'Event 9', 'Event 8', 'Event 7', 'Event 6', 'Event 5', 'Event 4', 'Event 3', 'Event 2'], - array_map(fn (Event $event) => $event->getName(), $events) + array_map(fn(Event $event) => $event->getName(), $events) ); } } diff --git a/test/Repository/DoctrineORMRepositoryTest.php b/test/Repository/DoctrineORMRepositoryTest.php index 59f8afb4..e272c036 100644 --- a/test/Repository/DoctrineORMRepositoryTest.php +++ b/test/Repository/DoctrineORMRepositoryTest.php @@ -1,5 +1,7 @@ assertEquals( 'learnyouphp', - $this->getRepository(Workshop::class)->findById($fixture->learnYouPhpId)->getCode() + $this->getRepository(Workshop::class)->findById($fixture->learnYouPhpId->toString())->getCode() ); } diff --git a/test/Repository/Fixtures/ApprovedAndUnApprovedWorkshops.php b/test/Repository/Fixtures/ApprovedAndUnApprovedWorkshops.php index c823de37..27a06529 100644 --- a/test/Repository/Fixtures/ApprovedAndUnApprovedWorkshops.php +++ b/test/Repository/Fixtures/ApprovedAndUnApprovedWorkshops.php @@ -1,5 +1,7 @@ assertNull($session->get('a')); } -// public function testDestroy(): void -// { -// @session_start(); -// $this->assertEquals(PHP_SESSION_ACTIVE, session_status()); -// @Session::destroy(); // silence headers already sent warning -// $this->assertEquals(PHP_SESSION_NONE, session_status()); -// } + // public function testDestroy(): void + // { + // @session_start(); + // $this->assertEquals(PHP_SESSION_ACTIVE, session_status()); + // @Session::destroy(); // silence headers already sent warning + // $this->assertEquals(PHP_SESSION_NONE, session_status()); + // } } diff --git a/test/User/StudentDTOTest.php b/test/User/StudentDTOTest.php index b1666290..f2f6cc53 100644 --- a/test/User/StudentDTOTest.php +++ b/test/User/StudentDTOTest.php @@ -1,5 +1,7 @@