New in PhpStorm 10 – Dataflow Analysis

PhpStorm 10 gives you an amazing new feature – the ability to analyze the data flow of your application without even leaving your IDE.

Using the new Dataflow Analysis tools, you can quickly and easily understand the paths the code has taken to get to any given point, which is fantastic for better understanding third party code, understanding complicated areas of your application, or finding bottlenecks in your logic.

Using the Dataflow Analyzer is easy — simply place the caret over the desired expression, method or variable, and select Analyze Data Flow To/From Here from the Code menu. PhpStorm will ask you in which scope you wish to analyze the data flow, and then show you the results in the Analyze Data Flow pane.

Using Analyze Data Flow To Here, you can see how a value has got to this line of the code, essentially it asks the question “how did this given value get here?”.

Analyse Data Flow Results

Here you can see the results of an Analyze Data Flow From Here request, showing how the selected value will be used after the current point in the execution – it asks the question “Where does this value go from here?”.

Keep up with the latest PhpStorm news on our blog and follow us on Twitter @phpstorm.

Happy developing!

– JetBrains PhpStorm Team

About Gary Hockin

Gary Hockin has been creating code to power web applications for 15 years, the last three of them at an extraordinary level. He is handsome, talented, funny and articulate, and also extremely modest. Gary is a valued contributor to Zend Framework 2 and is a member of the community review team. He's married and has two wonderful children, and when he's not coding, writing about code, speaking about code or reading about code, he can usually be found in the pub playing pool.
This entry was posted in Cool Feature and tagged , , . Bookmark the permalink.
  • Gustavo L. Fabro

    Awesome!!!

  • Alexander Romanenko

    Thank you for another release! I shall renew the subscription to support your work.

    Of all the new features “Analyse Data Flow To Here” feature jumpted out at me and is worth the whole upgrade alone. I immidiately jumpted to try it but found its current implementation not useful. I have a class like this:

    class Panel extends AbstractStandalone {

    private $title;

    public function __construct() {

    }

    public function __toString() {
    // rendering code
    }

    public function __invoke($title = null) {
    // allows to be used inline within a template
    }
    }

    which is typically used this way

    /** @var Panel $pluginInstance */
    $pluginInstance = $this->$helperPluginName();
    // set ViewModel to the helper
    $helperPluginStringContent = trim((string)$pluginInstance);

    This is a very typical every day PHP workflow, especially dominant in popular frameworks, such as Zend Framework. Class has a magic method, often __toString(), sometimes __invoke() and __call($function, $params) which gets executed based on end usage. A developer usually knows which magic function to look at based on usage. In the example, having it cast to a string, or used in context of a string in general, I know I should look at any __toString() through the class hierarchy to see how the value gets generated.

    If I am to trust Dataflow Analysis at all, I need to be confident it does not trip up over magic calls. At the moment, my example stops at trim() function falsely leading me to believe the variable starts there. Therfore, if I decide to use this feature in daily work, I will have to verify that every endpoint of the analysis graph does not stumble on a magic function, probably not only no saving any time at all but causing extra debug time.

    I can see how this analysis type is very difficult to implement accurately for implicitly called function, but there are a number of usecases that follow fairly obvious and consistent rules that can help analyser really stand out above other PHP IDEs. Ignoring these potentially sends the wrong message and falsely advertises its capabilities.

  • http://webuniverse.io Serge Zarouski

    This looks exciting. Is it possible to implement the same thing for Javascript or it is too dynamic for it?