diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml new file mode 100644 index 0000000..9211c2d --- /dev/null +++ b/.github/workflows/continuous-integration.yaml @@ -0,0 +1,167 @@ +name: "Continuous Integration" + +on: + push: + +concurrency: + group: ci-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + DB_ROOT_NAME: root + DB_ROOT_PASS: root + +jobs: + ci: + strategy: + matrix: + php-versions: + - "8.1" + - "8.2" + - "8.3" + - "8.4" + #- "8.5" + prefer: + - lowest + - highest + + runs-on: ubuntu-latest + + permissions: + contents: read + + services: + mysql57: + image: mirror.gcr.io/mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: nori57 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping -h localhost" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + mysql80: + image: mirror.gcr.io/mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: nori80 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping -h localhost" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + mysql84: + image: mirror.gcr.io/mysql:8.4 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: nori84 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping -h localhost" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + mariadb10: + image: mirror.gcr.io/mariadb:10 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: mariadb10 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + mariadb11: + image: mirror.gcr.io/mariadb:11 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: mariadb11 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + mariadb12: + image: mirror.gcr.io/mariadb:12 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: mariadb12 + MYSQL_USER: nori + MYSQL_PASSWORD: nori + ports: + - 3306/tcp + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-start-period=10s --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@ec406be512d7077f68eed36e63f4d91bc006edc4 # v2.35.4 + with: + php-version: ${{ matrix.php-versions }} + extensions: mysqli, pdo_mysql, xsl, opcache, zip + tools: composer + coverage: xdebug + ini-values: opcache.enable_cli=1, opcache.jit_buffer_size=0 + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.php-versions }}-${{ matrix.prefer }}- + + - name: Install dependencies + run: composer install --no-progress --audit + + - name: Update dependencies to lowest + if: ${{ matrix.prefer == 'lowest' }} + run: composer update --no-progress --prefer-stable + env: + COMPOSER_PREFER_LOWEST: 1 + + - name: Run composer validate + run: composer validate --strict + + - name: Run PHP CS Fixer + run: composer lint + + - name: Run PHPUnit 10 + if: ${{ matrix.php-versions == '8.1' || matrix.prefer == 'lowest' }} + run: composer test -- --configuration=phpunit10.xml --coverage-text + env: + XDEBUG_MODE: coverage + MYSQL57_DB_PORT: ${{ job.services.mysql57.ports['3306'] }} + MYSQL80_DB_PORT: ${{ job.services.mysql80.ports['3306'] }} + MYSQL84_DB_PORT: ${{ job.services.mysql84.ports['3306'] }} + MARIADB10_DB_PORT: ${{ job.services.mariadb10.ports['3306'] }} + MARIADB11_DB_PORT: ${{ job.services.mariadb11.ports['3306'] }} + MARIADB12_DB_PORT: ${{ job.services.mariadb12.ports['3306'] }} + + - name: Run PHPUnit 11 + if: ${{ matrix.php-versions == '8.2' && matrix.prefer == 'highest' }} + run: composer test -- --configuration=phpunit11.xml --coverage-text + env: + XDEBUG_MODE: coverage + MYSQL57_DB_PORT: ${{ job.services.mysql57.ports['3306'] }} + MYSQL80_DB_PORT: ${{ job.services.mysql80.ports['3306'] }} + MYSQL84_DB_PORT: ${{ job.services.mysql84.ports['3306'] }} + MARIADB10_DB_PORT: ${{ job.services.mariadb10.ports['3306'] }} + MARIADB11_DB_PORT: ${{ job.services.mariadb11.ports['3306'] }} + MARIADB12_DB_PORT: ${{ job.services.mariadb12.ports['3306'] }} + + - name: Run PHPUnit 12 + if: ${{ matrix.php-versions >= '8.3' && matrix.prefer == 'highest' }} + run: composer test -- --configuration=phpunit12.xml --coverage-text + env: + XDEBUG_MODE: coverage + MYSQL57_DB_PORT: ${{ job.services.mysql57.ports['3306'] }} + MYSQL80_DB_PORT: ${{ job.services.mysql80.ports['3306'] }} + MYSQL84_DB_PORT: ${{ job.services.mysql84.ports['3306'] }} + MARIADB10_DB_PORT: ${{ job.services.mariadb10.ports['3306'] }} + MARIADB11_DB_PORT: ${{ job.services.mariadb11.ports['3306'] }} + MARIADB12_DB_PORT: ${{ job.services.mariadb12.ports['3306'] }} diff --git a/.gitignore b/.gitignore index 487a7d6..7c50415 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor/ /build/ composer.lock +.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e482fcf..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -dist: trusty - -language: php -php: -- 7.3 - -before_script: - - composer install - -script: - - docker-compose up -d travis - - docker-compose logs -f travis - -notifications: - slack: - secure: YnDFdn2JQIgz9XNrmhmM3drDNUpJ+H1rWdtnC+1+2JP1Ahv4XhBcYBCBQVZbBJtYICaqR4xwbWEgqRpwumVRfBJsxNPfndYHEQ9F6ZaZBoVPcp+peOdXHv7mparkH4Z8RLQSsdsXeL1CIkaWs+blKtWmZ7utSbqpNkhgDoJxUZKLGyhmpNj1anfXAYzxomv0Mx7Vrhu6tokWk8l1Mde3vd2ZT/Bd46sXAknk7KariwqGHAVpoFczYdtXd+e7EiNxSAw6freU6DQ+cOShqAxTqKL0X/h1xW6utQZXvLBHxh0mNRd/w3HTgbc1e7HqEPi2q5sBJRXtIFdCEdjvkPnW9aHLXuvnHjrXGfFA88RdJMf4YzG/9Pnr5jXwpP/M5LovMJ6X2N0pKAjFTWK1++baIXRJ5cHe5wJSVk/aKK85J9nFZsXeB1cUTxqFzyXfozAIAbNlXp9kpwzbjREfFuK7Dz4TUMi7DgrW18Jc8W9Ms9fjtYvcxgvf/D3CEenfSNGzWMniOKWdcop5AalzwEurEDGF41Lq7hEef3VE2CG0QLO9LEhhPYWs09Uzho0qYB/maiAwY8J+J5hxHwD8G47XGRwwPwc08PLfzI1NfKW2SMjfkkIFBDCwVeVj5rJkN+PR9vAFSf/kN/gC6pdawzZz09OpR/rY29aVI+ptLiN3eqE= diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..680ab8e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# syntax=docker/dockerfile:1.6 +# check=error=true + +ARG PHP_VERSION=8.1 + +FROM mirror.gcr.io/php:${PHP_VERSION}-cli + +# Set up php +RUN \ + --mount=type=bind,from=ghcr.io/mlocati/php-extension-installer:latest,source=/usr/bin/install-php-extensions,target=/usr/local/bin/install-php-extensions \ + --mount=type=cache,sharing=locked,target=/var/lib/apt \ + --mount=type=cache,target=/var/cache/apt \ + < /etc/apt/apt.conf.d/keep-cache +apt-get update +apt-get install -y --no-install-recommends default-mysql-client sudo +install-php-extensions \ + @composer-2 \ + mysqli \ + pdo_mysql \ + xdebug \ + xsl \ + zip + +groupadd --gid 1000 phpuser +useradd --gid phpuser --shell /bin/bash --create-home --uid 1000 phpuser +echo "phpuser ALL=(root) NOPASSWD:ALL" > "/etc/sudoers.d/phpuser" +chmod 0440 "/etc/sudoers.d/phpuser" +EOL + +USER phpuser +VOLUME [ "/usr/src/app" ] +WORKDIR /usr/src/app diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..60cd45c --- /dev/null +++ b/compose.yaml @@ -0,0 +1,309 @@ +services: + php81: + build: + context: . + dockerfile: Dockerfile + args: + PHP_VERSION: 8.1 + working_dir: /usr/src/app + environment: + DB_HOST: mysql57:3306,mysql80:3306,mysql84:3306,mariadb100:3306,mariadb101:3306,mariadb102:3306,mariadb103:3306,mariadb110:3306,mariadb120:3306 + DB_ROOT_NAME: root + DB_ROOT_PASS: root + volumes: + - type: bind + source: . + target: /usr/src/app + consistency: cached + depends_on: + mysql57: + condition: service_healthy + mysql80: + condition: service_healthy + mysql84: + condition: service_healthy + mariadb101: + condition: service_healthy + mariadb102: + condition: service_healthy + mariadb103: + condition: service_healthy + mariadb110: + condition: service_healthy + mariadb120: + condition: service_healthy + + php82: + build: + context: . + dockerfile: Dockerfile + args: + PHP_VERSION: 8.2 + working_dir: /usr/src/app + environment: + DB_HOST: mysql57:3306,mysql80:3306,mysql84:3306,mariadb100:3306,mariadb101:3306,mariadb102:3306,mariadb103:3306,mariadb110:3306,mariadb120:3306 + DB_ROOT_NAME: root + DB_ROOT_PASS: root + volumes: + - type: bind + source: . + target: /usr/src/app + consistency: cached + depends_on: + mysql57: + condition: service_healthy + mysql80: + condition: service_healthy + mysql84: + condition: service_healthy + mariadb101: + condition: service_healthy + mariadb102: + condition: service_healthy + mariadb103: + condition: service_healthy + mariadb110: + condition: service_healthy + mariadb120: + condition: service_healthy + + php83: + build: + context: . + dockerfile: Dockerfile + args: + PHP_VERSION: 8.3 + working_dir: /usr/src/app + environment: + DB_HOST: mysql57:3306,mysql80:3306,mysql84:3306,mariadb100:3306,mariadb101:3306,mariadb102:3306,mariadb103:3306,mariadb110:3306,mariadb120:3306 + DB_ROOT_NAME: root + DB_ROOT_PASS: root + volumes: + - type: bind + source: . + target: /usr/src/app + consistency: cached + depends_on: + mysql57: + condition: service_healthy + mysql80: + condition: service_healthy + mysql84: + condition: service_healthy + mariadb101: + condition: service_healthy + mariadb102: + condition: service_healthy + mariadb103: + condition: service_healthy + mariadb110: + condition: service_healthy + mariadb120: + condition: service_healthy + + php84: + build: + context: . + dockerfile: Dockerfile + args: + PHP_VERSION: 8.4 + working_dir: /usr/src/app + environment: + DB_HOST: mysql57:3306,mysql80:3306,mysql84:3306,mariadb100:3306,mariadb101:3306,mariadb102:3306,mariadb103:3306,mariadb110:3306,mariadb120:3306 + DB_ROOT_NAME: root + DB_ROOT_PASS: root + volumes: + - type: bind + source: . + target: /usr/src/app + consistency: cached + depends_on: + mysql57: + condition: service_healthy + mysql80: + condition: service_healthy + mysql84: + condition: service_healthy + mariadb100: + condition: service_healthy + mariadb101: + condition: service_healthy + mariadb102: + condition: service_healthy + mariadb103: + condition: service_healthy + mariadb110: + condition: service_healthy + mariadb120: + condition: service_healthy + + mysql57: + image: mirror.gcr.io/mysql:5.7 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + volumes: + - type: volume + source: mysql57-volume + target: /var/lib/mysql + networks: + - default + + mysql80: + image: mirror.gcr.io/mysql:8.0 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + volumes: + - type: volume + source: mysql80-volume + target: /var/lib/mysql + networks: + - default + + mysql84: + image: mirror.gcr.io/mysql:8.4 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + volumes: + - type: volume + source: mysql84-volume + target: /var/lib/mysql + networks: + - default + + mariadb100: + image: mariadb:10.0 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb100-volume + target: /var/lib/mysql + networks: + - default + + mariadb101: + image: mariadb:10.1 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb101-volume + target: /var/lib/mysql + networks: + - default + + mariadb102: + image: mariadb:10.2 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb102-volume + target: /var/lib/mysql + networks: + - default + + mariadb103: + image: mariadb:10.3 + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MYSQL_ROOT_PASSWORD: root + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb103-volume + target: /var/lib/mysql + networks: + - default + + mariadb110: + image: mariadb:11 + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb110-volume + target: /var/lib/mysql + networks: + - default + + mariadb120: + image: mariadb:12 + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 20s + interval: 10s + timeout: 5s + retries: 3 + environment: + MARIADB_ROOT_PASSWORD: root + volumes: + - type: volume + source: mariadb120-volume + target: /var/lib/mysql + networks: + - default + +networks: + default: {} + +volumes: + mysql57-volume: {} + mysql80-volume: {} + mysql84-volume: {} + mariadb100-volume: {} + mariadb101-volume: {} + mariadb102-volume: {} + mariadb103-volume: {} + mariadb110-volume: {} + mariadb120-volume: {} diff --git a/composer.json b/composer.json index 3d9808a..43de795 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "authors": [ { - "name": "Hayashi Takuya", + "name": "Hayashi Takuya", "email": "howyi.lq@gmail.com" } ], @@ -25,17 +25,23 @@ "composer cs" ] }, + "prefer-stable": true, + "config": { + "preferred-install": "dist", + "sort-packages": true, + "optimize-autoloader": true + }, "repositories": [ { "type": "vcs", "url": "https://github.com/howyi/conv-test-suite.git", - "no-api": true + "no-api": false } ], "minimum-stability": "stable", "require": { - "php": ">=7.1", - "ext-PDO": "*", + "php": "^8.1", + "ext-PDO": "*", "symfony/console": ">=2.0", "composer/semver": "^1.4 || ^2.0 || ^3.0" }, @@ -50,13 +56,18 @@ } }, "require-dev": { - "phpunit/phpunit": "^6.2 || ^7.0", - "symfony/var-dumper": "^3.3", - "phpspec/prophecy": "^1.7", - "phpstan/phpstan": "^0.12.5", - "squizlabs/php_codesniffer": "^3.0", - "howyi/conv-test-suite": "dev-master", - "php-coveralls/php-coveralls": "^2.2" + "howyi/conv-test-suite": "dev-master", + "php-coveralls/php-coveralls": "^2.2", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpspec/prophecy-phpunit": "^2.4", + "phpstan/phpstan": "^2.1.22", + "phpunit/phpunit": "^10.5|^11.5|^12.3", + "rector/rector": "^2.1.4", + "roave/security-advisories": "dev-latest", + "squizlabs/php_codesniffer": "^3.0", + "symfony/var-dumper": ">=3.3" }, - "bin": ["bin/conv"] + "bin": [ + "bin/conv" + ] } diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index eb4eb91..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,113 +0,0 @@ -version: '3' -services: - test: - platform: linux/x86_64 - build: ./docker - working_dir: /usr/src/app - environment: - DB_HOST: mysql-56:3306,mysql-57:3306,mysql-80:3306,maria-100:3306,maria-101:3306,maria-102:3306,maria-103:3306,maria-113:3306 - command: ./docker/wait-for-it.sh -t 0 maria-103:3306 -- vendor/bin/phpunit - volumes: - - .:/usr/src/app - depends_on: - - maria-113 - - travis: - platform: linux/x86_64 - build: ./docker - working_dir: /usr/src/app - environment: - TRAVIS: - TRAVIS_JOB_ID: - DB_HOST: mysql-56:3306,mysql-57:3306,mysql-80:3306,maria-100:3306,maria-101:3306,maria-102:3306,maria-103:3306 - command: ./docker/wait-for-it.sh -t 0 maria-103:3306 -- ./docker/ci.sh - volumes: - - .:/usr/src/app - depends_on: - - maria-103 - - testdb: - platform: linux/x86_64 - image: mysql:8.0 - command: mysqld --default-authentication-plugin=mysql_native_password - security_opt: - - seccomp:unconfined - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - ports: - - 33060:3306 - - mysql-56: - platform: linux/x86_64 - image: mysql:5.6 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - - mysql-57: - platform: linux/x86_64 - image: mysql:5.7 - command: mysqld --general-log=true - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - mysql-56 - - mysql-80: - platform: linux/x86_64 - image: mysql:8.0 - command: mysqld --default-authentication-plugin=mysql_native_password - security_opt: - - seccomp:unconfined - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - mysql-57 - - maria-100: - platform: linux/x86_64 - image: mariadb:10.0 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - mysql-80 - - maria-101: - platform: linux/x86_64 - image: mariadb:10.1 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - maria-100 - - maria-102: - platform: linux/x86_64 - image: mariadb:10.2 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - maria-101 - - maria-103: - platform: linux/x86_64 - image: mariadb:10.3 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - maria-102 - - maria-113: - platform: linux/x86_64 - image: mariadb:11.3 - environment: - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - MYSQL_ROOT_PASSWORD: '' - depends_on: - - maria-103 diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..be17b6b --- /dev/null +++ b/rector.php @@ -0,0 +1,36 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withSets([ + SetList::PHP_72, + SetList::PHP_73, + SetList::PHP_74, + SetList::PHP_80, + SetList::PHP_81, + SetList::PHP_82, + SetList::PHP_83, + SetList::PHP_84, + SetList::PHP_85, + PHPUnitSetList::PHPUNIT_80, + PHPUnitSetList::PHPUNIT_90, + PHPUnitSetList::PHPUNIT_100, + PHPUnitSetList::PHPUNIT_110, + PHPUnitSetList::PHPUNIT_120, + ]) + ->withPhpSets( + php81: true, + // php82: true, + // php83: true, + // php84: true, + // php85: true, + ); diff --git a/src/Command/DiffDb2DbCommand.php b/src/Command/DiffDb2DbCommand.php index c2e89d6..df42f83 100644 --- a/src/Command/DiffDb2DbCommand.php +++ b/src/Command/DiffDb2DbCommand.php @@ -38,7 +38,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { - [$dbName1, $dbName2] = explode(':', $input->getArgument('dbNames')); + [$dbName1, $dbName2] = explode(':', (string) $input->getArgument('dbNames')); $pdo1 = $this->convertToPdo((string) $input->getOption('server1'), $dbName1); $db1Structure = DatabaseStructureFactory::fromPDO($pdo1, $dbName1); diff --git a/src/CreateQueryReflector.php b/src/CreateQueryReflector.php index 2fe7a6e..00a63ef 100644 --- a/src/CreateQueryReflector.php +++ b/src/CreateQueryReflector.php @@ -18,7 +18,7 @@ public static function fromPDO( string $dbName, string $path, OperatorInterface $operator, - callable $filter = null + ?callable $filter = null ) { $dbs = DatabaseStructureFactory::fromPDO( $pdo, @@ -57,7 +57,7 @@ public static function fromPDO( if (isset($showCreateTable['Create Table'])) { $query = preg_replace('/ AUTO_INCREMENT=[0-9]+/i', '', $showCreateTable['Create Table']); } else { - $query = preg_replace('/ DEFINER=.+ SQL SECURITY DEFINER/', '', $showCreateTable['Create View']); + $query = preg_replace('/ DEFINER=.+ SQL SECURITY DEFINER/', '', (string) $showCreateTable['Create View']); $query = strtr($query, [ ' AS select ' => ' AS select' . PHP_EOL . ' ', ',' => ',' . PHP_EOL . ' ', diff --git a/src/DatabaseStructureFactory.php b/src/DatabaseStructureFactory.php index 6bad3e3..ead4391 100644 --- a/src/DatabaseStructureFactory.php +++ b/src/DatabaseStructureFactory.php @@ -21,7 +21,7 @@ class DatabaseStructureFactory public static function fromPDO( \PDO $pdo, string $dbName, - callable $filter = null + ?callable $filter = null ): DatabaseStructure { $rawTableList = $pdo->query( "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '$dbName'" @@ -60,7 +60,7 @@ public static function fromSqlDir( \PDO $pdo, string $path, OperatorInterface $operator, - callable $filter = null, + ?callable $filter = null, $drop = true ): DatabaseStructure { $operator->output('Generate temporary database'); @@ -81,28 +81,22 @@ public static function fromSqlDir( } $query = file_get_contents($fileInfo->getRealPath()); $ddl = new class($query, $pdo, $operator) { - private $query; private $isView; private $hasCreated = false; private $references = []; - private $pdo; - private $operator; /** * @param string $query * @param \PDO $pdo * @param OperatorInterface $operator */ - public function __construct(string $query, \PDO $pdo, OperatorInterface $operator) + public function __construct(private readonly string $query, private readonly \PDO $pdo, private readonly OperatorInterface $operator) { - $this->query = $query; - $this->isView = false !== strpos($query, 'CREATE ALGORITHM'); - preg_match_all('/REFERENCES `?([a-zA-Z][a-zA-Z0-9_\ ]*?)`? /s', $query, $matches); + $this->isView = str_contains((string) $this->query, 'CREATE ALGORITHM'); + preg_match_all('/REFERENCES `?([a-zA-Z][a-zA-Z0-9_\ ]*?)`? /s', (string) $this->query, $matches); if (0 < count($matches[1])) { $this->references = $matches[1]; } - $this->pdo = $pdo; - $this->operator = $operator; } /** diff --git a/src/Driver/AbstractDriver.php b/src/Driver/AbstractDriver.php index 7f4cf35..80f9834 100644 --- a/src/Driver/AbstractDriver.php +++ b/src/Driver/AbstractDriver.php @@ -4,14 +4,11 @@ abstract class AbstractDriver implements DriverInterface { - private $PDO; - /** * @param \PDO $PDO */ - public function __construct(\PDO $PDO) + public function __construct(private readonly \PDO $PDO) { - $this->PDO = $PDO; } /** diff --git a/src/Driver/DriverAllocator.php b/src/Driver/DriverAllocator.php index 3bea9e2..b669381 100644 --- a/src/Driver/DriverAllocator.php +++ b/src/Driver/DriverAllocator.php @@ -20,25 +20,25 @@ public static function fromPDO(\PDO $PDO): DriverInterface $rawVersion = $PDO->getAttribute(\PDO::ATTR_SERVER_VERSION); preg_match( "/^[0-9\.]+/", - $rawVersion, + (string) $rawVersion, $match ); $type = $version = null; - if (strpos($rawVersion, 'MariaDB') !== false) { + if (str_contains((string) $rawVersion, 'MariaDB')) { $type = self::TYPE_MARIA_DB; - $split = explode('-', $rawVersion); + $split = explode('-', (string) $rawVersion); if (strtolower($split[1]) === 'mariadb') { // MariaDB 11 ~ $version = $split[0]; } else { $version = $split[1]; } - } elseif (strpos($rawVersion, 'TiDB') !== false){ + } elseif (str_contains((string) $rawVersion, 'TiDB')){ $type = self::TYPE_TIDB; $version = $match[0]; - } elseif (strtolower($driverName) === 'mysql') { + } elseif (strtolower((string) $driverName) === 'mysql') { $type = self::TYPE_MYSQL; $version = $match[0]; } diff --git a/src/Driver/MySQL56Driver.php b/src/Driver/MySQL56Driver.php index 1d02035..a88c314 100644 --- a/src/Driver/MySQL56Driver.php +++ b/src/Driver/MySQL56Driver.php @@ -143,16 +143,16 @@ protected function createColumnStructureList(string $dbName, string $tableName): protected function createColumnStructure(array $rawColumn): ColumnStructureInterface { $attribute = []; - if ((bool) preg_match('/auto_increment/', $rawColumn['EXTRA'])) { + if ((bool) preg_match('/auto_increment/', (string) $rawColumn['EXTRA'])) { $attribute[] = Attribute::AUTO_INCREMENT; } if ('YES' === $rawColumn['IS_NULLABLE']) { $attribute[] = Attribute::NULLABLE; } - if ((bool) preg_match('/unsigned/', $rawColumn['COLUMN_TYPE'])) { + if ((bool) preg_match('/unsigned/', (string) $rawColumn['COLUMN_TYPE'])) { $attribute[] = Attribute::UNSIGNED; } - if ((bool) preg_match('/STORED/', $rawColumn['EXTRA'])) { + if ((bool) preg_match('/STORED/', (string) $rawColumn['EXTRA'])) { $attribute[] = Attribute::STORED; } @@ -200,7 +200,7 @@ protected function createIndexStructureList(string $dbName, string $tableName): protected function getDefaultCharset(string $dbName, string $tableName): string { $createQuery = $this->PDO()->query("SHOW CREATE TABLE $tableName")->fetch()[1]; - $defaultCharsetSearch = mb_strstr($createQuery, 'DEFAULT CHARSET='); + $defaultCharsetSearch = mb_strstr((string) $createQuery, 'DEFAULT CHARSET='); if (false !== $defaultCharsetSearch) { $defaultCharsetSearch = str_replace('DEFAULT CHARSET=', '', $defaultCharsetSearch); return explode(' ', $defaultCharsetSearch)[0]; diff --git a/src/Driver/MySQL57Driver.php b/src/Driver/MySQL57Driver.php index ddb2f77..05b8928 100644 --- a/src/Driver/MySQL57Driver.php +++ b/src/Driver/MySQL57Driver.php @@ -12,16 +12,16 @@ class MySQL57Driver extends MySQL56Driver protected function createColumnStructure(array $rawColumn): ColumnStructureInterface { $attribute = []; - if ((bool) preg_match('/auto_increment/', $rawColumn['EXTRA'])) { + if ((bool) preg_match('/auto_increment/', (string) $rawColumn['EXTRA'])) { $attribute[] = Attribute::AUTO_INCREMENT; } if ('YES' === $rawColumn['IS_NULLABLE']) { $attribute[] = Attribute::NULLABLE; } - if ((bool) preg_match('/unsigned/', $rawColumn['COLUMN_TYPE'])) { + if ((bool) preg_match('/unsigned/', (string) $rawColumn['COLUMN_TYPE'])) { $attribute[] = Attribute::UNSIGNED; } - if ((bool) preg_match('/STORED/', $rawColumn['EXTRA'])) { + if ((bool) preg_match('/STORED/', (string) $rawColumn['EXTRA'])) { $attribute[] = Attribute::STORED; } diff --git a/src/Driver/TiDBTempDriver.php b/src/Driver/TiDBTempDriver.php index 3873d67..ffb9847 100644 --- a/src/Driver/TiDBTempDriver.php +++ b/src/Driver/TiDBTempDriver.php @@ -48,15 +48,15 @@ protected function createColumnStructure(array $rawColumn, ?string $rawPkStatus if ('YES' === $rawColumn['IS_NULLABLE']) { $attribute[] = Attribute::NULLABLE; } - if ((bool) preg_match('/unsigned/', $rawColumn['COLUMN_TYPE'])) { + if ((bool) preg_match('/unsigned/', (string) $rawColumn['COLUMN_TYPE'])) { $attribute[] = Attribute::UNSIGNED; } - if ((bool) preg_match('/STORED/', $rawColumn['EXTRA'])) { + if ((bool) preg_match('/STORED/', (string) $rawColumn['EXTRA'])) { $attribute[] = Attribute::STORED; } - if ((bool) preg_match('/PK_AUTO_RANDOM/', $rawPkStatus) && $rawColumn['COLUMN_KEY'] == 'PRI') { - preg_match_all('/[0-9]+/', $rawPkStatus, $bit_range); + if ((bool) preg_match('/PK_AUTO_RANDOM/', (string) $rawPkStatus) && $rawColumn['COLUMN_KEY'] == 'PRI') { + preg_match_all('/[0-9]+/', (string) $rawPkStatus, $bit_range); $auto_random = [ 'AUTO_RANDOM', $bit_range[0][0], diff --git a/src/Generator/FieldOrderGenerator.php b/src/Generator/FieldOrderGenerator.php index ae18e5e..75620db 100644 --- a/src/Generator/FieldOrderGenerator.php +++ b/src/Generator/FieldOrderGenerator.php @@ -60,7 +60,7 @@ public static function generate(array $before, array $after): array ); $rightSide = self::oneside($beforeRightSide, $afterRightSide); - list($bothSide, $num) = self::bothsides($leftSide, $center, $rightSide); + [$bothSide, $num] = self::bothsides($leftSide, $center, $rightSide); $sides[$num] = $bothSide; } diff --git a/src/Migration/Line/IndexAllMigrationLine.php b/src/Migration/Line/IndexAllMigrationLine.php index b08ec8f..e5e1090 100644 --- a/src/Migration/Line/IndexAllMigrationLine.php +++ b/src/Migration/Line/IndexAllMigrationLine.php @@ -7,18 +7,11 @@ */ class IndexAllMigrationLine { - private $first; - private $last; - /** * @param bool */ - public function __construct( - IndexDropMigrationLine $first = null, - IndexAddMigrationLine $last = null - ) { - $this->first = $first; - $this->last = $last; + public function __construct(private ?\Howyi\Conv\Migration\Line\IndexDropMigrationLine $first = null, private ?\Howyi\Conv\Migration\Line\IndexAddMigrationLine $last = null) + { } /** diff --git a/src/Migration/Table/TableAlterMigration.php b/src/Migration/Table/TableAlterMigration.php index 23f1a70..99e230b 100644 --- a/src/Migration/Table/TableAlterMigration.php +++ b/src/Migration/Table/TableAlterMigration.php @@ -11,7 +11,6 @@ class TableAlterMigration extends AbstractTableMigration { private $isAltered = false; - private $renamedNameList; /** * @param string $beforeTableName @@ -24,12 +23,11 @@ public function __construct( string $beforeTableName, string $afterTableName, MigrationLineList $migrationLineList, - array $renamedNameList, + private readonly array $renamedNameList, ?PartitionMigration $partitionMigration ) { $this->tableName = $beforeTableName; $this->type = MigrationType::ALTER; - $this->renamedNameList = $renamedNameList; $this->isAltered = ($migrationLineList->isMigratable() or !is_null($partitionMigration)); diff --git a/src/Migration/Table/ViewAlterMigration.php b/src/Migration/Table/ViewAlterMigration.php index 09e70fd..9c7005d 100644 --- a/src/Migration/Table/ViewAlterMigration.php +++ b/src/Migration/Table/ViewAlterMigration.php @@ -38,7 +38,7 @@ public function __construct( foreach ($allRenamedNameList as $renamedNameList) { $count = 0; foreach ($renamedNameList as $name) { - $count += (strpos($this->up, $name) === false) ? 0 : 1; + $count += (!str_contains((string) $this->up, (string) $name)) ? 0 : 1; } if ($count === count($renamedNameList)) { $this->isSplit = true; diff --git a/src/Structure/DatabaseStructure.php b/src/Structure/DatabaseStructure.php index b9b946a..8dfd730 100644 --- a/src/Structure/DatabaseStructure.php +++ b/src/Structure/DatabaseStructure.php @@ -4,15 +4,11 @@ class DatabaseStructure { - private $tableList = []; - /** * @param TableStructureInterface[] $tableList */ - public function __construct( - array $tableList - ) { - $this->tableList = $tableList; + public function __construct(private readonly array $tableList) + { } /** diff --git a/src/Structure/IndexStructure.php b/src/Structure/IndexStructure.php index 22fd417..651c3ba 100644 --- a/src/Structure/IndexStructure.php +++ b/src/Structure/IndexStructure.php @@ -47,7 +47,7 @@ public function generateCreateQuery(): string if ($this->isUnique) { $query[] = 'UNIQUE'; } elseif ($this->isBtree === false) { - $query[] = strtoupper($this->indexType); + $query[] = strtoupper((string) $this->indexType); } $query[] = 'KEY'; @@ -70,7 +70,7 @@ public function generateAddQuery(): string if ($this->isUnique) { $query[] = 'UNIQUE'; } elseif ($this->isBtree === false) { - $query[] = strtoupper($this->indexType); + $query[] = strtoupper((string) $this->indexType); } else { $query[] = 'INDEX'; } @@ -109,7 +109,7 @@ private function getQueryNameList(): array { $list = []; foreach ($this->columnNameList as $name) { - preg_match('/\(.+?\)/', $name, $match); + preg_match('/\(.+?\)/', (string) $name, $match); if (!empty($match)) { $subPart = $match[0]; $actualName = str_replace($subPart, '', $name); diff --git a/src/Structure/JoinStructure.php b/src/Structure/JoinStructure.php index 36cff5b..25e70cd 100644 --- a/src/Structure/JoinStructure.php +++ b/src/Structure/JoinStructure.php @@ -6,9 +6,6 @@ class JoinStructure { - private $joinArray; - private $aliasList; - const MYSQL_OPERATOR = [ '=', '<=>', @@ -24,12 +21,8 @@ class JoinStructure * @param array $joinArray * @param array $aliasList */ - public function __construct( - array $joinArray, - array $aliasList - ) { - $this->joinArray = $joinArray; - $this->aliasList = $aliasList; + public function __construct(private array $joinArray, private readonly array $aliasList) + { } /** @@ -90,7 +83,7 @@ private function graveDecorator(string $text): string foreach ($match as $part) { $originPart = ltrim(rtrim($part, ')'), '('); $part = $this->gravePartDecorator($originPart); - $text = preg_replace("/$originPart/", $part, $text, 1); + $text = preg_replace("/$originPart/", $part, (string) $text, 1); } return $text; } @@ -112,7 +105,7 @@ private function gravePartDecorator(string $text): string } foreach (explode('.', trim($pieces)) as $piece) { $insert = sprintf($sep, $id); - $text = preg_replace("/$piece/", $insert, $text, 1); + $text = preg_replace("/$piece/", $insert, (string) $text, 1); $replace[] = $insert; $replaced[] = "`$piece`"; $id++; diff --git a/src/Structure/PartitionLongStructure.php b/src/Structure/PartitionLongStructure.php index f46b5b1..f276616 100755 --- a/src/Structure/PartitionLongStructure.php +++ b/src/Structure/PartitionLongStructure.php @@ -4,23 +4,16 @@ class PartitionLongStructure implements PartitionStructureInterface { - private $type; - private $value; - private $parts; - /** * @param string $type * @param string $value * @param PartitionPartStructure[] $parts */ public function __construct( - string $type, - string $value, - array $parts + private readonly string $type, + private readonly string $value, + private array $parts ) { - $this->type = $type; - $this->value = $value; - $this->parts = $parts; ksort($this->parts); } diff --git a/src/Structure/PartitionPartStructure.php b/src/Structure/PartitionPartStructure.php index 0284341..75bbd8b 100755 --- a/src/Structure/PartitionPartStructure.php +++ b/src/Structure/PartitionPartStructure.php @@ -4,27 +4,14 @@ class PartitionPartStructure { - private $name; - private $operator; - private $value; - private $comment; - /** * @param string $name * @param string $operator * @param string $value * @param string $comment */ - public function __construct( - string $name, - string $operator, - string $value, - string $comment - ) { - $this->name = $name; - $this->operator = $operator; - $this->value = $value; - $this->comment = $comment; + public function __construct(private readonly string $name, private readonly string $operator, private readonly string $value, private readonly string $comment) + { } /** diff --git a/src/Structure/PartitionShortStructure.php b/src/Structure/PartitionShortStructure.php index c521566..67cf077 100755 --- a/src/Structure/PartitionShortStructure.php +++ b/src/Structure/PartitionShortStructure.php @@ -4,23 +4,13 @@ class PartitionShortStructure implements PartitionStructureInterface { - private $type; - private $value; - private $num; - /** * @param string $type * @param string $value * @param int $num */ - public function __construct( - string $type, - string $value, - int $num - ) { - $this->type = $type; - $this->value = $value; - $this->num = $num; + public function __construct(private readonly string $type, private readonly string $value, private readonly int $num) + { } /** diff --git a/src/Structure/TableStructure.php b/src/Structure/TableStructure.php index 16865e5..0dd3ca2 100644 --- a/src/Structure/TableStructure.php +++ b/src/Structure/TableStructure.php @@ -14,8 +14,6 @@ class TableStructure implements TableStructureInterface public $collate; public $columnStructureList; public $indexStructureList; - private $partition; - private $properties; /** * @param string $tableName @@ -36,8 +34,8 @@ public function __construct( string $collate, array $columnStructureList, array $indexStructureList, - $partition, - array $properties + private $partition, + private readonly array $properties ) { $this->tableName = $tableName; $this->comment = $comment; @@ -46,8 +44,6 @@ public function __construct( $this->collate = $collate; $this->columnStructureList = $columnStructureList; $this->indexStructureList = $indexStructureList; - $this->partition = $partition; - $this->properties = $properties; } /** diff --git a/src/Structure/ViewStructure.php b/src/Structure/ViewStructure.php index 909f573..b248bd1 100644 --- a/src/Structure/ViewStructure.php +++ b/src/Structure/ViewStructure.php @@ -6,23 +6,13 @@ class ViewStructure implements TableStructureInterface { - private $viewName; - private $createQuery; - private $properties; - /** * @param string $viewName * @param string $createQuery * @param array $properties */ - public function __construct( - string $viewName, - string $createQuery, - array $properties - ) { - $this->viewName = $viewName; - $this->createQuery = $createQuery; - $this->properties = $properties; + public function __construct(private readonly string $viewName, private readonly string $createQuery, private readonly array $properties) + { } /** diff --git a/src/Util/FieldOrder.php b/src/Util/FieldOrder.php index 6cedcb7..37071f9 100644 --- a/src/Util/FieldOrder.php +++ b/src/Util/FieldOrder.php @@ -4,23 +4,13 @@ class FieldOrder { - private $field; - private $previousAfterField; - private $nextAfterField; - /** * @param string $field * @param string|null $previousAfterField * @param string|null $nextAfterField */ - public function __construct( - string $field, - $previousAfterField, - $nextAfterField - ) { - $this->field = $field; - $this->previousAfterField = $previousAfterField; - $this->nextAfterField = $nextAfterField; + public function __construct(private readonly string $field, private $previousAfterField, private $nextAfterField) + { } /** diff --git a/tests/Generator/FieldOrderGeneratorTest.php b/tests/Generator/FieldOrderGeneratorTest.php index d203e64..c93f7d2 100644 --- a/tests/Generator/FieldOrderGeneratorTest.php +++ b/tests/Generator/FieldOrderGeneratorTest.php @@ -6,16 +6,14 @@ class FieldOrderGeneratorTest extends \PHPUnit\Framework\TestCase { - /** - * @dataProvider generateProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateProvider')] public function testGenerate($before, $after, $expected) { $actual = FieldOrderGenerator::generate($before, $after); $this->assertEquals($expected, $actual); } - public function generateProvider() + public static function generateProvider() { return [ [ @@ -48,16 +46,14 @@ public function generateProvider() ]; } - /** - * @dataProvider onesideProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('onesideProvider')] public function testOneside($before, $after, $expected) { $actual = FieldOrderGenerator::oneside($before, $after); $this->assertEquals($expected, $actual); } - public function onesideProvider() + public static function onesideProvider() { return [ [ diff --git a/tests/Generator/IndexMigrationGeneratorTest.php b/tests/Generator/IndexMigrationGeneratorTest.php index cbf474f..2a9558e 100644 --- a/tests/Generator/IndexMigrationGeneratorTest.php +++ b/tests/Generator/IndexMigrationGeneratorTest.php @@ -9,16 +9,14 @@ class IndexMigrationGeneratorTest extends \PHPUnit\Framework\TestCase { - /** - * @dataProvider generateProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateProvider')] public function testGenerate($before, $after, $expected) { $actual = IndexMigrationGenerator::generate($before, $after); $this->assertEquals($expected, $actual); } - public function generateProvider() + public static function generateProvider() { return [ [ diff --git a/tests/MigrationGeneratorMultiTest.php b/tests/MigrationGeneratorMultiTest.php index 6026985..5ef3de2 100644 --- a/tests/MigrationGeneratorMultiTest.php +++ b/tests/MigrationGeneratorMultiTest.php @@ -16,22 +16,22 @@ class MigrationGeneratorMultiTest extends \PHPUnit\Framework\TestCase { private $prophet; - protected function setup() + protected function setup(): void { $this->prophet = new \Prophecy\Prophet(); } - protected function tearDown() + protected function tearDown(): void { $this->prophet->checkPredictions(); } /** - * @dataProvider generateProvider * @param string $dir * @param string $calls * @param string $expected */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateProvider')] public function testGenerate($dir, $calls, $expected, $pdo) { $operator = $this->prophet->prophesize(ConsoleOperator::class); @@ -71,7 +71,7 @@ public function testGenerate($dir, $calls, $expected, $pdo) } } - public function generateProvider() + public static function generateProvider() { $values = [ [ diff --git a/tests/MigrationGeneratorSingleTest.php b/tests/MigrationGeneratorSingleTest.php index 091c3f8..8b36511 100644 --- a/tests/MigrationGeneratorSingleTest.php +++ b/tests/MigrationGeneratorSingleTest.php @@ -10,18 +10,17 @@ class MigrationGeneratorSingleTest extends \PHPUnit\Framework\TestCase { private $prophet; - protected function setup() + protected function setup(): void { $this->prophet = new \Prophecy\Prophet(); } - protected function tearDown() + protected function tearDown(): void { $this->prophet->checkPredictions(); } /** - * @dataProvider generateProvider * @param string $name * @param string $beforeDir * @param string $afterDir @@ -29,10 +28,11 @@ protected function tearDown() * @param string $downPath * @param \PDO $pdo */ + #[\PHPUnit\Framework\Attributes\DataProvider('generateProvider')] public function testGenerate($name, $beforeDir, $afterDir, $upPath, $downPath, $pdo) { $mysqlVersion = $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION); - preg_match("/^[0-9\.]+/", $mysqlVersion, $match); + preg_match("/^[0-9\.]+/", (string) $mysqlVersion, $match); $mysqlVersion = $match[0]; $exploded = explode(':', $name); @@ -101,7 +101,7 @@ public function testGenerate($name, $beforeDir, $afterDir, $upPath, $downPath, $ ); } - public function generateProvider() + public static function generateProvider() { $dir = 'vendor/howyi/conv-test-suite/cases/part/'; diff --git a/tests/Operator/ConsoleOperatorTest.php b/tests/Operator/ConsoleOperatorTest.php index da2aea3..b508d82 100644 --- a/tests/Operator/ConsoleOperatorTest.php +++ b/tests/Operator/ConsoleOperatorTest.php @@ -17,7 +17,7 @@ class ConsoleOperatorTest extends \PHPUnit\Framework\TestCase /** * {@inheritdoc} */ - protected function setup() + protected function setup(): void { $this->prophet = new \Prophecy\Prophet(); } @@ -25,7 +25,7 @@ protected function setup() /** * {@inheritdoc} */ - protected function tearDown() + protected function tearDown(): void { $this->prophet->checkPredictions(); } diff --git a/tests/TestUtility.php b/tests/TestUtility.php index bedc4fa..d99c319 100644 --- a/tests/TestUtility.php +++ b/tests/TestUtility.php @@ -10,10 +10,10 @@ class TestUtility */ public static function getPdoArray(?string $dbName = null): array { - $hostEnv = getenv('DB_HOST') ? getenv('DB_HOST') : '127.0.0.1:3306'; + $hostEnv = getenv('DB_HOST') ?: '127.0.0.1:3306'; $hosts = explode(',', $hostEnv); - $rootName = getenv('DB_ROOT_NAME') ? getenv('DB_ROOT_NAME') : 'root'; - $rootPass = getenv('DB_ROOT_PASS') ? getenv('DB_ROOT_PASS') : ''; + $rootName = getenv('DB_ROOT_NAME') ?: 'root'; + $rootPass = getenv('DB_ROOT_PASS') ?: ''; $pdoArray = []; foreach ($hosts as $hostEnv) { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6a2271e..4f49c73 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,7 +1,7 @@ exec('DROP DATABASE IF EXISTS conv_test');