From 74536d6d044c76ac85050dc83f7c657cb6a0ee01 Mon Sep 17 00:00:00 2001 From: Sanikovich Aleksey Date: Tue, 25 Oct 2022 00:22:21 +0300 Subject: [PATCH] Add .github/workflows with fixes (#52) add .github/workflows with fixes --- .flintci.yml | 2 -- .github/workflows/phpstan.yml | 38 +++++++++++++++++++++++++++ .github/workflows/tests.yml | 48 +++++++++++++++++++++++++++++++++++ .travis.yml | 28 -------------------- composer.json | 5 ++++ src/ClickHouseStatement.php | 12 ++++++--- src/Connection.php | 20 +++++++-------- 7 files changed, 109 insertions(+), 44 deletions(-) delete mode 100644 .flintci.yml create mode 100644 .github/workflows/phpstan.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.flintci.yml b/.flintci.yml deleted file mode 100644 index 9193742..0000000 --- a/.flintci.yml +++ /dev/null @@ -1,2 +0,0 @@ -services: - composernormalize: true \ No newline at end of file diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..38aaf26 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,38 @@ +name: Static analysis + +on: + push: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + phpstan: + name: PHPStan + runs-on: Ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: pdo + ini-values: "memory_limit=-1" + coverage: none + tools: phpstan + + - name: Install dependencies + run: | + composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false + composer install --prefer-dist + + - name: phpstan + run: phpstan analyse -l 5 src diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..1a94f84 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,48 @@ +name: Tests + +on: + push: + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + + tests: + name: Tests + runs-on: Ubuntu-20.04 + + strategy: + matrix: + php-versions: ['7.1', '7.4', '8.0', '8.1'] + fail-fast: false + + services: + clickhouse: + image: yandex/clickhouse-server + ports: + - 8123:8123 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: pdo + ini-values: "memory_limit=-1" + tools: composer + coverage: xdebug + + - name: Install dependencies + run: composer install --prefer-dist + + - name: Run tests + run: ./vendor/bin/phpunit --configuration ./phpunit.xml.dist --coverage-text \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 018eee8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: php -dist: trusty -sudo: required - -php: - - 7.1 - - 7.2 - - 8.0 - - nightly - -services: - - docker -before_install: - - docker run -d -p 127.0.0.1:8123:8123 --name test-clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server - - docker ps -a - - sed -i 's/localhost/clickhouse-server/' ./phpunit.xml.dist - - echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null - -before_script: - - composer install - -script: - - ./vendor/bin/phpunit --configuration ./phpunit.xml.dist - -matrix: - fast_finish: true - allow_failures: - - php: nightly diff --git a/composer.json b/composer.json index 4edf40a..3328fc5 100644 --- a/composer.json +++ b/composer.json @@ -44,5 +44,10 @@ "psr-4": { "FOD\\DBALClickHouse\\Tests\\": "tests/" } + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/src/ClickHouseStatement.php b/src/ClickHouseStatement.php index 3f5e7c6..d88634e 100644 --- a/src/ClickHouseStatement.php +++ b/src/ClickHouseStatement.php @@ -241,27 +241,31 @@ public function fetchColumn($columnIndex = 0) /** * {@inheritDoc} */ - public function bindValue($param, $value, $type = null) + public function bindValue($param, $value, $type = null): bool { $this->values[$param] = $value; $this->types[$param] = $type; + + return true; } /** * {@inheritDoc} */ - public function bindParam($column, &$variable, $type = null, $length = null) + public function bindParam($column, &$variable, $type = null, $length = null): bool { $this->values[$column] = &$variable; $this->types[$column] = $type; + + return true; } - public function errorCode() : void + public function errorCode() : int { throw new ClickHouseException('You need to implement ClickHouseStatement::' . __METHOD__ . '()'); } - public function errorInfo() : void + public function errorInfo() : array { throw new ClickHouseException('You need to implement ClickHouseStatement::' . __METHOD__ . '()'); } diff --git a/src/Connection.php b/src/Connection.php index 18609ce..316bf62 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -40,7 +40,7 @@ public function executeUpdate($query, array $params = [], array $types = []) : i /** * @throws ClickHouseException */ - public function delete($tableExpression, array $identifier, array $types = []) : void + public function delete($tableExpression, array $identifier, array $types = []) : int { throw ClickHouseException::notSupported(__METHOD__); } @@ -48,7 +48,7 @@ public function delete($tableExpression, array $identifier, array $types = []) : /** * @throws ClickHouseException */ - public function update($tableExpression, array $data, array $identifier, array $types = []) : void + public function update($tableExpression, array $data, array $identifier, array $types = []) : int { throw ClickHouseException::notSupported(__METHOD__); } @@ -60,7 +60,7 @@ public function update($tableExpression, array $data, array $identifier, array $ /** * @throws ClickHouseException */ - public function setTransactionIsolation($level) : void + public function setTransactionIsolation($level) : int { throw ClickHouseException::notSupported(__METHOD__); } @@ -68,7 +68,7 @@ public function setTransactionIsolation($level) : void /** * @throws ClickHouseException */ - public function getTransactionIsolation() : void + public function getTransactionIsolation() : int { throw ClickHouseException::notSupported(__METHOD__); } @@ -76,7 +76,7 @@ public function getTransactionIsolation() : void /** * @throws ClickHouseException */ - public function getTransactionNestingLevel() : void + public function getTransactionNestingLevel() : int { throw ClickHouseException::notSupported(__METHOD__); } @@ -100,7 +100,7 @@ public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoint /** * @throws ClickHouseException */ - public function getNestTransactionsWithSavepoints() : void + public function getNestTransactionsWithSavepoints() : bool { throw ClickHouseException::notSupported(__METHOD__); } @@ -108,7 +108,7 @@ public function getNestTransactionsWithSavepoints() : void /** * @throws ClickHouseException */ - public function beginTransaction() : void + public function beginTransaction() : bool { throw ClickHouseException::notSupported(__METHOD__); } @@ -116,7 +116,7 @@ public function beginTransaction() : void /** * @throws ClickHouseException */ - public function commit() : void + public function commit() : bool { throw ClickHouseException::notSupported(__METHOD__); } @@ -124,7 +124,7 @@ public function commit() : void /** * @throws ClickHouseException */ - public function rollBack() : void + public function rollBack() : bool { throw ClickHouseException::notSupported(__METHOD__); } @@ -164,7 +164,7 @@ public function setRollbackOnly() : void /** * @throws ClickHouseException */ - public function isRollbackOnly() : void + public function isRollbackOnly() : bool { throw ClickHouseException::notSupported(__METHOD__); }