Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created September 21, 2018 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/5dea4bd9c2f5587c49169662d6eeb7c3 to your computer and use it in GitHub Desktop.
Save Ocramius/5dea4bd9c2f5587c49169662d6eeb7c3 to your computer and use it in GitHub Desktop.
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