Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DQL inspections example/proposal for JetBrains PHPStorm EAP
<?php
class Foo {
private $bar = 'baz';
/** @var Baz @ORM\ManyToOne(targetEntity=Baz::class) */
private $baz;
}
class Baz {
private $tab = 'taz';
}
$simpleDql = <<<'DQL'
SELECT f FROM Foo f
DQL;
// Currently, people write this for easy refactoring
$dqlWithClassReferenceAsWeCurrentlyDoIt = 'SELECT f FROM ' . Foo::class . ' f';
$dqlWithFieldAccess = <<<'DQL'
SELECT f FROM Foo f WHERE f.bar = "example"
DQL;
$dqlWithAssociationJoin = <<<'DQL'
SELECT f, b FROM Foo f JOIN f.baz b WHERE b.tab = "example"
DQL;
// Highlight lexemes (or AST nodes)
// Hover on "Foo" - reference to Foo class
// Detect usage of "Foo" inside DQL
// Refactoring Foo? Renames?
// Refactor Foo.bar (detected as Foo#$bar)
// Refactor Foo.baz.tab ($dqlWithAssociationJoin)
// Detect usage of Foo.baz.tab
// Detect unknown associations?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment