From 9c7fd4864b6abcb74beba4577dc44e6a6739a4c2 Mon Sep 17 00:00:00 2001 From: Barney Hanlon <445227+shrikeh@users.noreply.github.com> Date: Mon, 30 May 2022 18:47:27 +0100 Subject: [PATCH] Get ready for general use --- .env | 11 +- Makefile | 1 + app/config/packages/doctrine.prod.yaml | 16 +- .../packages/doctrine_migrations.prod.yaml | 2 +- app/config/packages/translation.yaml | 13 ++ app/config/services.yaml | 10 +- app/data/health.sql | 38 ++++ app/migrations/.gitignore | 0 app/migrations/Version20220530155854.php | 36 ++++ .../DependencyCheck/DatabaseCheck.php | 31 ++- ...cyRepository.php => DatabaseUserCheck.php} | 3 +- .../Exception/NoDatabaseChecksProvided.php | 17 ++ .../DatabaseCheck/ReadUserCheck.php | 47 +++++ .../DatabaseCheck/WriteUserCheck.php | 50 +++++ .../{ => RandomOrgCheck}/RandomApiHealth.php | 2 +- app/translations/.gitignore | 0 composer.lock | 12 +- docker-compose.yml | 31 +-- docker/services/bundle/Dockerfile | 1 + docs/DEPENDENCY-CHECKS.md | 188 +++++++++++++++++- src/ApplicationHealth/Dependencies.php | 3 + .../Exception/NoDependencyChecks.php | 3 + .../SimpleReportFactory.php | 3 + .../Dependencies/SimpleDependencies.php | 3 + .../HealthReportFactory.php | 3 + src/ApplicationHealth/DependencyCheck.php | 3 + .../Exception/ApplicationHealthError.php | 3 + src/ApplicationHealth/HealthReport.php | 3 + .../HealthReport/DependencyStatus.php | 3 + .../DependencyStatus/SimpleStatus.php | 3 + .../Exception/NoDependencyStatuses.php | 3 + .../HealthReport/SimpleHealthReport.php | 3 + src/Console/Command/CheckHealth.php | 5 +- .../Factory/ResultFormatterFactory.php | 3 + .../StyledOutputFactory.php | 3 + src/CushonHealthBundle.php | 1 + .../CushonHealthExtension.php | 3 + src/Encoder/Json/Encoder.php | 3 + src/Encoder/Json/SafeJson.php | 5 +- src/Formatter/Console.php | 3 + src/Formatter/Console/StyledOutput.php | 6 +- .../StyledOutput/ApplicationStatus.php | 3 + .../ApplicationStatus/StatusSection.php | 3 + .../Console/StyledOutput/Dependency.php | 3 + .../Dependency/DependencyTable.php | 7 +- .../DependencyTable/DependencyRowFactory.php | 3 + .../DependencyTable/TableHeaderFactory.php | 3 + .../StyledOutput/Dependency/Mapper.php | 3 + .../Exception/UnableToMapDependency.php | 3 + .../Dependency/Mapper/SimpleMapper.php | 5 +- src/Handler/CheckHealth.php | 3 + .../CheckHealth/DefaultHealthCheck.php | 3 + .../ApplicationHealthCheckFailure.php | 3 + .../Exception/CheckHealthHandlerError.php | 3 + src/Handler/CheckHealth/Logger.php | 3 + src/Handler/CheckHealth/Logger/PsrLogger.php | 5 +- src/Handler/CheckHealth/ResultFactory.php | 3 + .../ResultFactory/DefaultResultFactory.php | 3 + src/Message/Query/HealthCheck.php | 3 + .../HealthCheck/DefaultHealthCheckQuery.php | 3 + .../Exception/QueryFactoryException.php | 3 + src/Message/QueryFactory/QueryFactory.php | 3 + .../ServiceContainerHealthCheck.php | 3 + .../Exception/IncorrectQueryType.php | 3 + .../QueryServiceDefinitionNotFound.php | 3 + src/Message/Result/HealthCheck.php | 3 + src/Message/Result/HealthCheck/Healthy.php | 2 + src/Message/Result/HealthCheck/Unhealthy.php | 2 + src/Message/Result/Traits/DependencyTrait.php | 3 + .../Result/Traits/JsonSerializableTrait.php | 3 + src/QueryBus/Exception/QueryBusError.php | 3 + .../Exception/ResultAssertionFailed.php | 3 + .../Exception/SymfonyMessengerError.php | 3 + src/QueryBus/HealthCheckQueryBus.php | 3 + src/QueryBus/MessengerHealthQueryBus.php | 3 + src/QueryBus/ResultAssertion.php | 3 + .../ResultAssertion/DefaultAssertion.php | 3 + .../Exception/AssertionError.php | 3 + .../ResultClassOrInterfaceNotFound.php | 3 + .../ResultTypeClassDoesNotMatchExpected.php | 3 + .../Exception/UnexpectedResultType.php | 3 + src/Traits/BundleRootKeyTrait.php | 3 + tests/behat/src/Context/Api.php | 3 + tests/behat/src/Context/Console.php | 3 + tests/behat/src/Context/MessageBus.php | 3 + .../Context/Traits/ProphecyContextTrait.php | 3 + .../Dependencies/SimpleDependenciesTest.php | 3 + .../Exception/NoDependencyStatusesTest.php | 3 + .../HealthReport/SimpleHealthReportTest.php | 3 + tests/unit/src/CushonHealthBundleTest.php | 3 + .../CushonHealthExtensionTest.php | 3 + tests/unit/src/Encoder/Json/SafeJsonTest.php | 3 + .../Console/Command/CheckHealthTest.php | 3 + .../StyledOutputFactoryTest.php | 3 + .../StatusSectionFormatterTest.php | 3 + .../DependencyRowFactoryTest.php | 3 + .../TableHeaderFactoryTest.php | 3 + .../Dependency/DependencyTableTest.php | 3 + .../Exception/UnableToMapDependencyTest.php | 3 + .../Dependency/Mapper/SimpleMapperTest.php | 3 + .../Formatter/Console/StyledOutputTest.php | 3 + .../CheckHealth/DefaultHealthCheckTest.php | 3 + .../ApplicationHealthCheckFailureTest.php | 3 + .../DefaultResultFactoryTest.php | 3 + .../unit/src/Handler/Logger/PsrLoggerTest.php | 3 + .../DefaultHealthCheckQueryTest.php | 3 + .../QueryServiceDefinitionNotFoundTest.php | 3 + .../Result/HealthCheck/HealthyTest.php | 3 + .../Traits/DependencyTraitTest.php | 3 + .../Traits/JsonSerializableTraitTest.php | 3 + .../Result/HealthCheck/UnhealthyTest.php | 3 + .../Exception/SymfonyMessengerErrorTest.php | 3 + .../Exception/UnexpectedResultTypeTest.php | 3 + .../QueryBus/MessengerHealthQueryBusTest.php | 3 + .../ResultAssertion/DefaultAssertionTest.php | 3 + 115 files changed, 750 insertions(+), 55 deletions(-) create mode 100644 app/config/packages/translation.yaml create mode 100644 app/data/health.sql create mode 100644 app/migrations/.gitignore create mode 100644 app/migrations/Version20220530155854.php rename app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/{HealthDependencyRepository.php => DatabaseUserCheck.php} (88%) create mode 100644 app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/Exception/NoDatabaseChecksProvided.php create mode 100644 app/src/Repository/DatabaseCheck/ReadUserCheck.php create mode 100644 app/src/Repository/DatabaseCheck/WriteUserCheck.php rename app/src/Repository/{ => RandomOrgCheck}/RandomApiHealth.php (98%) create mode 100644 app/translations/.gitignore diff --git a/.env b/.env index 6eee2f9..2e28fa1 100644 --- a/.env +++ b/.env @@ -26,6 +26,7 @@ APP_SECRET=e4fab8533e85795651f9963db77469ea # MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages # MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages ###< symfony/messenger ### +APP_ENV=test APP_CODE_DIR='/cushon/app' APP_BUILD_DIR=build APP_CACHE_DIR=build/cache/symfony @@ -33,11 +34,5 @@ APP_LOG_DIR=build/logs HOST_NGINX_PORT=9010 NULL_DEPENDENCY_NAME='A fake dependency' -###> doctrine/doctrine-bundle ### -# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url -# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml -# -# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" -# DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4" -DATABASE_URL="postgresql://symfony:ChangeMe@127.0.0.1:5432/app?serverVersion=13&charset=utf8" -###< doctrine/doctrine-bundle ### +DB_READ_PASSWORD=cushon_health_reader +DB_WRITE_PASSWORD=cushon_health_writer diff --git a/Makefile b/Makefile index 17b4bdb..4bda24a 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,7 @@ craft: .craft test quality console: .composer-console +health: APP_ENV = prod health: .composer-health brew: diff --git a/app/config/packages/doctrine.prod.yaml b/app/config/packages/doctrine.prod.yaml index 8cdce7f..c2afbf9 100644 --- a/app/config/packages/doctrine.prod.yaml +++ b/app/config/packages/doctrine.prod.yaml @@ -1,22 +1,22 @@ --- parameters: env(DB_READ_HOST): '127.0.0.1' - env(DB_READ_NAME): 'health_example' + env(DB_READ_NAME): 'cushon_health_test' env(DB_READ_USER): 'cushon_read' env(DB_READ_VERSION): 'mariadb-10.7.3' - env(DB_READ_PORT): 3306 + env(DB_READ_PORT): 33010 env(DB_WRITE_HOST): '127.0.0.1' - env(DB_WRITE_NAME): 'health_example' + env(DB_WRITE_NAME): 'cushon_health_test' env(DB_WRITE_USER): 'cushon_write' env(DB_WRITE_VERSION): 'mariadb-10.7.3' - env(DB_WRITE_PORT): 3306 + env(DB_WRITE_PORT): 33010 doctrine: dbal: - default_connection: default + default_connection: 'read' connections: - default: + read: # Connection used for read operations host: '%env(string:DB_READ_HOST)%' dbname: '%env(string:DB_READ_NAME)%' @@ -25,6 +25,8 @@ doctrine: server_version: '%env(string:DB_READ_VERSION)%' port: '%env(int:DB_READ_PORT)%' driver: 'pdo_mysql' + options: + LoginTimeout: 2 write: # Connection used for write operations host: '%env(string:DB_WRITE_HOST)%' @@ -34,4 +36,6 @@ doctrine: server_version: '%env(string:DB_WRITE_VERSION)%' port: '%env(int:DB_WRITE_PORT)%' driver: 'pdo_mysql' + options: + LoginTimeout: 2 diff --git a/app/config/packages/doctrine_migrations.prod.yaml b/app/config/packages/doctrine_migrations.prod.yaml index 2862b3e..946007b 100644 --- a/app/config/packages/doctrine_migrations.prod.yaml +++ b/app/config/packages/doctrine_migrations.prod.yaml @@ -4,5 +4,5 @@ doctrine_migrations: migrations_paths: # namespace is arbitrary but should be different from App\Migrations # as migrations classes should NOT be autoloaded - 'Example\DoctrineMigrations': '%kernel.project_dir%/migrations' + 'App\DoctrineMigrations': '%kernel.project_dir%/migrations' enable_profiler: '%kernel.debug%' diff --git a/app/config/packages/translation.yaml b/app/config/packages/translation.yaml new file mode 100644 index 0000000..abb76aa --- /dev/null +++ b/app/config/packages/translation.yaml @@ -0,0 +1,13 @@ +framework: + default_locale: en + translator: + default_path: '%kernel.project_dir%/translations' + fallbacks: + - en +# providers: +# crowdin: +# dsn: '%env(CROWDIN_DSN)%' +# loco: +# dsn: '%env(LOCO_DSN)%' +# lokalise: +# dsn: '%env(LOKALISE_DSN)%' diff --git a/app/config/services.yaml b/app/config/services.yaml index ce38e12..f69ffc5 100644 --- a/app/config/services.yaml +++ b/app/config/services.yaml @@ -14,7 +14,6 @@ services: _defaults: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. - # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: @@ -22,6 +21,15 @@ services: exclude: - '%kernel.project_dir%/src/{DependencyInjection/,Kernel.php}' + _instanceof: + App\ApplicationHealth\DependencyCheck\DatabaseCheck\DatabaseUserCheck: + tags: + - 'app.health.check.db' + + App\ApplicationHealth\DependencyCheck\DatabaseCheck: + arguments: + - !tagged_iterator app.health.check.db + # add more service definitions when explicit configuration is needed # please note that last definitions always *replace* previous ones App\ApplicationHealth\DependencyCheck\NullDependencyCheck: diff --git a/app/data/health.sql b/app/data/health.sql new file mode 100644 index 0000000..87fc155 --- /dev/null +++ b/app/data/health.sql @@ -0,0 +1,38 @@ +-- MariaDB dump 10.19 Distrib 10.7.3-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: uuid_example +-- ------------------------------------------------------ +-- Server version 10.7.3-MariaDB-1:10.7.3+maria~focal + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +CREATE SCHEMA IF NOT EXISTS cushon_health_test; + +CREATE USER 'cushon_read'@'%'; +CREATE USER 'cushon_write'@'%'; + +GRANT ALL PRIVILEGES ON `cushon_health_test`.* TO 'cushon_write'@'%' IDENTIFIED BY 'cushon_health_writer'; +GRANT SELECT ON `cushon_health_test`.* TO 'cushon_read'@'%' IDENTIFIED BY 'cushon_health_reader'; + +FLUSH PRIVILEGES; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2022-03-23 15:47:25 diff --git a/app/migrations/.gitignore b/app/migrations/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/app/migrations/Version20220530155854.php b/app/migrations/Version20220530155854.php new file mode 100644 index 0000000..8764dd5 --- /dev/null +++ b/app/migrations/Version20220530155854.php @@ -0,0 +1,36 @@ +createTable('health'); + $health->addColumn( + 'last_checked', + Types::DATETIME_IMMUTABLE + ); + + } + + public function down(Schema $schema): void + { + $schema->dropTable('health'); + } +} diff --git a/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck.php b/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck.php index 0e0c62c..5dae5ab 100644 --- a/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck.php +++ b/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck.php @@ -1,24 +1,35 @@ + */ private Set $dependencyRepositories; /** - * @param HealthDependencyRepository ...$dependencyRepositories + * @param iterable $dependencyRepositories */ - public function __construct(HealthDependencyRepository ...$dependencyRepositories) + public function __construct(iterable $dependencyRepositories) { - $this->dependencyRepositories = new Set($dependencyRepositories); + $this->dependencyRepositories = new Set(); + foreach ($dependencyRepositories as $dependencyRepository) { + $this->addDatabaseUserCheck($dependencyRepository); + } + + if (!$this->dependencyRepositories->count()) { + throw NoDatabaseChecksProvided::create(); + } } /** @@ -26,9 +37,17 @@ public function __construct(HealthDependencyRepository ...$dependencyRepositorie */ public function check(): Generator { - /** @var HealthDependencyRepository $dependencyRepository */ foreach ($this->dependencyRepositories as $dependencyRepository) { yield $dependencyRepository->checkUser(); } } + + /** + * @param DatabaseUserCheck $databaseUserChecks + * @return void + */ + private function addDatabaseUserCheck(DatabaseUserCheck $databaseUserChecks): void + { + $this->dependencyRepositories->add($databaseUserChecks); + } } diff --git a/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/HealthDependencyRepository.php b/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/DatabaseUserCheck.php similarity index 88% rename from app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/HealthDependencyRepository.php rename to app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/DatabaseUserCheck.php index 946b31e..9f00625 100644 --- a/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/HealthDependencyRepository.php +++ b/app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/DatabaseUserCheck.php @@ -1,11 +1,12 @@ connection = $readConnection; + } + + /** + * @inheritDoc + */ + public function checkUser(): DependencyStatus + { + $healthy = false; + try { + $this->connection->createQueryBuilder() + ->select('last_checked') + ->from('health') + ->executeQuery(); + $healthy = true; + $info = null; + } catch (Exception $e) { + $info = $e->getMessage(); + } + + return new SimpleStatus('DB read user', $healthy, $info); + } +} diff --git a/app/src/Repository/DatabaseCheck/WriteUserCheck.php b/app/src/Repository/DatabaseCheck/WriteUserCheck.php new file mode 100644 index 0000000..c69000e --- /dev/null +++ b/app/src/Repository/DatabaseCheck/WriteUserCheck.php @@ -0,0 +1,50 @@ +connection = $writeConnection; + } + + /** + * @inheritDoc + */ + public function checkUser(): DependencyStatus + { + $health = false; + try { + $this->connection->createQueryBuilder() + ->insert('health') + ->setValue('last_checked', ':now') + ->setParameter('now', new DateTimeImmutable(), Types::DATETIME_IMMUTABLE) + ->executeStatement(); + $health = true; + $info = null; + } catch (Exception $e) { + $info = $e->getMessage(); + } + + return new SimpleStatus('DB write user', $health, $info); + } +} diff --git a/app/src/Repository/RandomApiHealth.php b/app/src/Repository/RandomOrgCheck/RandomApiHealth.php similarity index 98% rename from app/src/Repository/RandomApiHealth.php rename to app/src/Repository/RandomOrgCheck/RandomApiHealth.php index d6f32f3..83382e1 100644 --- a/app/src/Repository/RandomApiHealth.php +++ b/app/src/Repository/RandomOrgCheck/RandomApiHealth.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Repository; +namespace App\Repository\RandomOrgCheck; use App\ApplicationHealth\DependencyCheck\RandomOrgApiCheck\HealthDependencyRepository; use App\Repository\Exception\ResponseNotOk; diff --git a/app/translations/.gitignore b/app/translations/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/composer.lock b/composer.lock index c2f2bfc..0d76ba8 100644 --- a/composer.lock +++ b/composer.lock @@ -6603,16 +6603,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.7.3", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "48c4621b1a6dde32aab2e9a79658b843ffb614f7" + "reference": "dfb81bf8d11e96bb5b51cf6e70ccb817a4b23be7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/48c4621b1a6dde32aab2e9a79658b843ffb614f7", - "reference": "48c4621b1a6dde32aab2e9a79658b843ffb614f7", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dfb81bf8d11e96bb5b51cf6e70ccb817a4b23be7", + "reference": "dfb81bf8d11e96bb5b51cf6e70ccb817a4b23be7", "shasum": "" }, "require": { @@ -6638,7 +6638,7 @@ "description": "PHPStan - PHP Static Analysis Tool", "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.7.3" + "source": "https://github.com/phpstan/phpstan/tree/1.7.5" }, "funding": [ { @@ -6658,7 +6658,7 @@ "type": "tidelift" } ], - "time": "2022-05-29T11:36:09+00:00" + "time": "2022-05-30T16:14:54+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/docker-compose.yml b/docker-compose.yml index c0a8b12..5662d2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,10 @@ services: APP_CACHE_DIR: '/cache' APP_LOG_DIR: '/cushon/build/logs/symfony' APP_ENV: "${APP_ENV}" + DB_READ_HOST: 'db' + DB_WRITE_HOST: 'db' + DB_WRITE_PORT: 3306 + DB_READ_PORT: 3306 restart: unless-stopped volumes: - ./:/cushon @@ -29,6 +33,19 @@ services: restart: unless-stopped ports: - "${HOST_NGINX_PORT:?err}:${NGINX_PORT:-8080}" + db: + image: mariadb:10.7.3-focal + restart: always + environment: + MYSQL_ROOT_PASSWORD: "lets_all_stay_healthy" + networks: + - app + volumes: + - db-data:/var/lib/mysql:rw + # This inserts the read and write users for the Symfony app + - ./app/data:/docker-entrypoint-initdb.d + ports: + - '33010:3306' blackfire: image: blackfire/blackfire:2 ports: [ "8307" ] @@ -41,20 +58,6 @@ services: BLACKFIRE_DISABLE_LEGACY_PORT: 'true' networks: - app - -###> doctrine/doctrine-bundle ### - database: - image: postgres:${POSTGRES_VERSION:-13}-alpine - environment: - POSTGRES_DB: ${POSTGRES_DB:-app} - # You should definitely change the password in production - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-ChangeMe} - POSTGRES_USER: ${POSTGRES_USER:-symfony} - volumes: - - db-data:/var/lib/postgresql/data:rw - # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - # - ./docker/db/data:/var/lib/postgresql/data:rw -###< doctrine/doctrine-bundle ### networks: app: diff --git a/docker/services/bundle/Dockerfile b/docker/services/bundle/Dockerfile index 484f0ec..34893c3 100644 --- a/docker/services/bundle/Dockerfile +++ b/docker/services/bundle/Dockerfile @@ -3,6 +3,7 @@ RUN apk update RUN apk add gcc autoconf ca-certificates RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} RUN pecl install -o -f ds pcov pcntl posix +RUN docker-php-ext-install pdo_mysql opcache RUN docker-php-ext-enable opcache ds pcov FROM base AS composer diff --git a/docs/DEPENDENCY-CHECKS.md b/docs/DEPENDENCY-CHECKS.md index 1272c6d..bcbecae 100644 --- a/docs/DEPENDENCY-CHECKS.md +++ b/docs/DEPENDENCY-CHECKS.md @@ -36,8 +36,194 @@ All Dependency Checks should implement the interface `Cushon\HealthBundle\Applic #### A Database Dependency Check Using Doctrine -In this example, we use the well-known Doctrine Database Abstraction Layer (DBAL) to test that all the users can read and write to the database as required. This example requires the Doctrine migrations to be run before it will behave as expected. +In this example, we use the well-known Doctrine Database Abstraction Layer (DBAL) to test that all the users can read and write to the database as required. This example requires the Doctrine migrations to be run before it will behave as expected. You should also bring up the docker services, which will populate an empty schema and two users (read and write) for you: +```bash +> make up +Bringing up services... +Creating network "cushon-health-bundle_app" with the default driver +Creating cushon-health-bundle_nginx_1 ... done +Creating cushon-health-bundle_bundle_1 ... done +Creating cushon-health-bundle_db_1 ... done +Creating cushon-health-bundle_blackfire_1 ... done + +> app/bin/console doctrine:migrations:migrate +WARNING! You are about to execute a migration in database "cushon_health_test" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]: +> y + +[notice] Migrating up to App\DoctrineMigrations\Version20220530155854 +[notice] finished in 77.9ms, used 16M memory, 1 migrations executed, 1 sql queries +``` +The above creates a very simple table called `health` with one column `last_checked`. Obviously, the read and write user should be the same users used for core application functionality, or you may miss that there actually is a problem. + +Using Symfony's autwiring and the Symfony Doctrine bundle, let's create a simple configuration in `doctrine.yaml`: + +```yaml +--- +parameters: + env(DB_READ_HOST): '127.0.0.1' + env(DB_READ_NAME): 'cushon_health_test' + env(DB_READ_USER): 'cushon_read' + env(DB_READ_VERSION): 'mariadb-10.7.3' + env(DB_READ_PORT): 33010 + + env(DB_WRITE_HOST): '127.0.0.1' + env(DB_WRITE_NAME): 'cushon_health_test' + env(DB_WRITE_USER): 'cushon_write' + env(DB_WRITE_VERSION): 'mariadb-10.7.3' + env(DB_WRITE_PORT): 33010 + +doctrine: + dbal: + default_connection: 'read' + connections: + read: + # Connection used for read operations + host: '%env(string:DB_READ_HOST)%' + dbname: '%env(string:DB_READ_NAME)%' + user: '%env(string:DB_READ_USER)%' + password: '%env(string:DB_READ_PASSWORD)%' + server_version: '%env(string:DB_READ_VERSION)%' + port: '%env(int:DB_READ_PORT)%' + driver: 'pdo_mysql' + + write: + # Connection used for write operations + host: '%env(string:DB_WRITE_HOST)%' + dbname: '%env(string:DB_WRITE_NAME)%' + user: '%env(string:DB_WRITE_USER)%' + password: '%env(string:DB_WRITE_PASSWORD)%' + server_version: '%env(string:DB_WRITE_VERSION)%' + port: '%env(int:DB_WRITE_PORT)%' + driver: 'pdo_mysql' +``` +Here we use environmentals to keep it inline with the 12-Factor Application principle, but add some sensible defaults to the environment variables. + +Next, we create two very simple wrappers to test the connections: + +```php +connection = $writeConnection; + } + + /** + * @inheritDoc + */ + public function checkUser(): DependencyStatus + { + $health = false; + try { + $this->connection->createQueryBuilder() + ->insert('health') + ->setValue('last_checked', ':now') + ->setParameter('now', new DateTimeImmutable(), Types::DATETIME_IMMUTABLE) + ->executeStatement(); + $health = true; + $info = null; + } catch (Exception $e) { + $info = $e->getMessage(); + } + + return new SimpleStatus('DB write user', $health, $info); + } +} +``` +We will skip the example of the read user check for the sake of keeping this example less verbose,but the class exists in the example app. +Next, we tag all the repositories implementing the `DatabaseUserCheck` interface, so we can easily pass them to our database check. Updating our `services.yaml` with an `_instanceof` service definition: + +```yaml + _instanceof: + App\ApplicationHealth\DependencyCheck\DatabaseCheck\DatabaseUserCheck: + tags: + - 'app.health.check.db' + + App\ApplicationHealth\DependencyCheck\DatabaseCheck: + arguments: + - !tagged_iterator app.health.check.db +``` +Our CQRS-style health check can now be fairly straightforward. We add a few guards to ensure that it must have at least one database check in the constructor: + +```php + + */ + private Set $dependencyRepositories; + + /** + * @param iterable $dependencyRepositories + */ + public function __construct(iterable $dependencyRepositories) + { + $this->dependencyRepositories = new Set(); + foreach ($dependencyRepositories as $dependencyRepository) { + $this->addDatabaseUserCheck($dependencyRepository); + } + + if (!$this->dependencyRepositories->count()) { + throw NoDatabaseChecksProvided::create(); + } + } + + /** + * @inheritDoc + */ + public function check(): Generator + { + foreach ($this->dependencyRepositories as $dependencyRepository) { + yield $dependencyRepository->checkUser(); + } + } + + /** + * @param DatabaseUserCheck $databaseUserChecks + * @return void + */ + private function addDatabaseUserCheck(DatabaseUserCheck $databaseUserChecks): void + { + $this->dependencyRepositories->add($databaseUserChecks); + } +} + +``` diff --git a/src/ApplicationHealth/Dependencies.php b/src/ApplicationHealth/Dependencies.php index 40f85ee..c27084a 100644 --- a/src/ApplicationHealth/Dependencies.php +++ b/src/ApplicationHealth/Dependencies.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\ApplicationHealth\Exception\ApplicationHealthError; +/** + * @author Barney Hanlon + */ interface Dependencies { /** diff --git a/src/ApplicationHealth/Dependencies/Exception/NoDependencyChecks.php b/src/ApplicationHealth/Dependencies/Exception/NoDependencyChecks.php index 65467b2..5fdbe42 100644 --- a/src/ApplicationHealth/Dependencies/Exception/NoDependencyChecks.php +++ b/src/ApplicationHealth/Dependencies/Exception/NoDependencyChecks.php @@ -6,6 +6,9 @@ use DomainException; +/** + * @author Barney Hanlon + */ final class NoDependencyChecks extends DomainException { /** diff --git a/src/ApplicationHealth/Dependencies/HealthReportFactory/SimpleReportFactory.php b/src/ApplicationHealth/Dependencies/HealthReportFactory/SimpleReportFactory.php index b627387..d4db5d7 100644 --- a/src/ApplicationHealth/Dependencies/HealthReportFactory/SimpleReportFactory.php +++ b/src/ApplicationHealth/Dependencies/HealthReportFactory/SimpleReportFactory.php @@ -8,6 +8,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; use Cushon\HealthBundle\ApplicationHealth\HealthReport\SimpleHealthReport; +/** + * @author Barney Hanlon + */ final class SimpleReportFactory implements HealthReportFactory { /** diff --git a/src/ApplicationHealth/Dependencies/SimpleDependencies.php b/src/ApplicationHealth/Dependencies/SimpleDependencies.php index 389a0bf..e501395 100644 --- a/src/ApplicationHealth/Dependencies/SimpleDependencies.php +++ b/src/ApplicationHealth/Dependencies/SimpleDependencies.php @@ -13,6 +13,9 @@ use Ds\Set; use Generator; +/** + * @author Barney Hanlon + */ final class SimpleDependencies implements Dependencies { /** diff --git a/src/ApplicationHealth/Dependencies/Simpledependencies/HealthReportFactory.php b/src/ApplicationHealth/Dependencies/Simpledependencies/HealthReportFactory.php index 65bf0bf..d47ec66 100644 --- a/src/ApplicationHealth/Dependencies/Simpledependencies/HealthReportFactory.php +++ b/src/ApplicationHealth/Dependencies/Simpledependencies/HealthReportFactory.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport; use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; +/** + * @author Barney Hanlon + */ interface HealthReportFactory { /** diff --git a/src/ApplicationHealth/DependencyCheck.php b/src/ApplicationHealth/DependencyCheck.php index 7447831..09336df 100644 --- a/src/ApplicationHealth/DependencyCheck.php +++ b/src/ApplicationHealth/DependencyCheck.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; use Generator; +/** + * @author Barney Hanlon + */ interface DependencyCheck { /** diff --git a/src/ApplicationHealth/Exception/ApplicationHealthError.php b/src/ApplicationHealth/Exception/ApplicationHealthError.php index 7b19f1d..82506b6 100644 --- a/src/ApplicationHealth/Exception/ApplicationHealthError.php +++ b/src/ApplicationHealth/Exception/ApplicationHealthError.php @@ -6,6 +6,9 @@ use Throwable; +/** + * @author Barney Hanlon + */ interface ApplicationHealthError extends Throwable { } diff --git a/src/ApplicationHealth/HealthReport.php b/src/ApplicationHealth/HealthReport.php index 834cf99..cec65a2 100644 --- a/src/ApplicationHealth/HealthReport.php +++ b/src/ApplicationHealth/HealthReport.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; +/** + * @author Barney Hanlon + */ interface HealthReport { /** diff --git a/src/ApplicationHealth/HealthReport/DependencyStatus.php b/src/ApplicationHealth/HealthReport/DependencyStatus.php index c8be2bb..bc67708 100644 --- a/src/ApplicationHealth/HealthReport/DependencyStatus.php +++ b/src/ApplicationHealth/HealthReport/DependencyStatus.php @@ -6,6 +6,9 @@ use JsonSerializable; +/** + * @author Barney Hanlon + */ interface DependencyStatus extends JsonSerializable { public const KEY_NAME = 'name'; diff --git a/src/ApplicationHealth/HealthReport/DependencyStatus/SimpleStatus.php b/src/ApplicationHealth/HealthReport/DependencyStatus/SimpleStatus.php index 9157033..56afe37 100644 --- a/src/ApplicationHealth/HealthReport/DependencyStatus/SimpleStatus.php +++ b/src/ApplicationHealth/HealthReport/DependencyStatus/SimpleStatus.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; +/** + * @author Barney Hanlon + */ final class SimpleStatus implements DependencyStatus { public const KEY_INFO = 'info'; diff --git a/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatuses.php b/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatuses.php index 1439686..3d99fea 100644 --- a/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatuses.php +++ b/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatuses.php @@ -6,6 +6,9 @@ use InvalidArgumentException; +/** + * @author Barney Hanlon + */ final class NoDependencyStatuses extends InvalidArgumentException { /** diff --git a/src/ApplicationHealth/HealthReport/SimpleHealthReport.php b/src/ApplicationHealth/HealthReport/SimpleHealthReport.php index 43fa151..8c38257 100644 --- a/src/ApplicationHealth/HealthReport/SimpleHealthReport.php +++ b/src/ApplicationHealth/HealthReport/SimpleHealthReport.php @@ -8,6 +8,9 @@ use Ds\Set; use Generator; +/** + * @author Barney Hanlon + */ final class SimpleHealthReport implements HealthReport { private bool $healthy; diff --git a/src/Console/Command/CheckHealth.php b/src/Console/Command/CheckHealth.php index 2d70eb0..96f6eeb 100644 --- a/src/Console/Command/CheckHealth.php +++ b/src/Console/Command/CheckHealth.php @@ -12,7 +12,10 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class CheckHealth extends Command +/** + * @author Barney Hanlon + */ +final class CheckHealth extends Command { public const DEFAULT_NAME = 'cushon:health'; public const DEFAULT_DESCRIPTION = 'Console command to initiate an bundle health check'; diff --git a/src/Console/Factory/ResultFormatterFactory.php b/src/Console/Factory/ResultFormatterFactory.php index 98272b5..dafa6f9 100644 --- a/src/Console/Factory/ResultFormatterFactory.php +++ b/src/Console/Factory/ResultFormatterFactory.php @@ -8,6 +8,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * @author Barney Hanlon + */ interface ResultFormatterFactory { /** diff --git a/src/Console/Factory/ResultFormatterFactory/StyledOutputFactory.php b/src/Console/Factory/ResultFormatterFactory/StyledOutputFactory.php index 0287f10..79e18f1 100644 --- a/src/Console/Factory/ResultFormatterFactory/StyledOutputFactory.php +++ b/src/Console/Factory/ResultFormatterFactory/StyledOutputFactory.php @@ -12,6 +12,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ final class StyledOutputFactory implements ResultFormatterFactory { private ApplicationStatus $applicationStatusFormatter; diff --git a/src/CushonHealthBundle.php b/src/CushonHealthBundle.php index 2868b27..a173f86 100644 --- a/src/CushonHealthBundle.php +++ b/src/CushonHealthBundle.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; /** + * @author Barney Hanlon * @psalm-suppress PropertyNotSetInConstructor Bundle uses Symfony's ContainerAwareTrait */ final class CushonHealthBundle extends Bundle diff --git a/src/DependencyInjection/CushonHealthExtension.php b/src/DependencyInjection/CushonHealthExtension.php index df797b2..ef58d20 100644 --- a/src/DependencyInjection/CushonHealthExtension.php +++ b/src/DependencyInjection/CushonHealthExtension.php @@ -13,6 +13,9 @@ use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +/** + * @author Barney Hanlon + */ final class CushonHealthExtension extends Extension { use BundleRootKeyTrait; diff --git a/src/Encoder/Json/Encoder.php b/src/Encoder/Json/Encoder.php index fa4e71f..c615bdd 100644 --- a/src/Encoder/Json/Encoder.php +++ b/src/Encoder/Json/Encoder.php @@ -4,6 +4,9 @@ namespace Cushon\HealthBundle\Encoder\Json; +/** + * @author Barney Hanlon + */ interface Encoder { /** diff --git a/src/Encoder/Json/SafeJson.php b/src/Encoder/Json/SafeJson.php index b2fcac1..114cdec 100644 --- a/src/Encoder/Json/SafeJson.php +++ b/src/Encoder/Json/SafeJson.php @@ -8,7 +8,10 @@ use function Safe\json_encode; -class SafeJson implements Encoder +/** + * @author Barney Hanlon + */ +final class SafeJson implements Encoder { public const DEFAULT_INDENT = 2; diff --git a/src/Formatter/Console.php b/src/Formatter/Console.php index 5789327..fbe0b99 100644 --- a/src/Formatter/Console.php +++ b/src/Formatter/Console.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck; +/** + * @author Barney Hanlon + */ interface Console { /** diff --git a/src/Formatter/Console/StyledOutput.php b/src/Formatter/Console/StyledOutput.php index 9c8b6ce..89ee853 100644 --- a/src/Formatter/Console/StyledOutput.php +++ b/src/Formatter/Console/StyledOutput.php @@ -14,11 +14,11 @@ use Symfony\Component\Console\Helper\TableCellStyle; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ final class StyledOutput implements Console { - public const STATUS_HEALTHY = 'Healthy'; - public const STATUS_UNHEALTHY = 'Unhealthy'; - private SymfonyStyle $styler; private Dependency $dependencyFormatter; private ApplicationStatus $applicationStatusFormatter; diff --git a/src/Formatter/Console/StyledOutput/ApplicationStatus.php b/src/Formatter/Console/StyledOutput/ApplicationStatus.php index 87949d9..40cfd4c 100644 --- a/src/Formatter/Console/StyledOutput/ApplicationStatus.php +++ b/src/Formatter/Console/StyledOutput/ApplicationStatus.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ interface ApplicationStatus { public const STATUS_HEALTHY = 'Healthy'; diff --git a/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSection.php b/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSection.php index 934aef9..c755d40 100644 --- a/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSection.php +++ b/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSection.php @@ -8,6 +8,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ final class StatusSection implements ApplicationStatus { public const DEFAULT_HEALTHY = 'Status: %s'; diff --git a/src/Formatter/Console/StyledOutput/Dependency.php b/src/Formatter/Console/StyledOutput/Dependency.php index 50e6ea7..1f1c291 100644 --- a/src/Formatter/Console/StyledOutput/Dependency.php +++ b/src/Formatter/Console/StyledOutput/Dependency.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ interface Dependency { public const STATUS_HEALTHY = 'Healthy'; diff --git a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable.php b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable.php index fc32d8e..78da4f9 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable.php +++ b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable.php @@ -11,10 +11,13 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Style\SymfonyStyle; +/** + * @author Barney Hanlon + */ final class DependencyTable implements Dependency { - private DependencyTable\TableHeaderFactory $tableHeaderFactory; - private DependencyTable\DependencyRowFactory $dependencyRowFactory; + private TableHeaderFactory $tableHeaderFactory; + private DependencyRowFactory $dependencyRowFactory; public function __construct( TableHeaderFactory $tableHeaderFactory, diff --git a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactory.php b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactory.php index 5e31e4b..507afc6 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactory.php +++ b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactory.php @@ -10,6 +10,9 @@ use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Helper\TableCellStyle; +/** + * @author Barney Hanlon + */ final class DependencyRowFactory { public const DEFAULT_COLOUR_HEALTHY = 'green'; diff --git a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactory.php b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactory.php index 89fcde6..c018ef6 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactory.php +++ b/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactory.php @@ -10,6 +10,9 @@ use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Helper\TableCellStyle; +/** + * @author Barney Hanlon + */ final class TableHeaderFactory { public const DEFAULT_COLOUR_HEALTHY = 'green'; diff --git a/src/Formatter/Console/StyledOutput/Dependency/Mapper.php b/src/Formatter/Console/StyledOutput/Dependency/Mapper.php index 1944231..35d8690 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/Mapper.php +++ b/src/Formatter/Console/StyledOutput/Dependency/Mapper.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; use Cushon\HealthBundle\Message\Result\HealthCheck; +/** + * @author Barney Hanlon + */ interface Mapper { /** diff --git a/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependency.php b/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependency.php index 67bf3e8..c7d5814 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependency.php +++ b/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependency.php @@ -8,6 +8,9 @@ use Cushon\HealthBundle\Formatter\Console\StyledOutput\Dependency\Mapper; use InvalidArgumentException; +/** + * @author Barney Hanlon + */ final class UnableToMapDependency extends InvalidArgumentException { /** diff --git a/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapper.php b/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapper.php index b7c84c0..c534eee 100644 --- a/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapper.php +++ b/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapper.php @@ -72,9 +72,10 @@ private function mapSimpleDependency(SimpleStatus $simpleStatus): Generator * @param string $name * @param string $health * @param string $info - * @return iterable + * @return Generator + * @psalm-return Generator<'health'|'info'|'name', string, mixed, void> */ - private function yieldMap(string $name, string $health, string $info): iterable + private function yieldMap(string $name, string $health, string $info): Generator { yield self::KEY_NAME => $name; yield self::KEY_HEALTH => $health; diff --git a/src/Handler/CheckHealth.php b/src/Handler/CheckHealth.php index 894ba77..434a1d4 100644 --- a/src/Handler/CheckHealth.php +++ b/src/Handler/CheckHealth.php @@ -9,6 +9,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck as HealthCheckResult; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; +/** + * @author Barney Hanlon + */ interface CheckHealth extends MessageHandlerInterface { /** diff --git a/src/Handler/CheckHealth/DefaultHealthCheck.php b/src/Handler/CheckHealth/DefaultHealthCheck.php index 904c8e3..a7e0e23 100644 --- a/src/Handler/CheckHealth/DefaultHealthCheck.php +++ b/src/Handler/CheckHealth/DefaultHealthCheck.php @@ -11,6 +11,9 @@ use Cushon\HealthBundle\Message\Query\HealthCheck as HealthCheckQuery; use Cushon\HealthBundle\Message\Result\HealthCheck as HealthCheckResult; +/** + * @author Barney Hanlon + */ final class DefaultHealthCheck implements CheckHealth { private Dependencies $dependencies; diff --git a/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailure.php b/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailure.php index 659d0ea..079827a 100644 --- a/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailure.php +++ b/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailure.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\Exception\ApplicationHealthError; use RuntimeException; +/** + * @author Barney Hanlon + */ final class ApplicationHealthCheckFailure extends RuntimeException implements CheckHealthHandlerError { /** diff --git a/src/Handler/CheckHealth/Exception/CheckHealthHandlerError.php b/src/Handler/CheckHealth/Exception/CheckHealthHandlerError.php index 99e4180..ceb0367 100644 --- a/src/Handler/CheckHealth/Exception/CheckHealthHandlerError.php +++ b/src/Handler/CheckHealth/Exception/CheckHealthHandlerError.php @@ -6,6 +6,9 @@ use Throwable; +/** + * @author Barney Hanlon + */ interface CheckHealthHandlerError extends Throwable { } diff --git a/src/Handler/CheckHealth/Logger.php b/src/Handler/CheckHealth/Logger.php index fb39f56..7d57fb4 100644 --- a/src/Handler/CheckHealth/Logger.php +++ b/src/Handler/CheckHealth/Logger.php @@ -8,6 +8,9 @@ use Cushon\HealthBundle\Message\Query\HealthCheck as HealthCheckQuery; use Cushon\HealthBundle\Message\Result\HealthCheck as HealthCheckResult; +/** + * @author Barney Hanlon + */ interface Logger { /** diff --git a/src/Handler/CheckHealth/Logger/PsrLogger.php b/src/Handler/CheckHealth/Logger/PsrLogger.php index a701cb2..578fee3 100644 --- a/src/Handler/CheckHealth/Logger/PsrLogger.php +++ b/src/Handler/CheckHealth/Logger/PsrLogger.php @@ -12,7 +12,10 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; -class PsrLogger implements Logger +/** + * @author Barney Hanlon + */ +final class PsrLogger implements Logger { public const LOG_CONTEXT_HEALTH = 'health'; public const LOG_CONTEXT_HANDLER = 'handler'; diff --git a/src/Handler/CheckHealth/ResultFactory.php b/src/Handler/CheckHealth/ResultFactory.php index 15a6151..aa25c6a 100644 --- a/src/Handler/CheckHealth/ResultFactory.php +++ b/src/Handler/CheckHealth/ResultFactory.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport; use Cushon\HealthBundle\Message\Result\HealthCheck; +/** + * @author Barney Hanlon + */ interface ResultFactory { /** diff --git a/src/Handler/CheckHealth/ResultFactory/DefaultResultFactory.php b/src/Handler/CheckHealth/ResultFactory/DefaultResultFactory.php index 20a71ae..0e61ddb 100644 --- a/src/Handler/CheckHealth/ResultFactory/DefaultResultFactory.php +++ b/src/Handler/CheckHealth/ResultFactory/DefaultResultFactory.php @@ -11,6 +11,9 @@ use Cushon\HealthBundle\Message\Result\HealthCheck\Healthy; use Cushon\HealthBundle\Message\Result\HealthCheck\Unhealthy; +/** + * @author Barney Hanlon + */ final class DefaultResultFactory implements ResultFactory { /** diff --git a/src/Message/Query/HealthCheck.php b/src/Message/Query/HealthCheck.php index ffd9c75..f500b02 100644 --- a/src/Message/Query/HealthCheck.php +++ b/src/Message/Query/HealthCheck.php @@ -4,6 +4,9 @@ namespace Cushon\HealthBundle\Message\Query; +/** + * @author Barney Hanlon + */ interface HealthCheck { } diff --git a/src/Message/Query/HealthCheck/DefaultHealthCheckQuery.php b/src/Message/Query/HealthCheck/DefaultHealthCheckQuery.php index ffbd7e7..11330c1 100644 --- a/src/Message/Query/HealthCheck/DefaultHealthCheckQuery.php +++ b/src/Message/Query/HealthCheck/DefaultHealthCheckQuery.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\Message\Query\HealthCheck; +/** + * @author Barney Hanlon + */ final class DefaultHealthCheckQuery implements HealthCheck { } diff --git a/src/Message/QueryFactory/Exception/QueryFactoryException.php b/src/Message/QueryFactory/Exception/QueryFactoryException.php index 78dcc9f..e3ea307 100644 --- a/src/Message/QueryFactory/Exception/QueryFactoryException.php +++ b/src/Message/QueryFactory/Exception/QueryFactoryException.php @@ -6,6 +6,9 @@ use Throwable; +/** + * @author Barney Hanlon + */ interface QueryFactoryException extends Throwable { } diff --git a/src/Message/QueryFactory/QueryFactory.php b/src/Message/QueryFactory/QueryFactory.php index 2f2d9db..218c466 100644 --- a/src/Message/QueryFactory/QueryFactory.php +++ b/src/Message/QueryFactory/QueryFactory.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\Message\Query\HealthCheck; +/** + * @author Barney Hanlon + */ interface QueryFactory { /** diff --git a/src/Message/QueryFactory/ServiceContainerHealthCheck.php b/src/Message/QueryFactory/ServiceContainerHealthCheck.php index 9a78f07..9706ef8 100644 --- a/src/Message/QueryFactory/ServiceContainerHealthCheck.php +++ b/src/Message/QueryFactory/ServiceContainerHealthCheck.php @@ -9,6 +9,9 @@ use Cushon\HealthBundle\Message\QueryFactory\ServiceContainerHealthCheck\Exception\QueryServiceDefinitionNotFound; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @author Barney Hanlon + */ final class ServiceContainerHealthCheck implements QueryFactory { private ContainerInterface $container; diff --git a/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/IncorrectQueryType.php b/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/IncorrectQueryType.php index 4f5f782..caa371a 100644 --- a/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/IncorrectQueryType.php +++ b/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/IncorrectQueryType.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\Message\QueryFactory\Exception\QueryFactoryException; use InvalidArgumentException; +/** + * @author Barney Hanlon + */ final class IncorrectQueryType extends InvalidArgumentException implements QueryFactoryException { /** diff --git a/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFound.php b/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFound.php index 646edd5..047d480 100644 --- a/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFound.php +++ b/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFound.php @@ -8,6 +8,9 @@ use RuntimeException; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @author Barney Hanlon + */ final class QueryServiceDefinitionNotFound extends RuntimeException implements QueryFactoryException { private ContainerInterface $container; diff --git a/src/Message/Result/HealthCheck.php b/src/Message/Result/HealthCheck.php index 6240315..d988d16 100644 --- a/src/Message/Result/HealthCheck.php +++ b/src/Message/Result/HealthCheck.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; use JsonSerializable; +/** + * @author Barney Hanlon + */ interface HealthCheck extends JsonSerializable { public const STATUS_HEALTHY = 'healthy'; diff --git a/src/Message/Result/HealthCheck/Healthy.php b/src/Message/Result/HealthCheck/Healthy.php index 977eb0c..4fec55a 100644 --- a/src/Message/Result/HealthCheck/Healthy.php +++ b/src/Message/Result/HealthCheck/Healthy.php @@ -9,6 +9,7 @@ use Cushon\HealthBundle\Message\Result\Traits\DependencyTrait; use Cushon\HealthBundle\Message\Result\Traits\JsonSerializableTrait; use Ds\Set; +use Generator; final class Healthy implements HealthCheck { @@ -25,6 +26,7 @@ public function __construct(DependencyStatus ...$dependencies) /** * @return iterable + * @psalm-return Generator */ public function __invoke(): iterable { diff --git a/src/Message/Result/HealthCheck/Unhealthy.php b/src/Message/Result/HealthCheck/Unhealthy.php index 6d00eea..120db7a 100644 --- a/src/Message/Result/HealthCheck/Unhealthy.php +++ b/src/Message/Result/HealthCheck/Unhealthy.php @@ -9,6 +9,7 @@ use Cushon\HealthBundle\Message\Result\Traits\DependencyTrait; use Cushon\HealthBundle\Message\Result\Traits\JsonSerializableTrait; use Ds\Set; +use Generator; final class Unhealthy implements HealthCheck { @@ -25,6 +26,7 @@ public function __construct(DependencyStatus ...$dependencies) /** * @return iterable + * @psalm-return Generator */ public function __invoke(): iterable { diff --git a/src/Message/Result/Traits/DependencyTrait.php b/src/Message/Result/Traits/DependencyTrait.php index d08c5a1..4fc9265 100644 --- a/src/Message/Result/Traits/DependencyTrait.php +++ b/src/Message/Result/Traits/DependencyTrait.php @@ -8,6 +8,9 @@ use Ds\Set; use Generator; +/** + * @author Barney Hanlon + */ trait DependencyTrait { /** diff --git a/src/Message/Result/Traits/JsonSerializableTrait.php b/src/Message/Result/Traits/JsonSerializableTrait.php index 313c02e..343fbc7 100644 --- a/src/Message/Result/Traits/JsonSerializableTrait.php +++ b/src/Message/Result/Traits/JsonSerializableTrait.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; use Cushon\HealthBundle\Message\Result\HealthCheck; +/** + * @author Barney Hanlon + */ trait JsonSerializableTrait { /** diff --git a/src/QueryBus/Exception/QueryBusError.php b/src/QueryBus/Exception/QueryBusError.php index ec673bc..8c20cd3 100644 --- a/src/QueryBus/Exception/QueryBusError.php +++ b/src/QueryBus/Exception/QueryBusError.php @@ -6,6 +6,9 @@ use Throwable; +/** + * @author Barney Hanlon + */ interface QueryBusError extends Throwable { } diff --git a/src/QueryBus/Exception/ResultAssertionFailed.php b/src/QueryBus/Exception/ResultAssertionFailed.php index 543fd25..c5c2654 100644 --- a/src/QueryBus/Exception/ResultAssertionFailed.php +++ b/src/QueryBus/Exception/ResultAssertionFailed.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\QueryBus\ResultAssertion\Exception\AssertionError; use RuntimeException; +/** + * @author Barney Hanlon + */ final class ResultAssertionFailed extends RuntimeException implements QueryBusError { /** diff --git a/src/QueryBus/Exception/SymfonyMessengerError.php b/src/QueryBus/Exception/SymfonyMessengerError.php index e4a915d..b734cb9 100644 --- a/src/QueryBus/Exception/SymfonyMessengerError.php +++ b/src/QueryBus/Exception/SymfonyMessengerError.php @@ -7,6 +7,9 @@ use RuntimeException; use Symfony\Component\Messenger\Exception\ExceptionInterface; +/** + * @author Barney Hanlon + */ final class SymfonyMessengerError extends RuntimeException implements QueryBusError { /** diff --git a/src/QueryBus/HealthCheckQueryBus.php b/src/QueryBus/HealthCheckQueryBus.php index 1c6f5b4..0031ad0 100644 --- a/src/QueryBus/HealthCheckQueryBus.php +++ b/src/QueryBus/HealthCheckQueryBus.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\Message\Query\HealthCheck as HealthCheckQuery; use Cushon\HealthBundle\Message\Result\HealthCheck as HealthCheckResult; +/** + * @author Barney Hanlon + */ interface HealthCheckQueryBus { /** diff --git a/src/QueryBus/MessengerHealthQueryBus.php b/src/QueryBus/MessengerHealthQueryBus.php index ed5bf92..fbae826 100644 --- a/src/QueryBus/MessengerHealthQueryBus.php +++ b/src/QueryBus/MessengerHealthQueryBus.php @@ -19,6 +19,9 @@ use Symfony\Component\Messenger\HandleTrait; use Symfony\Component\Messenger\MessageBusInterface; +/** + * @author Barney Hanlon + */ final class MessengerHealthQueryBus implements HealthCheckQueryBus { use HandleTrait; diff --git a/src/QueryBus/ResultAssertion.php b/src/QueryBus/ResultAssertion.php index 6f5222a..dcae5b0 100644 --- a/src/QueryBus/ResultAssertion.php +++ b/src/QueryBus/ResultAssertion.php @@ -6,6 +6,9 @@ use Cushon\HealthBundle\QueryBus\ResultAssertion\Exception\AssertionError; +/** + * @author Barney Hanlon + */ interface ResultAssertion { /** diff --git a/src/QueryBus/ResultAssertion/DefaultAssertion.php b/src/QueryBus/ResultAssertion/DefaultAssertion.php index 2a328df..12b2fbc 100644 --- a/src/QueryBus/ResultAssertion/DefaultAssertion.php +++ b/src/QueryBus/ResultAssertion/DefaultAssertion.php @@ -11,6 +11,9 @@ use Cushon\HealthBundle\QueryBus\ResultAssertion\Exception\UnexpectedResultType; use ReflectionClass; +/** + * @author Barney Hanlon + */ final class DefaultAssertion implements ResultAssertion { private string $classOrInterfaceName; diff --git a/src/QueryBus/ResultAssertion/Exception/AssertionError.php b/src/QueryBus/ResultAssertion/Exception/AssertionError.php index 33af28f..106b7ff 100644 --- a/src/QueryBus/ResultAssertion/Exception/AssertionError.php +++ b/src/QueryBus/ResultAssertion/Exception/AssertionError.php @@ -6,6 +6,9 @@ use Throwable; +/** + * @author Barney Hanlon + */ interface AssertionError extends Throwable { } diff --git a/src/QueryBus/ResultAssertion/Exception/ResultClassOrInterfaceNotFound.php b/src/QueryBus/ResultAssertion/Exception/ResultClassOrInterfaceNotFound.php index 1294cc5..642886f 100644 --- a/src/QueryBus/ResultAssertion/Exception/ResultClassOrInterfaceNotFound.php +++ b/src/QueryBus/ResultAssertion/Exception/ResultClassOrInterfaceNotFound.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\QueryBus\Exception\QueryBusError; use InvalidArgumentException; +/** + * @author Barney Hanlon + */ final class ResultClassOrInterfaceNotFound extends InvalidArgumentException implements AssertionError { /** diff --git a/src/QueryBus/ResultAssertion/Exception/ResultTypeClassDoesNotMatchExpected.php b/src/QueryBus/ResultAssertion/Exception/ResultTypeClassDoesNotMatchExpected.php index 5c3643c..ea93ddf 100644 --- a/src/QueryBus/ResultAssertion/Exception/ResultTypeClassDoesNotMatchExpected.php +++ b/src/QueryBus/ResultAssertion/Exception/ResultTypeClassDoesNotMatchExpected.php @@ -8,6 +8,9 @@ use Cushon\HealthBundle\QueryBus\Exception\QueryBusError; use InvalidArgumentException; +/** + * @author Barney Hanlon + */ final class ResultTypeClassDoesNotMatchExpected extends InvalidArgumentException implements AssertionError { /** diff --git a/src/QueryBus/ResultAssertion/Exception/UnexpectedResultType.php b/src/QueryBus/ResultAssertion/Exception/UnexpectedResultType.php index 768d7ad..7a2145c 100644 --- a/src/QueryBus/ResultAssertion/Exception/UnexpectedResultType.php +++ b/src/QueryBus/ResultAssertion/Exception/UnexpectedResultType.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\QueryBus\Exception\QueryBusError; use RuntimeException; +/** + * @author Barney Hanlon + */ final class UnexpectedResultType extends RuntimeException implements AssertionError { private mixed $result; diff --git a/src/Traits/BundleRootKeyTrait.php b/src/Traits/BundleRootKeyTrait.php index 42cf9a9..830bd58 100644 --- a/src/Traits/BundleRootKeyTrait.php +++ b/src/Traits/BundleRootKeyTrait.php @@ -4,6 +4,9 @@ namespace Cushon\HealthBundle\Traits; +/** + * @author Barney Hanlon + */ trait BundleRootKeyTrait { private string $rootKey; diff --git a/tests/behat/src/Context/Api.php b/tests/behat/src/Context/Api.php index a3865b3..fc43471 100644 --- a/tests/behat/src/Context/Api.php +++ b/tests/behat/src/Context/Api.php @@ -7,6 +7,9 @@ use Behat\Behat\Context\Context; use Behat\Behat\Tester\Exception\PendingException; +/** + * @author Barney Hanlon + */ final class Api implements Context { /** diff --git a/tests/behat/src/Context/Console.php b/tests/behat/src/Context/Console.php index ec40a76..a407fa7 100644 --- a/tests/behat/src/Context/Console.php +++ b/tests/behat/src/Context/Console.php @@ -22,6 +22,9 @@ use Symfony\Component\HttpKernel\KernelInterface; use Tests\Behat\Context\Traits\ProphecyContextTrait; +/** + * @author Barney Hanlon + */ final class Console implements Context { use ProphecyContextTrait; diff --git a/tests/behat/src/Context/MessageBus.php b/tests/behat/src/Context/MessageBus.php index 39a0e2e..3f9ea25 100644 --- a/tests/behat/src/Context/MessageBus.php +++ b/tests/behat/src/Context/MessageBus.php @@ -15,6 +15,9 @@ use Symfony\Component\HttpKernel\KernelInterface; use Tests\Behat\Context\Traits\ProphecyContextTrait; +/** + * @author Barney Hanlon + */ final class MessageBus implements Context { use ProphecyContextTrait; diff --git a/tests/behat/src/Context/Traits/ProphecyContextTrait.php b/tests/behat/src/Context/Traits/ProphecyContextTrait.php index 21282bd..240b95a 100644 --- a/tests/behat/src/Context/Traits/ProphecyContextTrait.php +++ b/tests/behat/src/Context/Traits/ProphecyContextTrait.php @@ -7,6 +7,9 @@ use Prophecy\Prophecy\ObjectProphecy; use Prophecy\Prophet; +/** + * @author Barney Hanlon + */ trait ProphecyContextTrait { private static ?Prophet $prophet = null; diff --git a/tests/unit/src/ApplicationHealth/Dependencies/SimpleDependenciesTest.php b/tests/unit/src/ApplicationHealth/Dependencies/SimpleDependenciesTest.php index ea04ee2..ee99f1e 100644 --- a/tests/unit/src/ApplicationHealth/Dependencies/SimpleDependenciesTest.php +++ b/tests/unit/src/ApplicationHealth/Dependencies/SimpleDependenciesTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class SimpleDependenciesTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatusesTest.php b/tests/unit/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatusesTest.php index 3380921..8ef959f 100644 --- a/tests/unit/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatusesTest.php +++ b/tests/unit/src/ApplicationHealth/HealthReport/Exception/NoDependencyStatusesTest.php @@ -7,6 +7,9 @@ use Cushon\HealthBundle\ApplicationHealth\HealthReport\Exception\NoDependencyStatuses; use PHPUnit\Framework\TestCase; +/** + * @author Barney Hanlon + */ final class NoDependencyStatusesTest extends TestCase { public function testItReturnsAZeroidErrorCode(): void diff --git a/tests/unit/src/ApplicationHealth/HealthReport/SimpleHealthReportTest.php b/tests/unit/src/ApplicationHealth/HealthReport/SimpleHealthReportTest.php index e9a7db9..c562850 100644 --- a/tests/unit/src/ApplicationHealth/HealthReport/SimpleHealthReportTest.php +++ b/tests/unit/src/ApplicationHealth/HealthReport/SimpleHealthReportTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class SimpleHealthReportTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/CushonHealthBundleTest.php b/tests/unit/src/CushonHealthBundleTest.php index bc5f1e0..d2167f7 100644 --- a/tests/unit/src/CushonHealthBundleTest.php +++ b/tests/unit/src/CushonHealthBundleTest.php @@ -12,6 +12,9 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** + * @author Barney Hanlon + */ final class CushonHealthBundleTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/DependencyInjection/CushonHealthExtensionTest.php b/tests/unit/src/DependencyInjection/CushonHealthExtensionTest.php index 08808bf..5af4494 100644 --- a/tests/unit/src/DependencyInjection/CushonHealthExtensionTest.php +++ b/tests/unit/src/DependencyInjection/CushonHealthExtensionTest.php @@ -16,6 +16,9 @@ use Symfony\Component\Filesystem\Filesystem; use Tests\Utils\Constants; +/** + * @author Barney Hanlon + */ final class CushonHealthExtensionTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Encoder/Json/SafeJsonTest.php b/tests/unit/src/Encoder/Json/SafeJsonTest.php index 81c2858..c4eb6ca 100644 --- a/tests/unit/src/Encoder/Json/SafeJsonTest.php +++ b/tests/unit/src/Encoder/Json/SafeJsonTest.php @@ -12,6 +12,9 @@ use function Safe\file_get_contents; use function Safe\json_decode; +/** + * @author Barney Hanlon + */ final class SafeJsonTest extends TestCase { private const ENCODING_FIXTURES_DIR = '/encoding'; diff --git a/tests/unit/src/Formatter/Console/Command/CheckHealthTest.php b/tests/unit/src/Formatter/Console/Command/CheckHealthTest.php index 84a8ab0..997a1ea 100644 --- a/tests/unit/src/Formatter/Console/Command/CheckHealthTest.php +++ b/tests/unit/src/Formatter/Console/Command/CheckHealthTest.php @@ -18,6 +18,9 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Tester\CommandTester; +/** + * @author Barney Hanlon + */ final class CheckHealthTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/Factory/ResultFormatterFactory/StyledOutputFactoryTest.php b/tests/unit/src/Formatter/Console/Factory/ResultFormatterFactory/StyledOutputFactoryTest.php index 28af691..9529501 100644 --- a/tests/unit/src/Formatter/Console/Factory/ResultFormatterFactory/StyledOutputFactoryTest.php +++ b/tests/unit/src/Formatter/Console/Factory/ResultFormatterFactory/StyledOutputFactoryTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Tester\TesterTrait; +/** + * @author Barney Hanlon + */ final class StyledOutputFactoryTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSectionFormatterTest.php b/tests/unit/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSectionFormatterTest.php index c1aa3af..2afaa73 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSectionFormatterTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/ApplicationStatus/StatusSectionFormatterTest.php @@ -12,6 +12,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Tester\TesterTrait; +/** + * @author Barney Hanlon + */ final class StatusSectionFormatterTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactoryTest.php b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactoryTest.php index 28c0cc6..481efc4 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactoryTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/DependencyRowFactoryTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Helper\TableCell; +/** + * @author Barney Hanlon + */ final class DependencyRowFactoryTest extends TestCase { public function testItReturnsAHealthyDependencyRow(): void diff --git a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactoryTest.php b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactoryTest.php index fbe65a8..7b8a4a9 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactoryTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTable/TableHeaderFactoryTest.php @@ -11,6 +11,9 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Helper\TableCell; +/** + * @author Barney Hanlon + */ final class TableHeaderFactoryTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTableTest.php b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTableTest.php index f66da16..3d57d3d 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTableTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/DependencyTableTest.php @@ -15,6 +15,9 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Tester\TesterTrait; +/** + * @author Barney Hanlon + */ final class DependencyTableTest extends TestCase { use TesterTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependencyTest.php b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependencyTest.php index 986c80a..c1ccd68 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependencyTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/Exception/UnableToMapDependencyTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class UnableToMapDependencyTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapperTest.php b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapperTest.php index 3d4bc1d..34050e4 100644 --- a/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapperTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutput/Dependency/Mapper/SimpleMapperTest.php @@ -13,6 +13,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class SimpleMapperTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Formatter/Console/StyledOutputTest.php b/tests/unit/src/Formatter/Console/StyledOutputTest.php index 5ea0a8d..d32b65e 100644 --- a/tests/unit/src/Formatter/Console/StyledOutputTest.php +++ b/tests/unit/src/Formatter/Console/StyledOutputTest.php @@ -18,6 +18,9 @@ use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Tester\TesterTrait; +/** + * @author Barney Hanlon + */ final class StyledOutputTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Handler/CheckHealth/DefaultHealthCheckTest.php b/tests/unit/src/Handler/CheckHealth/DefaultHealthCheckTest.php index 716f78a..817cc88 100644 --- a/tests/unit/src/Handler/CheckHealth/DefaultHealthCheckTest.php +++ b/tests/unit/src/Handler/CheckHealth/DefaultHealthCheckTest.php @@ -18,6 +18,9 @@ use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class DefaultHealthCheckTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailureTest.php b/tests/unit/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailureTest.php index c30f6c3..c023d11 100644 --- a/tests/unit/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailureTest.php +++ b/tests/unit/src/Handler/CheckHealth/Exception/ApplicationHealthCheckFailureTest.php @@ -9,6 +9,9 @@ use Exception; use PHPUnit\Framework\TestCase; +/** + * @author Barney Hanlon + */ final class ApplicationHealthCheckFailureTest extends TestCase { public function testItReturnsAZeroidErrorCode(): void diff --git a/tests/unit/src/Handler/CheckHealth/ResultFactory/DefaultResultFactoryTest.php b/tests/unit/src/Handler/CheckHealth/ResultFactory/DefaultResultFactoryTest.php index f25126f..54f0fb7 100644 --- a/tests/unit/src/Handler/CheckHealth/ResultFactory/DefaultResultFactoryTest.php +++ b/tests/unit/src/Handler/CheckHealth/ResultFactory/DefaultResultFactoryTest.php @@ -12,6 +12,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class DefaultResultFactoryTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Handler/Logger/PsrLoggerTest.php b/tests/unit/src/Handler/Logger/PsrLoggerTest.php index 57cd92a..2bed596 100644 --- a/tests/unit/src/Handler/Logger/PsrLoggerTest.php +++ b/tests/unit/src/Handler/Logger/PsrLoggerTest.php @@ -17,6 +17,9 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; +/** + * @author Barney Hanlon + */ final class PsrLoggerTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/QueryFactory/DefaultHealthCheckQueryTest.php b/tests/unit/src/Message/QueryFactory/DefaultHealthCheckQueryTest.php index e922e1d..17b5e64 100644 --- a/tests/unit/src/Message/QueryFactory/DefaultHealthCheckQueryTest.php +++ b/tests/unit/src/Message/QueryFactory/DefaultHealthCheckQueryTest.php @@ -13,6 +13,9 @@ use stdClass; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @author Barney Hanlon + */ final class DefaultHealthCheckQueryTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFoundTest.php b/tests/unit/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFoundTest.php index 53cd5ca..3a86f56 100644 --- a/tests/unit/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFoundTest.php +++ b/tests/unit/src/Message/QueryFactory/ServiceContainerHealthCheck/Exception/QueryServiceDefinitionNotFoundTest.php @@ -9,6 +9,9 @@ use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\DependencyInjection\ContainerInterface; +/** + * @author Barney Hanlon + */ final class QueryServiceDefinitionNotFoundTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/Result/HealthCheck/HealthyTest.php b/tests/unit/src/Message/Result/HealthCheck/HealthyTest.php index 8d326be..ccf5c8f 100644 --- a/tests/unit/src/Message/Result/HealthCheck/HealthyTest.php +++ b/tests/unit/src/Message/Result/HealthCheck/HealthyTest.php @@ -11,6 +11,9 @@ use function Safe\json_encode; +/** + * @author Barney Hanlon + */ final class HealthyTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/Result/HealthCheck/Traits/DependencyTraitTest.php b/tests/unit/src/Message/Result/HealthCheck/Traits/DependencyTraitTest.php index d467039..ef11fb9 100644 --- a/tests/unit/src/Message/Result/HealthCheck/Traits/DependencyTraitTest.php +++ b/tests/unit/src/Message/Result/HealthCheck/Traits/DependencyTraitTest.php @@ -10,6 +10,9 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +/** + * @author Barney Hanlon + */ final class DependencyTraitTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/Result/HealthCheck/Traits/JsonSerializableTraitTest.php b/tests/unit/src/Message/Result/HealthCheck/Traits/JsonSerializableTraitTest.php index 28cc27d..0462868 100644 --- a/tests/unit/src/Message/Result/HealthCheck/Traits/JsonSerializableTraitTest.php +++ b/tests/unit/src/Message/Result/HealthCheck/Traits/JsonSerializableTraitTest.php @@ -15,6 +15,9 @@ use function Safe\json_decode; use function Safe\json_encode; +/** + * @author Barney Hanlon + */ final class JsonSerializableTraitTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/Message/Result/HealthCheck/UnhealthyTest.php b/tests/unit/src/Message/Result/HealthCheck/UnhealthyTest.php index da053c9..27e0ffe 100644 --- a/tests/unit/src/Message/Result/HealthCheck/UnhealthyTest.php +++ b/tests/unit/src/Message/Result/HealthCheck/UnhealthyTest.php @@ -12,6 +12,9 @@ use function Safe\json_encode; +/** + * @author Barney Hanlon + */ final class UnhealthyTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/QueryBus/Exception/SymfonyMessengerErrorTest.php b/tests/unit/src/QueryBus/Exception/SymfonyMessengerErrorTest.php index af7b1e4..831ecb0 100644 --- a/tests/unit/src/QueryBus/Exception/SymfonyMessengerErrorTest.php +++ b/tests/unit/src/QueryBus/Exception/SymfonyMessengerErrorTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Messenger\Exception\LogicException; +/** + * @author Barney Hanlon + */ final class SymfonyMessengerErrorTest extends TestCase { public function testItReturnsAZeroidErrorCode(): void diff --git a/tests/unit/src/QueryBus/Exception/UnexpectedResultTypeTest.php b/tests/unit/src/QueryBus/Exception/UnexpectedResultTypeTest.php index 1c5a2e8..0d58c5b 100644 --- a/tests/unit/src/QueryBus/Exception/UnexpectedResultTypeTest.php +++ b/tests/unit/src/QueryBus/Exception/UnexpectedResultTypeTest.php @@ -8,6 +8,9 @@ use PHPUnit\Framework\TestCase; use stdClass; +/** + * @author Barney Hanlon + */ final class UnexpectedResultTypeTest extends TestCase { public function testItHasTheResult(): void diff --git a/tests/unit/src/QueryBus/MessengerHealthQueryBusTest.php b/tests/unit/src/QueryBus/MessengerHealthQueryBusTest.php index 7ac0dd1..f3d0f69 100644 --- a/tests/unit/src/QueryBus/MessengerHealthQueryBusTest.php +++ b/tests/unit/src/QueryBus/MessengerHealthQueryBusTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\Stamp\HandledStamp; +/** + * @author Barney Hanlon + */ final class MessengerHealthQueryBusTest extends TestCase { use ProphecyTrait; diff --git a/tests/unit/src/QueryBus/ResultAssertion/DefaultAssertionTest.php b/tests/unit/src/QueryBus/ResultAssertion/DefaultAssertionTest.php index cb412ab..f567c68 100644 --- a/tests/unit/src/QueryBus/ResultAssertion/DefaultAssertionTest.php +++ b/tests/unit/src/QueryBus/ResultAssertion/DefaultAssertionTest.php @@ -14,6 +14,9 @@ use stdClass; use Symfony\Component\Messenger\MessageBusInterface; +/** + * @author Barney Hanlon + */ final class DefaultAssertionTest extends TestCase { use ProphecyTrait;