Phpstan-dba - database handling related class reflection extension for PHPStan & framework-specific rules

Overview

database handling class reflection extension for PHPStan

This extension provides following features:

  • PDO->query knows the array shape of the returned results and therefore can return a generic PDOStatement
  • mysqli->query knows the array shape of the returned results and therefore can return a generic mysqli_result
  • SyntaxErrorInQueryMethodRule can inspect sql queries and detect syntax errors - SyntaxErrorInQueryFunctionRule can do the same for functions

see the unit-testsuite to get a feeling about the current featureset.

Its really early days... and this libs has a few rough edges.

Usage

To get the extension running you need to configure the phpstan-dba.

  1. Include the dba.neon from within your PHPStan configuration.

  2. Additionally your bootstrap file needs to be configured within your phpstan configuration, so it will be automatically included by PHPStan:

 // bootstrap.php

use staabm\PHPStanDba\QueryReflection\MysqliQueryReflector;
use staabm\PHPStanDba\QueryReflection\QueryReflection;
use staabm\PHPStanDba\QueryReflection\RecordingQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReplayQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReflectionCache;

require_once __DIR__ . '/vendor/autoload.php';

$cacheFile = __DIR__.'/.phpstan-dba.cache';

QueryReflection::setupReflector(
    new RecordingQueryReflector(
        ReflectionCache::create(
            $cacheFile
        ),
        // XXX put your database credentials here
        new MysqliQueryReflector(new mysqli('mysql57.ab', 'testuser', 'test', 'phpstan-dba'))
    )
);

As you can see, phpstan-dba requires a mysqli connection to introspect the database.

Record and Replay

In case you cannot be sure to have a database running at PHPStan analysis time, you can use the RecordingQueryReflector to record the reflection information. With this cache file you can utilize ReplayQueryReflector to replay the reflection information, without the need for a active database connection.

 // bootstrap.php

use staabm\PHPStanDba\QueryReflection\MysqliQueryReflector;
use staabm\PHPStanDba\QueryReflection\QueryReflection;
use staabm\PHPStanDba\QueryReflection\RecordingQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReplayQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReflectionCache;

require_once __DIR__ . '/vendor/autoload.php';

$cacheFile = __DIR__.'/.phpstan-dba.cache';

QueryReflection::setupReflector(
    new ReplayQueryReflector(
        ReflectionCache::load(
            $cacheFile
        )
    )
);

This might be usefull if your CI pipeline cannot connect to your development database server for whatever reason.

The GitHubActions setup of phpstan-dba is using this technique to replay the reflection information.

use SyntaxErrorInQueryMethodRule for your custom classes

Reuse the SyntaxErrorInQueryMethodRule within your PHPStan configuration to detect syntax errors in queries, by registering a service:

services:
	-
		class: staabm\PHPStanDba\Rules\SyntaxErrorInQueryMethodRule
		tags: [phpstan.rules.rule]
		arguments:
			classMethods:
				- 'myClass::query#0'
				- 'anotherClass::takesAQuery#2'

the callable format is class::method#parameterIndex, while the parameter-index defines the position of the query-string argument.

use SyntaxErrorInQueryFunctionRule for your custom functions

Reuse the SyntaxErrorInQueryFunctionRule within your PHPStan configuration to detect syntax errors in queries, by registering a service:

services:
	-
		class: staabm\PHPStanDba\Rules\SyntaxErrorInQueryFunctionRule
		tags: [phpstan.rules.rule]
		arguments:
			functionNames:
				- 'Deployer\runMysqlQuery#0'

the callable format is funtionName#parameterIndex, while the parameter-index defines the position of the query-string argument.

Installation

composer require --dev staabm/phpstan-dba

Todos / Caveats

Comments
  • Question about Doctrine/DBAL

    Question about Doctrine/DBAL

    Hey there :wave:

    I found your project on twitter the other day and after looking into it, it looks very interesting. :+1: good work so far

    we are using the Doctrine/DBAL connection in our projects and not directly the PHP classes and functions. Is this somehow also supported? Or are your interfered types again replaced by the annotations and types of DBAL itself?

    keep up the good work :muscle:

    opened by mitelg 17
  • Return type for integers should be numeric-string

    Return type for integers should be numeric-string

    This code here:

            $result = $this->getEntityManager()->getConnection()->fetchOne('SELECT verified FROM vendor WHERE name = :vendor', ['vendor' => $vendor]);
    
            return $result === '1';
    

    Triggered:

    Strict comparison using === between int<-128, 127> and '1' will always evaluate to false.
    

    At least with doctrine connection like this it appears to really return '1'. I am not sure if there are cases where PDO will return the proper integers, or perhaps with Doctrine when using query builder it may have smarter return values. Would need to all be verified.

    enhancement 
    opened by Seldaek 12
  • Use phpmyadmin/sql-parser

    Use phpmyadmin/sql-parser

    This is a proof of concept.

    One of the 'problems' is if the query does not parse, parser will throw it, instead of sending the supposedly invalid query to the server.

    opened by xPaw 11
  • Introduce PDO based QueryReflector

    Introduce PDO based QueryReflector

    Hello, I've tried to setup a PDO based Query reflector to make the extension work with PostgreSQL databases.

    I can run the extension in my project now, however I've only worked in some basic support for doctrine 2.*, so I'm thinking if I should try to work the Mapper support now or possibly open up another PR with more improvements and drop the separation from Mysql mapper.

    WDYT? is this the way to go?

    I'm also wondering about the simulated param value support, I'd love to see some uuid support since I've been experimenting with it a bit.

    Following up from https://github.com/staabm/phpstan-dba/issues/200

    opened by p4veI 11
  • Fix QueryPlanAnalyser with dynamic offset and limit params

    Fix QueryPlanAnalyser with dynamic offset and limit params

    The QueryPlanAnalyser does not strip trailing limits and offsets. If limits and offsets are set via parameters it would escape the limits and offsets as strings. This resulted in incorrect SQL being analysed.

    opened by keulinho 10
  • Allow simulation of DateTime objects

    Allow simulation of DateTime objects

    Partially addresses #278 - but the way I see it, in QuerySimulation::simulateParamValueType you don't have access to the param types argument, only to the parameter themselves?

    I mean PDO::exec($query, $params, $paramTypes) <- this param types arg

    Without access to that we can serialize the datetime to a Y-m-d H:i:s format, but it won't be always correct, as if you pass Doctrine\DBAL\Types\Types::DATE for ex then it should use Y-m-d only. And strictly speaking we should only simulate/serialize DateTime objects if the appropriate Type is passed in $paramTypes. Otherwise it's unlikely to be a bug if you have a DateTime in there as it will fail at runtime.

    This patch does fix the issue I have though so it's a improvement as it allows me to run phpstan-dba on this project of mine, but it's hardly a comprehensive fix.

    opened by Seldaek 10
  • Strange DBAL discrepancy between local env and CI

    Strange DBAL discrepancy between local env and CI

    With this code here https://github.com/composer/packagist/blob/8a3d28e42f9790dea401e5f9afc7c2c9780b58d8/src/Entity/PackageRepository.php#L255-L270

    Running locally I get:

    Method App\Entity\PackageRepository::getStalePackagesForDumping() should return array<int, string> but returns array<int<0, max>, int<0, 4294967295>>.

    Which makes sense given #222

    But on CI e.g. https://github.com/composer/packagist/runs/5037284175?check_suite_focus=true I get this:

    Method App\Entity\PackageRepository::getStalePackagesForDumping() should return array<int, string> but returns array<int, mixed>.

    Any clue what could cause this? All dependency versions are the same as it installs from lock file.

    bug 
    opened by Seldaek 10
  • Query error with parameterised queries

    Query error with parameterised queries

    Following up on Issue 69, as this is a different issue (I don't want to mix up the two things).

    The SQL error, when checking $pdo->prepare():

    ------ ------------------------------------------------------------------ 
     Line   index.php                                                         
    ------ ------------------------------------------------------------------ 
     5      Query error: You have an error in your SQL syntax; check the      
            manual that corresponds to your MySQL/MariaDB server version for  
            the right syntax to use near ':id AND 2=2 LIMIT 0' at line 1      
                                                                              
            Simulated query: SELECT * FROM user WHERE id = :id AND 2=2 LIMIT  
            0 (1064).                                                         
     8      Query error: You have an error in your SQL syntax; check the      
            manual that corresponds to your MySQL/MariaDB server version for  
            the right syntax to use near '? AND 2=2 LIMIT 0' at line 1        
                                                                              
            Simulated query: SELECT * FROM user WHERE id = ? AND 2=2 LIMIT 0  
            (1064).                                                           
    ------ ------------------------------------------------------------------
    

    This output used the new debug mode in RuntimeConfiguration (thanks for adding).

    It's happening on both named and question mark parameter queries.

    The MysqliQueryReflector::simulateQuery() method is used, and it looks like the query is being sent to the database without parameters being provided (or replaced).

    It's interesting that later, when $stmt->execute() is being tested, the values are being replaced in QueryReflection::replaceParameters().

    I wonder if this check can be done during $stmt->execute(), when you have some parameters to use... or it might be possible to generate some values, even if it's the number 0, or a value that's appropriate for the field type (considering it's not actually returning any records with a LIMIT 0).

    opened by craigfrancis 9
  • Prepared statement: Question mark parameters

    Prepared statement: Question mark parameters

    Currently phpstan-dba supports named parameters (thank you), but it does not support question mark parameters:

    $statement = $pdo->prepare('SELECT * FROM user WHERE id = :id');
    $statement->execute(['id' => 1]);
    
    $statement = $pdo->prepare('SELECT * FROM user WHERE id = ?');
    $statement->execute([1]);
    

    First one is fine, second one "Value 0 is given to execute(), but the query does not containt this placeholder."

    I can see you have a $parameters array in PdoStatementExecuteErrorMethodRule::checkParameterValues(), is it worth using something like the following to determine if it's using keyed arrays:

    (count(array_filter(array_keys($array), 'is_string')) > 0)
    

    https://stackoverflow.com/a/4254008/6632


    Also, typo with "containt" (says he with a keyboard who happens to have a nearly broken "t" key, so can you send them my way).

    opened by craigfrancis 9
  • Support for checking update/insert/delete statemenet

    Support for checking update/insert/delete statemenet

    Hello

    in my dibi fork, I was able to successfully test update/delete/insert statements (inside a transaction). @staabm commented it out as not supported yet (https://github.com/staabm/phpstan-dba/pull/468).

    Could it be supported since it worked fine in my fork? We'd have to make sure we disallow any statement that does work inside the transaction (eg put whitelist only to select, insert, update, delete to disallow truncate, alter etc)

    Thanks

    opened by jakubvojacek 8
  • Detect syntax errors in `Dibi\Connection::*`

    Detect syntax errors in `Dibi\Connection::*`

    Hello @staabm

    as discussed in https://github.com/staabm/phpstan-dba/issues/462, I am attempting to add support for dibi database driver.

    So far I have come up with those changes. Surprisingly, it kinda works. Already got some reports such as:

     ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
      Line   Customer.php                                                                                                                                                                                                       
     ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
      193    Parameter #1 $key of function array_key_exists expects int|string, int<0, 4294967295>|null given.                                                                                                                  
      246    Parameter #2 $data of method SomeApp\SchemaProcessor\SchemaProcessor::processOutput() expects array<string, mixed>, array<int|string, array<int|SomeApp\ApiModule\Entity\ProfileEntity>|int|string|null> given.  
     ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
    

    It correctly guesses the parameters and their types.

    But,

    1. the part where I replace the question mark with "1" seems messy. I guess you got some APIs already prepared to replace placeholders? But I couldn't really find it.
    2. It does not report syntax errors correctly because of the hack where I replace placeholders in inferType instead of the APIs handling it I think. It should be somehow replaced in resolveQueryStrings automatically right?
    3. phpcs/phpstan fails, hope that is okay for now.
    opened by jakubvojacek 8
  • Update doctrine/dbal requirement from ^3.2 to ^3.3

    Update doctrine/dbal requirement from ^3.2 to ^3.3

    Updates the requirements on doctrine/dbal to permit the latest version.

    Release notes

    Sourced from doctrine/dbal's releases.

    3.3.8

    Release 3.3.8

    3.3.8

    • Total issues resolved: 1
    • Total pull requests resolved: 12
    • Total contributors: 6

    Bug,Type Conversion

    Test Suite

    Dependencies

    Documentation,Schema Comparison

    Code Style

    Documentation

    Bug,Schema Comparison,Schema Management

    Static Analysis,Test Suite

    ... (truncated)

    Commits
    • f873a82 Merge pull request #5566 from wouterj/serialization-deprecation
    • c66b982 Do not treat deprecation level as errors
    • de42378 Merge pull request #5535 from derrabus/improvement/assert-count
    • 1100987 Use assertCount() when possible
    • f31bf8a Merge pull request #5533 from morozov/phpstan-1.8
    • e2dd913 Update PHPStan to 1.8.2
    • 8532d49 Merge pull request #5522 from morozov/lock-closed-issues
    • 6adcfe5 Lock closed issues
    • 39a05f6 Merge pull request #5503 from derrabus/bugfix/deprecation-link
    • 5c85fd4 Fix link in deprecation message
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Update phpstan/phpstan requirement from ^1.5.6 to ^1.9.7

    Update phpstan/phpstan requirement from ^1.5.6 to ^1.9.7

    Updates the requirements on phpstan/phpstan to permit the latest version.

    Release notes

    Sourced from phpstan/phpstan's releases.

    1.9.7

    Bleeding edge 🔪

    If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon:

    includes:
    	- vendor/phpstan/phpstan/conf/bleedingEdge.neon
    

    Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more

    Improvements 🔧

    Bugfixes 🐛

    Function signature fixes 🤖

    Internals 🔍

    Commits
    • 0501435 PHPStan 1.9.7
    • 707c831 Updated PHPStan to commit d279f388f5a1cb7a6f821dbecc4052a9ebbb8417
    • 23daeff Updated PHPStan to commit 091fcafb07ac0b3eb261285c049d9c0f214a535c
    • 1a28725 Updated Composer baseline
    • af72eaa Updated PHPUnit baseline
    • c0d39c1 Updated PHPStan to commit 28c2c79b16cac6ba6b01f1b4d211541dd49d8a77
    • 45dbb01 Updated PHPStan to commit 752baaf49f65586b79ab24d5beb4b385c65a281c
    • 7f88292 Updated PHPStan to commit 02753c6883677edd87d40f397f057daddd103a05
    • b4c0d3f Updated PHPStan to commit 6debffdb5892f7fb311a60634ec9cda79b6e3154
    • 92ac649 Reproduce progress bar crash if all passed paths to analyse are excluded
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Update composer/semver requirement from ^3.2 to ^3.3

    Update composer/semver requirement from ^3.2 to ^3.3

    Updates the requirements on composer/semver to permit the latest version.

    Release notes

    Sourced from composer/semver's releases.

    3.3.2

    • Fixed handling of non-string values (#134)
    Changelog

    Sourced from composer/semver's changelog.

    [3.3.2] 2022-04-01

    • Fixed handling of non-string values (#134)

    [3.3.1] 2022-03-16

    • Fixed possible cache key clash in the CompilingMatcher memoization (#132)

    [3.3.0] 2022-03-15

    • Improved performance of CompilingMatcher by memoizing more (#131)
    • Added CompilingMatcher::clear to clear all memoization caches

    [3.2.9] 2022-02-04

    • Revert #129 (Fixed MultiConstraint with MatchAllConstraint) which caused regressions

    [3.2.8] 2022-02-04

    [3.2.7] 2022-01-04

    • Fixed: typo in type definition of Intervals class causing issues with Psalm scanning vendors

    [3.2.6] 2021-10-25

    • Fixed: type improvements to parseStability

    [3.2.5] 2021-05-24

    • Fixed: issue comparing disjunctive MultiConstraints to conjunctive ones (#127)
    • Fixed: added complete type information using phpstan annotations

    [3.2.4] 2020-11-13

    • Fixed: code clean-up

    [3.2.3] 2020-11-12

    • Fixed: constraints in the form of X || Y, >=Y.1 and other such complex constructs were in some cases being optimized into a more restrictive constraint

    [3.2.2] 2020-10-14

    • Fixed: internal code cleanups

    [3.2.1] 2020-09-27

    • Fixed: accidental validation of broken constraints combining ^/~ and wildcards, and -dev suffix allowing weird cases

    ... (truncated)

    Commits
    • 3953f23 Update CHANGELOG.md
    • 9b2d75f Fix handling of non-string values, fixes #134
    • 7b62ddc Merge pull request #133 from SubhanSh/develop
    • 944b3e3 docs: added fullname of an abbreviation
    • 5d8e574 Update changelog
    • f7ebdcb Merge pull request #132 from Toflar/fix-cache-key
    • eca295a Fix result cache key in CompilingMatcher
    • f79c90a Update changelog
    • e2000a2 Add method to clear memoization caches, refs #131
    • af3620d Merge pull request #131 from Toflar/improve-compilingmatcher-performance
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Update phpstan/phpstan-strict-rules requirement from ^1.1 to ^1.4

    Update phpstan/phpstan-strict-rules requirement from ^1.1 to ^1.4

    Updates the requirements on phpstan/phpstan-strict-rules to permit the latest version.

    Release notes

    Sourced from phpstan/phpstan-strict-rules's releases.

    1.4.4

    • 23e5f37 - Configuration option strictRules.disallowedLooseComparsion
    Commits
    • 23e5f37 Configuration option strictRules.disallowedLooseComparsion
    • 431b3d6 Fix wrong error when function is rebound.
    • 1f3b649 Add regression test for non-looping loops
    • 4e57160 Revert "Add regression test for non-looping loops"
    • 749afc7 Configuration parameters to enable/disable rules - fix for VariablePropertyFe...
    • 6f0133d Add regression test for non-looping loops
    • a73b397 Update workflow
    • 8019e79 Update README.md
    • f120c3b Configuration parameters to enable/disable rules
    • 6ec8ce7 Update build.yml
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Update vlucas/phpdotenv requirement from ^5.4 to ^5.5

    Update vlucas/phpdotenv requirement from ^5.4 to ^5.5

    Updates the requirements on vlucas/phpdotenv to permit the latest version.

    Release notes

    Sourced from vlucas/phpdotenv's releases.

    V5.5.0 (16/10/2022)

    We announce the immediate availability V5.5.0.

    New Features

    • Add support for unicode variable names (1a7ea2afc49c3ee6d87061f5a233e3a035d0eae7)

    Changes

    • Add official support for PHP 8.2 (b674e23043fb054147eea190465467a71dd2ed85)
    • Made repository checks a little stricter (4c165455a670005a05edbdf97a5590aa3e4936ec)

    Bug Fixes

    • Fix issue where line ending in =" is incorrectly marked as a multi-line start (f9266951999a6a4059a6edea926a1d19f40cfc3b)
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Update phpstan/phpstan-phpunit requirement from ^1.0 to ^1.3

    Update phpstan/phpstan-phpunit requirement from ^1.0 to ^1.3

    Updates the requirements on phpstan/phpstan-phpunit to permit the latest version.

    Release notes

    Sourced from phpstan/phpstan-phpunit's releases.

    1.3.3

    • 54a24bd - Add support for data provider attributes
    • 7f7b59b - Update release-toot.yml
    • 64f4c56 - Create release-toot.yml
    Commits
    • 54a24bd Add support for data provider attributes
    • 7f7b59b Update release-toot.yml
    • 64f4c56 Create release-toot.yml
    • cd9c693 DataProviderDeclarationRule - report non-static dataProvider only with PHPUni...
    • b9827cf Discover data providers from other classes
    • 008f5da Update .gitattributes
    • bc0a290 Do not use "strtolower" when there is a dedicated method
    • f9bfc19 Report data providers deprecated usage
    • 4c06b7e Add rule to check @dataProvider
    • 8313d41 Update dessant/lock-threads action to v4
    • Additional commits viewable in compare view

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Releases(0.2.56)
  • 0.2.56(Jan 8, 2023)

    Improvements

    Write-queries are analyzed by default and no longer executed and rollback'ed. the new logic also works for tables and databases which do not support transactions.

    What's Changed

    • transform write query into read query by @staabm in https://github.com/staabm/phpstan-dba/pull/497

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.55...0.2.56

    Source code(tar.gz)
    Source code(zip)
  • 0.2.55(Jan 6, 2023)

    Improvements

    • Support for delete, insert, update, replace by @jakubvojacek, @staabm in https://github.com/staabm/phpstan-dba/pull/483

    Enable it via RuntimeConfiguration:

    $config = new RuntimeConfiguration();
    $config->analyzeWriteQueries(true);
    

    requires transaction support in db schema and db driver

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.54...0.2.55

    Source code(tar.gz)
    Source code(zip)
  • 0.2.54(Dec 14, 2022)

    Features

    • Detect syntax errors in Dibi\Connection::* by @jakubvojacek in https://github.com/staabm/phpstan-dba/pull/463
    • Dibi type inference by @staabm in https://github.com/staabm/phpstan-dba/pull/468

    Improvements

    • fix PHPStan 1.9.3 compat by @staabm in https://github.com/staabm/phpstan-dba/pull/486
    • Throw exception in case we are not able to start a transaction by @staabm in https://github.com/staabm/phpstan-dba/pull/487
    • implement DbaApi by @jakubvojacek in https://github.com/staabm/phpstan-dba/pull/480

    What's Changed

    • simplify test-suite config by @staabm in https://github.com/staabm/phpstan-dba/pull/464
    • simplify return type extensions by @staabm in https://github.com/staabm/phpstan-dba/pull/467
    • fix github action phpunit annotations by @staabm in https://github.com/staabm/phpstan-dba/pull/471
    • Adds new placeholders by @jakubvojacek in https://github.com/staabm/phpstan-dba/pull/473
    • Fix aggregate functions in dibi::fetchSingle by @jakubvojacek in https://github.com/staabm/phpstan-dba/pull/478
    • test with empty result cache by @staabm in https://github.com/staabm/phpstan-dba/pull/482
    • remove duplicate mysqli_stmt stub definitions by @staabm in https://github.com/staabm/phpstan-dba/pull/485

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.53...0.2.54

    Source code(tar.gz)
    Source code(zip)
  • 0.2.53(Dec 2, 2022)

    • fix ReplayAndRecordingQueryReflector to report consistent results with RecordingReflector

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.52...0.2.53

    Source code(tar.gz)
    Source code(zip)
  • 0.2.52(Nov 21, 2022)

    • work arround PHPStorm integration issues which lead to useless cache-files. phpstan-dba should be run across the whole project

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.51...0.2.52

    Source code(tar.gz)
    Source code(zip)
  • 0.2.51(Nov 3, 2022)

    What's Changed

    • prevent Query error: Incorrect table name '' (1103). by @staabm in https://github.com/staabm/phpstan-dba/pull/456
    • fix fatal error on query reflection with AssignOp operators by @staabm in https://github.com/staabm/phpstan-dba/pull/450

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.50...0.2.51

    Source code(tar.gz)
    Source code(zip)
  • 0.2.50(Nov 1, 2022)

    What's Changed

    • fixed regression by @staabm in https://github.com/staabm/phpstan-dba/pull/453

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.49...0.2.50

    Source code(tar.gz)
    Source code(zip)
  • 0.2.49(Oct 29, 2022)

    Improvements

    • fix fatal error on mysql error 1103 / incorrect table by @staabm in https://github.com/staabm/phpstan-dba/pull/447

    What's Changed

    • phpstan 1.9 fixes by @staabm in https://github.com/staabm/phpstan-dba/pull/445
    • fix cs, ignore test-files by @staabm in https://github.com/staabm/phpstan-dba/pull/448
    • ignore unreliable type errors in SchemaHasherMysql by @staabm in https://github.com/staabm/phpstan-dba/pull/449

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.48...0.2.49

    Source code(tar.gz)
    Source code(zip)
  • 0.2.48(Oct 10, 2022)

    What's Changed

    • fix phpdoc parsing with whitespaces/contents after values by @staabm in https://github.com/staabm/phpstan-dba/pull/438

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.47...0.2.48

    Source code(tar.gz)
    Source code(zip)
  • 0.2.47(Oct 8, 2022)

    What's Changed

    • added mysqli::execute_query() support (php 8.2+ only) by @staabm in https://github.com/staabm/phpstan-dba/pull/430
    • support out-of-class MethodCalls in PhpDocUtil by @staabm in https://github.com/staabm/phpstan-dba/pull/436
    • support non-conditional @psalm-taint-escape sql by @staabm in https://github.com/staabm/phpstan-dba/pull/437

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.46...0.2.47

    Source code(tar.gz)
    Source code(zip)
  • 0.2.46(Oct 3, 2022)

    What's Changed

    • extract PhpDocUtil by @staabm in https://github.com/staabm/phpstan-dba/pull/435

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.45...0.2.46

    Source code(tar.gz)
    Source code(zip)
  • 0.2.45(Oct 2, 2022)

    What's Changed

    • Strip query comments by @marmichalski in https://github.com/staabm/phpstan-dba/pull/431
    • support encapsed strings by @staabm in https://github.com/staabm/phpstan-dba/pull/433
    • support @phpstandba-inference-placeholder on calls via variable by @staabm in https://github.com/staabm/phpstan-dba/pull/434

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.44...0.2.45

    Source code(tar.gz)
    Source code(zip)
  • 0.2.44(Oct 1, 2022)

    What's Changed

    • better error message on setup problems by @staabm in https://github.com/staabm/phpstan-dba/pull/427
    • support mysqli_execute_query (php 8.2+ only) by @staabm in https://github.com/staabm/phpstan-dba/pull/425
    • support @phpstandba-inference-placeholder on static method calls by @staabm in https://github.com/staabm/phpstan-dba/pull/432

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.43...0.2.44

    Source code(tar.gz)
    Source code(zip)
  • 0.2.43(Sep 25, 2022)

    What's Changed

    • cover intersection type inference in tests by @staabm in https://github.com/staabm/phpstan-dba/pull/414
    • Update query-plan-analysis.md by @staabm in https://github.com/staabm/phpstan-dba/pull/417
    • Rm duplicated docs by @staabm in https://github.com/staabm/phpstan-dba/pull/423
    • cover php 8.2 in CI by @staabm in https://github.com/staabm/phpstan-dba/pull/426
    • [MySQL] Treat decimal as numeric-string by @marmichalski in https://github.com/staabm/phpstan-dba/pull/429

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.42...0.2.43

    Source code(tar.gz)
    Source code(zip)
  • 0.2.42(Jul 19, 2022)

    New Features

    • implement @phpstandba-inference-placeholder annotation by @staabm in https://github.com/staabm/phpstan-dba/pull/413

    What's Changed

    • Merge separate PDO and Mysqli rule tests by @p4veI in https://github.com/staabm/phpstan-dba/pull/410
    • Use new constants by @staabm in https://github.com/staabm/phpstan-dba/pull/411
    • Use new constants by @staabm in https://github.com/staabm/phpstan-dba/pull/412

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.41...0.2.42

    Source code(tar.gz)
    Source code(zip)
  • 0.2.41(Jun 29, 2022)

    • added php 7.3 support by @staabm in https://github.com/staabm/phpstan-dba/pull/369
    • added mysql 5.7 support

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.40...0.2.41

    Source code(tar.gz)
    Source code(zip)
  • 0.2.40(Jun 9, 2022)

    What's Changed

    • prevent race conditions while writing cache file by @staabm in https://github.com/staabm/phpstan-dba/pull/406

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.39...0.2.40

    Source code(tar.gz)
    Source code(zip)
  • 0.2.39(Jun 9, 2022)

    What's Changed

    • improve compatibility with phpstan@bleedingEdge by @staabm in https://github.com/staabm/phpstan-dba/pull/404
    • added build job against phpstan@dev by @staabm in https://github.com/staabm/phpstan-dba/pull/403

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.38...0.2.39

    Source code(tar.gz)
    Source code(zip)
  • 0.2.38(Jun 8, 2022)

    What's Changed

    • don't analyse maybe existing data when QueryPlanAnalyzer::TABLES_WITHOUT_DATA by @staabm in https://github.com/staabm/phpstan-dba/pull/402

    💌 Support phpstan-dba

    Consider supporting the project, so we can make this tool even better even faster for everyone.

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.37...0.2.38

    Source code(tar.gz)
    Source code(zip)
  • 0.2.37(May 31, 2022)

    What's Changed

    • handle UnresolvableQueryException in *Extensions and while Query Plan Analysis by @staabm in https://github.com/staabm/phpstan-dba/pull/399

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.36...0.2.37

    Source code(tar.gz)
    Source code(zip)
  • 0.2.36(May 31, 2022)

    Improvements

    • support debugMode() in query plan analysis by @staabm in https://github.com/staabm/phpstan-dba/pull/398

    What's Changed

    • improve rules test coverage for pdo-pgsql by @p4veI in https://github.com/staabm/phpstan-dba/pull/393
    • rules.md: document how to re-use QueryPlanAnalyzerRule by @staabm in https://github.com/staabm/phpstan-dba/pull/395
    • fix typo by @staabm in https://github.com/staabm/phpstan-dba/pull/397

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.35...0.2.36

    Source code(tar.gz)
    Source code(zip)
  • 0.2.35(May 27, 2022)

    What's Changed

    • Query Plan Analysis: Reduce default numberOfRowsNotRequiringIndex to 0 by @staabm in https://github.com/staabm/phpstan-dba/pull/388

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.34...0.2.35

    Source code(tar.gz)
    Source code(zip)
  • 0.2.34(May 27, 2022)

    What's Changed

    • Fix QueryPlanAnalyser with dynamic offset and limit params by @keulinho in https://github.com/staabm/phpstan-dba/pull/390

    New Contributors

    • @keulinho made their first contribution in https://github.com/staabm/phpstan-dba/pull/390

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.33...0.2.34

    Source code(tar.gz)
    Source code(zip)
  • 0.2.33(May 25, 2022)

    What's Changed

    • docs by @staabm in https://github.com/staabm/phpstan-dba/pull/383
    • added more general mysql optimization tips by @staabm in https://github.com/staabm/phpstan-dba/pull/384
    • cover SyntaxErrorInPreparedStatementMethodRuleReflectorTest on pgsql by @staabm in https://github.com/staabm/phpstan-dba/pull/386
    • docs by @staabm in https://github.com/staabm/phpstan-dba/pull/387

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.32...0.2.33

    Source code(tar.gz)
    Source code(zip)
  • 0.2.32(May 25, 2022)

    New Features

    • Within your phpstan-dba-bootstrap.php file, you can optionally enable query plan analysis. When enabled, phpstan-dba will error when queries are not using indices or queries are inefficient. DEMO

    What's Changed

    • mysql query plan analyzer by @staabm in https://github.com/staabm/phpstan-dba/pull/377
    • fix reflection-cache error by @staabm in https://github.com/staabm/phpstan-dba/pull/382
    • Added null to PDO default types by @staabm in https://github.com/staabm/phpstan-dba/pull/381

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.31...0.2.32

    Source code(tar.gz)
    Source code(zip)
  • 0.2.31(May 24, 2022)

    What's Changed

    • pgsql fixes for syntax error detection in some cases by @staabm in https://github.com/staabm/phpstan-dba/pull/379
    • Infer default-result type when sql queries cannot be inferred by @staabm in https://github.com/staabm/phpstan-dba/pull/373

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.30...0.2.31

    Source code(tar.gz)
    Source code(zip)
  • 0.2.30(May 23, 2022)

    Notable Changes

    • Fixed a few glitches when working with the recording feature and using the record-information across operating systems
    • PdoQueryReflector was marked as deprecated and PdoMysqlQueryReflector should be used as a 1:1 replacement instead
      • we won't drop PdoQueryReflector in the near future though

    What's Changed

    • introduce PdoMysqlQueryReflector and deprecate PdoQueryReflector by @staabm in https://github.com/staabm/phpstan-dba/pull/370
    • cleanup internal types by @staabm in https://github.com/staabm/phpstan-dba/pull/362
    • make sure recording information works consistent across OS (line delims) by @staabm in https://github.com/staabm/phpstan-dba/pull/374
    • normalize EOL also in prepared queries by @staabm in https://github.com/staabm/phpstan-dba/pull/375
    • trim queries for cross-OS compat by @staabm in https://github.com/staabm/phpstan-dba/pull/376

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.29...0.2.30

    Source code(tar.gz)
    Source code(zip)
  • 0.2.29(May 21, 2022)

    Notable Changes

    • Added php 7.4 support by @staabm in https://github.com/staabm/phpstan-dba/pull/367

    What's Changed

    • Substitute params using regex by @marmichalski in https://github.com/staabm/phpstan-dba/pull/364
    • Create faq.md by @staabm in https://github.com/staabm/phpstan-dba/pull/366
    • drop symplify/phpstan-extensions dependency by @staabm in https://github.com/staabm/phpstan-dba/pull/368

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.28...0.2.29

    Source code(tar.gz)
    Source code(zip)
  • 0.2.28(May 20, 2022)

    Notable Changes

    • Added support for JSON datatype by @marmichalski in https://github.com/staabm/phpstan-dba/pull/360

    What's Changed

    • docs update by @staabm in https://github.com/staabm/phpstan-dba/pull/354
    • docs by @staabm in https://github.com/staabm/phpstan-dba/pull/355
    • Docs: fixed dead link by @staabm in https://github.com/staabm/phpstan-dba/pull/358
    • docs: remove link to testsuite by @staabm in https://github.com/staabm/phpstan-dba/pull/359

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.27...0.2.28

    Source code(tar.gz)
    Source code(zip)
  • 0.2.27(May 19, 2022)

    What's Changed

    • Move ext-mysqli to require-dev by @marmichalski in https://github.com/staabm/phpstan-dba/pull/352
    • overhaul docs by @staabm in https://github.com/staabm/phpstan-dba/pull/351

    New Contributors

    • @marmichalski made their first contribution in https://github.com/staabm/phpstan-dba/pull/352

    Full Changelog: https://github.com/staabm/phpstan-dba/compare/0.2.26...0.2.27

    Source code(tar.gz)
    Source code(zip)
Owner
Markus Staab
Markus Staab
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

null 3 Feb 14, 2022
Support for many missing PostgreSQL specific features

Laravel supports many different databases and therefore has to limit itself to the lowest common denominator of all databases. PostgreSQL, however, of

Tobias Petry 359 Jan 3, 2023
A Laravel package to output a specific sql to your favourite debugging tool. The supported log output is Laravel Telescope, Laravel Log, Ray, Clockwork, Laravel Debugbar and your browser.

Laravel showsql A Laravel package to output a specific sql to your favourite debugging tool, your browser or your log file. Use case You often want to

Dieter Coopman 196 Dec 28, 2022
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.

Please give it a Star if you like the project ?? ❤️ SleekDB - A NoSQL Database made using PHP Full documentation: https://sleekdb.github.io/ SleekDB i

Kazi Mehedi Hasan 745 Jan 7, 2023
SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate.

SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate. NoSQL API

SleekwareDB 12 Dec 11, 2022
The lightweight PHP database framework to accelerate development

The lightweight PHP database framework to accelerate development Features Lightweight - Less than 100 KB, portable with only one file Easy - Extremely

Angel Lai 4.6k Dec 28, 2022
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

The Laravel Components 2.5k Dec 27, 2022
Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.

ClosureTable This is a database manipulation package for the Laravel 5.4+ framework. You may want to use it when you need to store and operate hierarc

Yan Ivanov 441 Dec 11, 2022
A complete, simple and powerful database framework written in PHP

BaseSQL BaseSQL is a complete database framework written in PHP. It was built to accelerate projects development by handle database connections and qu

Willian Pinheiro 2 Sep 21, 2021
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7

Maghead 4.0.x IS CURRENTLY UNDER HEAVY DEVELOPMENT, API IS NOT STABLE Maghead is an open-source Object-Relational Mapping (ORM) designed for PHP7. Mag

Maghead 477 Dec 24, 2022
This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud

Database Backup Manager This package provides a framework-agnostic database backup manager for dumping to and restoring databases from S3, Dropbox, FT

Backup Manager 1.6k Dec 23, 2022
The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

Mark Armendariz 0 Jan 7, 2022
MySQL Spatial Data Extension integration with Laravel.

Laravel MySQL Spatial extension Laravel package to easily work with MySQL Spatial Data Types and MySQL Spatial Functions. Please check the documentati

Joseph Estefane 741 Jan 9, 2023
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL extension

Swoole Coroutine PostgreSQL Doctrine DBAL Driver A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL. Getting started Install

Leo Cavalcante 19 Nov 25, 2022
Doctrine extension to persist spatial data objects.

doctrine-Spatial Doctrine-spatial is a doctrine extension. It implements spatial types and functions. As exemple, this extension can help you to know

LongitudeOne 36 Jan 7, 2023
Php mongodb admin, use new mongodb extension.

EasyMongo EasyMongo is a Mongodb web management application. This project is based on iwind/RockMongo, uses the latest mongodb-extension + mongo-php-l

Meng Wang 8 Oct 31, 2022
ORM layer that creates models, config and database on the fly

RedBeanPHP 5 RedBeanPHP is an easy to use ORM tool for PHP. Automatically creates tables and columns as you go No configuration, just fire and forget

Gabor de Mooij 2.2k Jan 9, 2023
Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer

Spot DataMapper ORM v2.0 Spot v2.x is built on the Doctrine DBAL, and targets PHP 5.4+. The aim of Spot is to be a lightweight DataMapper alternative

Spot ORM 602 Dec 27, 2022
SQL database access through PDO.

Aura.Sql Provides an extension to the native PDO along with a profiler and connection locator. Because ExtendedPdo is an extension of the native PDO,

Aura for PHP 533 Dec 30, 2022