Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phpstan result types #11

Open
staabm opened this issue Nov 25, 2022 · 3 comments
Open

Phpstan result types #11

staabm opened this issue Nov 25, 2022 · 3 comments

Comments

@staabm
Copy link

staabm commented Nov 25, 2022

In the readme I found

another will hopefully help PHPStan (static analysis tool for PHP) better understand SQL queries and their results

Since I am working on https://github.com/staabm/phpstan-dba - which achives a similar goal, I am interested in your plans. Maybe we can join forces on some of the involved problems..

@paranoiq
Copy link
Member

hi Markus, i am aware of your project, i just did not find time to react ^_^
in fact it was Ondřej Mirtes who made me aware of phpstan-dba and proposed that it would be nice to make it work truly statically (without calling any DB from CI; possibly from DB structure export)

till now i have been finishing the parser side. just two weeks ago i finished all MySQL features support. now i am preparing for a first talk (small local meetup) about this project and going to start promoting this tool

since you have already started to use it (https://github.com/staabm/phpstan-dba/commits/sqlftw), let me know any of your suggestions

providing PHPStan with types is one of the things i would like to do, but currently it is not a top priority. there is a lot of things to do. my plans for upcoming weeks/months are:

  • porting my older tool for analysing SQL migrations on this parser (few dozens of rules, mainly to make migrations safe; they do not work with any type model, but there is already a mechanism to provide existing exported DB structures when needed for analysis)
  • making parser better aware of platform versions (now basicly parses anything from 5.7 to 8.0.30)
  • preparing it for other platforms (MariaDB, PG...)
  • making it able to cope better with partially valid code
  • and of course building a type model for static type analysis of SQL (this could be really fun with user defined types in Postgre ^_^)

so, i am not sure when i will get to the PHPStan part. and maybe i won't have to... : ]

providing types for PHPStan is not the only goal of this project. there is more areas where static analysis is needed:

  • safe migrations
  • analysis of existing DB schema
  • providing types for PHPStan
  • analysing SQL queries from app (security, safety, bugs, performance)
  • analysing external SQL (analytics/data teams etc.)

SQLFTW will need all the parts like type model and provider of existing DB structures anyway, so we can definitely join our forces here

also, pleas also be aware, that this is still an early developer version and some APIs will change. there will be breaking changes in patch versions until i am a little confident about the interfaces and leave 0.1

@staabm
Copy link
Author

staabm commented Feb 14, 2023

thx for the extensive answer. I will try to build up the sql <-> phpstan type system in phpstandba and keep it as isolated as possible for now.

maybe it can later be backported into sqlftw when it fits your roadmap. lets see how it goes.

@staabm
Copy link
Author

staabm commented Feb 26, 2023

I started building dynamic return type extensions for the mysql function library in

https://github.com/staabm/phpstan-dba/tree/main/src/SqlAst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants