Skip to content

Commit

Permalink
Merge pull request #6 from emonkak/php-8
Browse files Browse the repository at this point in the history
Update PHP restriction to 8.1 or higher
  • Loading branch information
emonkak committed May 16, 2024
2 parents 9b3611f + 2d5f0c8 commit 5ffbaac
Show file tree
Hide file tree
Showing 104 changed files with 2,243 additions and 2,476 deletions.
2 changes: 0 additions & 2 deletions .coveralls.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
test:
strategy:
matrix:
include:
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout the repository
uses: actions/checkout@v4
- 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-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-ansi --no-interaction --no-progress --prefer-dist
- name: Run Psalm
run: ./vendor/bin/psalm --no-cache --no-progress
- name: Run PHP CS Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --stop-on-violation --show-progress=none --verbose
- name: Run tests
run: ./vendor/bin/phpunit --coverage-clover ./coverage/clover.xml
- name: Upload coverage results
continue-on-error: true
uses: coverallsapp/github-action@v2
with:
file: ./coverage/clover.xml
flag-name: php-${{ matrix.php-version }}
parallel: true
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
/.php_cs.cache
/.php-cs-fixer.cache
/.phpunit.cache/
/.phpunit.result.cache
/composer.lock
/vendor/
4 changes: 2 additions & 2 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'@Symfony' => true,
Expand Down
6 changes: 6 additions & 0 deletions .phpactor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "/phpactor.schema.json",
"language_server_psalm.enabled": false,
"language_server_php_cs_fixer.enabled": true,
"prophecy.enabled": true
}
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Emonkak\Orm

[![Build Status](https://travis-ci.org/emonkak/php-orm.svg?branch=master)](https://travis-ci.org/emonkak/php-orm)
[![Coverage Status](https://coveralls.io/repos/github/emonkak/php-orm/badge.svg?branch=master)](https://coveralls.io/github/emonkak/php-orm?branch=master)
![CI Status](https://github.com/emonkak/php-orm/actions/workflows/ci.yml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/emonkak/php-orm/badge.svg)](https://coveralls.io/github/emonkak/php-orm)
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
}
],
"require": {
"php": ">=7.2",
"emonkak/enumerable": "^1.0",
"emonkak/database": "^1.0",
"php": ">=8.1",
"emonkak/enumerable": "^2.0",
"emonkak/database": "^2.0",
"psr/simple-cache": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"satooshi/php-coveralls": "^2.0",
"vimeo/psalm": "~3.11.0",
"friendsofphp/php-cs-fixer": "^2.16"
"friendsofphp/php-cs-fixer": "^3.56.1",
"phpunit/phpunit": "^10.5.20",
"vimeo/psalm": "^5.24.0"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 15 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true">
<phpunit
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
Expand All @@ -8,9 +18,9 @@
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<source>
<include>
<directory>./src/</directory>
</whitelist>
</filter>
</include>
</source>
</phpunit>
5 changes: 4 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<?xml version="1.0"?>
<psalm
totallyTyped="true"
errorLevel="2"
findUnusedBaselineEntry="true"
findUnusedCode="false"
resolveFromConfigFile="true"
totallyTyped="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<directory name="tests" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
Expand Down
5 changes: 1 addition & 4 deletions src/Aggregatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@ public function sum(PDOInterface $pdo, string $expr): int
return (int) $this->aggregate($pdo, "SUM($expr)");
}

/**
* @return mixed
*/
abstract public function aggregate(PDOInterface $pdo, string $expr);
abstract public function aggregate(PDOInterface $pdo, string $expr): mixed;
}
42 changes: 9 additions & 33 deletions src/DeleteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,13 @@ class DeleteBuilder implements QueryBuilderInterface
use Explainable;
use Preparable;

/**
* @var GrammarInterface
*/
private $grammar;

/**
* @var string
*/
private $prefix = 'DELETE';

/**
* @var string
*/
private $from = '';

/**
* @var ?Sql
*/
private $where;
private GrammarInterface $grammar;

private string $prefix = 'DELETE';

private string $from = '';

private ?Sql $where = null;

public function __construct(GrammarInterface $grammar)
{
Expand Down Expand Up @@ -73,27 +61,15 @@ public function from(string $table): self
return $cloned;
}

/**
* @param mixed $arg1
* @param mixed $arg2
* @param mixed $arg3
* @param mixed $arg4
*/
public function where($arg1, $arg2 = null, $arg3 = null, $arg4 = null): self
public function where(mixed $arg1, mixed $arg2 = null, mixed $arg3 = null, mixed $arg4 = null): self
{
$condition = $this->grammar->condition(...func_get_args());
$cloned = clone $this;
$cloned->where = $this->where ? Sql::and($this->where, $condition) : $condition;
return $cloned;
}

/**
* @param mixed $arg1
* @param mixed $arg2
* @param mixed $arg3
* @param mixed $arg4
*/
public function orWhere($arg1, $arg2 = null, $arg3 = null, $arg4 = null): self
public function orWhere(mixed $arg1, mixed $arg2 = null, mixed $arg3 = null, mixed $arg4 = null): self
{
$condition = $this->grammar->condition(...func_get_args());
$cloned = clone $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Fetchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ trait Fetchable
{
/**
* @template TResult
* @psalm-param FetcherInterface<TResult> $fetcher
* @psalm-return ResultSetInterface<TResult>
* @param FetcherInterface<TResult> $fetcher
* @return ResultSetInterface<TResult>
*/
public function getResult(FetcherInterface $fetcher): ResultSetInterface
{
Expand Down
16 changes: 3 additions & 13 deletions src/Fetcher/ArrayFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@
use Emonkak\Orm\ResultSet\ResultSetInterface;

/**
* @template T of array
* @implements FetcherInterface<T>
* @implements FetcherInterface<array<string,mixed>>
*/
class ArrayFetcher implements FetcherInterface
{
/**
* @use Relatable<T>
* @use Relatable<array<string,mixed>>
*/
use Relatable;

/**
* @var PDOInterface
*/
private $pdo;
private PDOInterface $pdo;

public function __construct(PDOInterface $pdo)
{
Expand All @@ -35,17 +31,11 @@ public function getPdo(): PDOInterface
return $this->pdo;
}

/**
* {@inheritdoc}
*/
public function getClass(): ?string
{
return null;
}

/**
* {@inheritdoc}
*/
public function fetch(QueryBuilderInterface $queryBuilder): ResultSetInterface
{
$stmt = $queryBuilder->prepare($this->pdo);
Expand Down
16 changes: 2 additions & 14 deletions src/Fetcher/ColumnFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
*/
class ColumnFetcher implements FetcherInterface
{
/**
* @var PDOInterface
*/
private $pdo;
private PDOInterface $pdo;

/**
* @var int
*/
private $columnNumber;
private int $columnNumber;

public function __construct(PDOInterface $pdo, int $columnNumber = 0)
{
Expand All @@ -40,17 +34,11 @@ public function getColumnNumber(): int
return $this->columnNumber;
}

/**
* {@inheritdoc}
*/
public function getClass(): ?string
{
return null;
}

/**
* {@inheritdoc}
*/
public function fetch(QueryBuilderInterface $queryBuilder): ResultSetInterface
{
$stmt = $queryBuilder->prepare($this->pdo);
Expand Down
4 changes: 2 additions & 2 deletions src/Fetcher/FetcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ interface FetcherInterface
public function getPdo(): PDOInterface;

/**
* @psalm-return ?class-string<T>
* @return ?class-string
*/
public function getClass(): ?string;

/**
* @psalm-return ResultSetInterface<T>
* @return ResultSetInterface<T>
*/
public function fetch(QueryBuilderInterface $queryBuilder): ResultSetInterface;
}

0 comments on commit 5ffbaac

Please sign in to comment.