Git Product home page Git Product logo

Comments (6)

p4veI avatar p4veI commented on June 12, 2024 1

@staabm hey, I’m looking forward to looking into this, I didn’t have much time this past week. But I should be able to look into this in the upcoming week..

I already had some base for pgsql actions for github prepared, so I’ll start with that for sure.

from phpstan-dba.

staabm avatar staabm commented on June 12, 2024

correct, atm only mysql is supported. its the only database type I work with. contributions welcome.

in case e.g. a PDOQueryReflector would be implemented phpstan-dba could work across more databases.
alternatively some pgsql specific reflector would also be an option.

from phpstan-dba.

p4veI avatar p4veI commented on June 12, 2024

@staabm Hey, I can try to implement this feature into phpstan-dba if you're not against, I'm using pgsql in most of our projects so I'm kind of missing this feature.

from phpstan-dba.

staabm avatar staabm commented on June 12, 2024

I would love having pgsql support. we also need to add it to the CI pipeline then

from phpstan-dba.

staabm avatar staabm commented on June 12, 2024

@stof @p4veI do you have plans to work on this?

as we recently landed a PDO based reflector in #261 it should now be possible to work out pgsql support.
possible good first steps would be

  • add a github action running pgsql, importing existing db schema and running the testsuite
  • figure out whether pgsql support can be easily built into the PDO based reflector, or whether we better would have 2 separate pdo reflectors (one for mysql, one for pgsql)
  • tackle possible test-failures

this could be done in several pull requests and should not be done in one huge PR.

I am willing to support whoever wants to work on it. As I never used pgsql and don't have any production app using it at hand, I will not work on this topic myself.

from phpstan-dba.

staabm avatar staabm commented on June 12, 2024

implemented with #328 et. all

I will push out a release now, but of course also need to update the documentation in #351

for anyone interessted in beta-testing it - the configuration file for using it looks like:

<?php // phpstan-dba-bootstrap.php

use staabm\PHPStanDba\QueryReflection\RuntimeConfiguration;
use staabm\PHPStanDba\QueryReflection\PdoPgSqlQueryReflector;
use staabm\PHPStanDba\QueryReflection\QueryReflection;
use staabm\PHPStanDba\QueryReflection\RecordingQueryReflector;
use staabm\PHPStanDba\QueryReflection\ReflectionCache;

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

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

$config = new RuntimeConfiguration();
// $config->debugMode(true);
// $config->stringifyTypes(true);

// TODO: Put your database credentials here
$pdo = new PDO(..)

QueryReflection::setupReflector(
    new RecordingQueryReflector(
        ReflectionCache::create(
            $cacheFile
        ),
        new PdoPgSqlQueryReflector($pdo)
    ),
    $config
);

while the phpstandba engine requires PDO-PGSQL, the codebase beeing analyzed can use Doctrine or PDO.
for custom pgsql query apis you might also use SyntaxErrorInQueryMethodRule and/or SyntaxErrorInQueryFunctionRule like described in the project readme

from phpstan-dba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.