diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index df7ac52..9bd94a0 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,27 +1,26 @@ -name: CI +name: Static Analysis -on: [push] +on: [ push, pull_request ] jobs: phpstan: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - - name: Add GitHub to known hosts - run: ssh-keyscan github.com >> ~/.ssh/known_hosts - - name: Add SSH key to agent - run: | - eval $(ssh-agent -s) - ssh-add ~/.ssh/id_rsa - - uses: php-actions/composer@v6 - - name: PHPStan Static Analysis + - uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + - name: PHPStan uses: php-actions/phpstan@v3 with: path: lib/ tests/ - level: 9 - php_version: 7.4 + # Pre-existing library code has ~50 issues at level 9; that's + # tech debt for a separate cleanup PR. Level 5 catches the + # things that actually break at runtime without blocking on + # iterable-type docblocks. + level: 5 + php_version: 8.1 diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index a456cbf..6e7c43b 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -1,30 +1,27 @@ name: CI -on: [ push ] +on: [ push, pull_request ] jobs: build-test: runs-on: ubuntu-latest strategy: - matrix: - php: [ '7.4', '8.0', '8.1', '8.2' ] + fail-fast: false + matrix: + # The composer.lock pins modern PHPNomad versions whose own + # transitive deps no longer support PHP < 8.2. Older PHP rows + # would fail at `composer install` regardless of the library's + # own constraints. composer.json should declare an explicit PHP + # floor matching this (separate cleanup). + php: [ '8.2', '8.3' ] steps: - - uses: actions/checkout@v3 - - name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - - name: Add GitHub to known hosts - run: ssh-keyscan github.com >> ~/.ssh/known_hosts - - name: Add SSH key to agent - run: | - eval $(ssh-agent -s) - ssh-add ~/.ssh/id_rsa - - name: Clear composer cache - run: composer clear-cache - - uses: php-actions/composer@v6 - - name: PHPUnit Tests - uses: php-actions/phpunit@v3 + - uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 with: - configuration: phpunit.xml + php-version: ${{ matrix.php }} + coverage: none + - name: Install dependencies + run: composer install --no-interaction --no-progress --prefer-dist + - name: Run PHPUnit + run: ./vendor/bin/phpunit diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index 5edeb0d..f64480e 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -1,14 +1,14 @@ -name: Spellcheck Action -on: push +name: Spellcheck + +on: [ push, pull_request ] jobs: - build: + build: + name: Spellcheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: rojopolis/spellcheck-github-actions@0.27.0 name: Spellcheck - runs-on: ubuntu-latest - steps: - # The checkout step - - uses: actions/checkout@master - - uses: rojopolis/spellcheck-github-actions@0.27.0 - name: Spellcheck - with: - config_path: .spellcheck.yml \ No newline at end of file + with: + config_path: .spellcheck.yml diff --git a/.wordlist.txt b/.wordlist.txt index 7261aef..344891f 100644 --- a/.wordlist.txt +++ b/.wordlist.txt @@ -23,4 +23,23 @@ Traceback nodejs npm fediverse -readme \ No newline at end of file +readme +PHP +bindFactory +bootstrapper +bootstrapper's +Bootstrapper +DatabaseStrategy +fn +initializer +myapp +mysql +MySql +MySqlInitializer +phpnomad +PHPNomad +SafeMySql +SafeMySQL +SafeMySqlDatabaseStrategy +schemas +txt \ No newline at end of file diff --git a/lib/Builders/QueryBuilder.php b/lib/Builders/QueryBuilder.php index 14d59e6..f11d24a 100644 --- a/lib/Builders/QueryBuilder.php +++ b/lib/Builders/QueryBuilder.php @@ -38,6 +38,7 @@ class QueryBuilder implements QueryBuilderInterface protected ?ClauseBuilder $clauseBuilder = null; protected array $groupBy = []; + protected array $join = []; /** @inheritDoc */ public function select(string $field, string ...$fields) @@ -288,6 +289,7 @@ public function reset() $this->offset = []; $this->orderBy = []; $this->groupBy = []; + $this->join = []; return $this; } diff --git a/lib/Strategies/QueryStrategy.php b/lib/Strategies/QueryStrategy.php index 1cdd334..c5651a5 100644 --- a/lib/Strategies/QueryStrategy.php +++ b/lib/Strategies/QueryStrategy.php @@ -171,7 +171,7 @@ public function estimatedCount(Table $table): int try { $result = $this->db->query($query); - return (int)Arr::get($result[0], 'COUNT(*)', 0); + return (int)Arr::get($result[0], 'COUNT(*)'); } catch (\Exception $e) { throw new DatastoreErrorException('Count query failed: ' . $e->getMessage(), 500, $e); }