Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/infection.json.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/tools export-ignore
18 changes: 8 additions & 10 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ on:
jobs:
run:
name: Run
runs-on: ubuntu-20.04
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
env:
key: cache-v1
matrix:
operating-system: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.5'
extensions: mbstring, intl, opcache, xdebug, xml
tools: composer, cs2pr
- name: Get Composer cache directory
id: composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
id: composer-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache-dir.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
Expand All @@ -44,7 +44,5 @@ jobs:
run: rm -f composer.lock
- name: Setup Composer
run: composer install
- name: Setup PHPStan
run: tools/.phpstan/setup
- name: Run PHPStan analysis
run: tools/phpstan analyse -c phpstan-use-baseline.neon
run: ./vendor/bin/phpstan analyse -c phpstan-use-baseline.neon
10 changes: 4 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04]
php-versions: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
env:
key: cache-v1
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3', '8.4', 8.5]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
Expand All @@ -34,7 +32,7 @@ jobs:
- name: Get Composer cache directory
id: composer-cache-dir
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Restore composer cache
id: composer-cache
uses: actions/cache@v3
Expand Down
31 changes: 0 additions & 31 deletions .phpstan-baseline.neon

This file was deleted.

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"sql"
],
"require": {
"php": ">=5.4"
"php": ">=8.1",
"ext-pdo": "*"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1 || ^1.1",
"phpunit/phpunit": "^8.5 || ^7.5 || ^4.8",
"yoast/phpunit-polyfills": "^1.0"
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^9.6 || ^12.0"
},
"autoload": {
"psr-4": {
Expand Down
36 changes: 36 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Welcome to Mago!
# For full documentation, see https://mago.carthage.software/tools/overview
php-version = "8.1.0"

[source]
workspace = "."
paths = ["src/", "tests/"]
includes = ["vendor"]
excludes = []

[formatter]
print-width = 120
tab-width = 4
use-tabs = false

[linter]
integrations = ["phpunit"]

[linter.rules]
ambiguous-function-call = { enabled = false }
literal-named-argument = { enabled = false }
halstead = { effort-threshold = 7000 }

[analyzer]
find-unused-definitions = true
find-unused-expressions = false
analyze-dead-code = false
memoize-properties = true
allow-possibly-undefined-array-keys = true
check-throws = false
check-missing-override = false
find-unused-parameters = false
strict-list-index-checks = false
no-boolean-literal-comparison = false
check-missing-type-hints = false
register-super-globals = true
78 changes: 72 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,31 +1,97 @@
parameters:
ignoreErrors:
-
message: "#^Generic type Teto\\\\SQL\\\\PDOAggregate\\<PDO\\|Teto\\\\SQL\\\\PDOInterface\\<PDOStatement\\|Teto\\\\SQL\\\\PDOStatementInterface\\>\\> in PHPDoc tag @param for parameter \\$pdo does not specify all template types of interface Teto\\\\SQL\\\\PDOAggregate\\: S, T$#"
rawMessage: 'Generic type Teto\SQL\PDOAggregate<PDO|Teto\SQL\PDOInterface<PDOStatement|Teto\SQL\PDOStatementInterface>> in PHPDoc tag @param for parameter $pdo does not specify all template types of interface Teto\SQL\PDOAggregate: S, T'
identifier: generics.lessTypes
count: 2
path: src/AbstractStaticQuery.php

-
message: "#^Type PDO\\|Teto\\\\SQL\\\\PDOInterface\\<PDOStatement\\|Teto\\\\SQL\\\\PDOStatementInterface\\> in generic type Teto\\\\SQL\\\\PDOAggregate\\<PDO\\|Teto\\\\SQL\\\\PDOInterface\\<PDOStatement\\|Teto\\\\SQL\\\\PDOStatementInterface\\>\\> in PHPDoc tag @param for parameter \\$pdo is not subtype of template type S of PDOStatement\\|Teto\\\\SQL\\\\PDOStatementInterface of interface Teto\\\\SQL\\\\PDOAggregate\\.$#"
rawMessage: Type PDO|Teto\SQL\PDOInterface<PDOStatement|Teto\SQL\PDOStatementInterface> in generic type Teto\SQL\PDOAggregate<PDO|Teto\SQL\PDOInterface<PDOStatement|Teto\SQL\PDOStatementInterface>> in PHPDoc tag @param for parameter $pdo is not subtype of template type S of PDOStatement|Teto\SQL\PDOStatementInterface of interface Teto\SQL\PDOAggregate.
identifier: generics.notSubtype
count: 2
path: src/AbstractStaticQuery.php

-
message: "#^Method Teto\\\\SQL\\\\Processor\\\\CallbackProcessor\\:\\:processQuery\\(\\) should return string but returns mixed\\.$#"
rawMessage: 'Interface Teto\SQL\PDOInterface has type alias teto_pdo with generic interface Teto\SQL\PDOInterface but does not specify its types: T'
identifier: missingType.generics
count: 1
path: src/PDOInterface.php

-
rawMessage: 'Method Teto\SQL\Processor\CallbackProcessor::processQuery() should return string but returns mixed.'
identifier: return.type
count: 1
path: src/Processor/CallbackProcessor.php

-
message: "#^Property Teto\\\\SQL\\\\Processor\\\\CallbackProcessor\\:\\:\\$callback with generic interface Teto\\\\SQL\\\\PDOInterface does not specify its types\\: T$#"
rawMessage: 'Property Teto\SQL\Processor\CallbackProcessor::$callback with generic interface Teto\SQL\PDOInterface does not specify its types: T'
identifier: missingType.generics
count: 1
path: src/Processor/CallbackProcessor.php

-
message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\<int\\|string, string\\>\\)\\: string, Closure\\(array\\)\\: int\\|string given\\.$#"
rawMessage: 'Parameter #2 $callback of function preg_replace_callback expects callable(array<string>): string, Closure(array): (int|string) given.'
identifier: argument.type
count: 1
path: src/Processor/PregCallbackReplacer.php

-
message: "#^Parameter \\#2 \\$matches of method Teto\\\\SQL\\\\ReplacerInterface\\:\\:replaceQuery\\(\\) expects array\\<non\\-empty\\-string, string\\>, array\\<int\\|string, string\\> given\\.$#"
rawMessage: 'Parameter #2 $matches of method Teto\SQL\ReplacerInterface::replaceQuery() expects array<non-empty-string, string>, array<string> given.'
identifier: argument.type
count: 1
path: src/Processor/PregCallbackReplacer.php

-
rawMessage: Cannot use array destructuring on mixed.
identifier: offsetAccess.nonArray
count: 1
path: src/QueryBuilder.php

-
rawMessage: 'Parameter #3 $type of method PDOStatement::bindParam() expects int, mixed given.'
identifier: argument.type
count: 1
path: src/QueryBuilder.php

-
rawMessage: 'Call to function assert() with true will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 1
path: src/Replacer/Placeholder.php

-
rawMessage: 'Call to function is_string() with string will always evaluate to true.'
identifier: function.alreadyNarrowedType
count: 1
path: src/Replacer/Placeholder.php

-
rawMessage: Cannot cast mixed to string.
identifier: cast.string
count: 1
path: src/Replacer/Placeholder.php

-
rawMessage: 'Parameter &$bind_values by-ref type of method Teto\SQL\Replacer\Placeholder::replaceQuery() expects array<non-empty-string, mixed>, array<mixed> given.'
identifier: parameterByRef.type
count: 1
path: src/Replacer/Placeholder.php

-
rawMessage: 'Strict comparison using !== between non-falsy-string and ''0'' will always evaluate to true.'
identifier: notIdentical.alwaysTrue
count: 1
path: src/Replacer/Placeholder.php

-
rawMessage: 'Parameter #1 $value of method Teto\SQL\Type\PgIdentifier::quote() expects string, mixed given.'
identifier: argument.type
count: 1
path: src/Type/PgIdentifier.php

-
rawMessage: Unreachable statement - code above always terminates.
identifier: deadCode.unreachable
count: 1
path: src/Type/PgIdentifier.php
2 changes: 1 addition & 1 deletion phpstan-use-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
includes:
- phpstan.dist.neon
- .phpstan-baseline.neon
- phpstan-baseline.neon
2 changes: 2 additions & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ parameters:
- tests/
bootstrapFiles:
- vendor/autoload.php
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
15 changes: 3 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
Expand All @@ -9,20 +9,11 @@
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuites>
<testsuite name="TetoSQL Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
Loading