staabm / phpstan-dba

PHPStan based SQL static analysis and type inference for the database access layer
https://staabm.github.io/archive.html#phpstan-dba
MIT License
250 stars 17 forks source link

AST named column (use raw expression from sqlwtf) #580

Closed jakubvojacek closed 1 year ago

jakubvojacek commented 1 year ago

https://github.com/staabm/phpstan-dba/pull/570 got too messy after rebasing etc, decided to make it again from scratch

jakubvojacek commented 1 year ago

I dont think this

protected function setUp(): void
    {
        QueryReflection::getRuntimeConfiguration()->utilizeSqlAst(true);
    }

    protected function tearDown(): void
    {
        QueryReflection::getRuntimeConfiguration()->utilizeSqlAst(false);
    }

works properly, the tests are failing as if the AST wasnt enabled at all (which I double checked in QueryReflector by dumping the runtime config)

if (
                self::getRuntimeConfiguration()->isUtilizingSqlAst()
            ) {

I am not very much familiar wiht phpunit, I usually use nette/tester or codeception

staabm commented 1 year ago

I think the reason that it worked for DoctrineKeyValueStyleRuleStrictTest extends RuleTestCase but not in this PR is the different base class DbaAstInferenceTest extends TypeInferenceTestCase. unfortunately we cannot use a different base class here.

it seems your previous approach using a new test-suite was the right one. I have forgotten about that technical limitation of TypeInferenceTestCase. sorry.