Quant
Quant

Reputation: 360

Code hinting method properties in PhpStorm

Suppose I have the following class:

namespace Acme\SuperBundle\Resources;
use \DOMDocument;
/**
* Class XMLAnswerParser
* @package Acme\SuperBundle\Resources
* @author Quant
* @param \DOMDocument $dom
*/
class XMLAnswerParser
{

public $dom;
private $profile;

// a whole lot of things

protected function checkDOM()
{
    $this->dom-> 

And I'd expect any IDE to give me hinting knowing that the $dom property is a DOMDocument. Somehow this is not working in my IDE phpstorm. Am I doing something wrong with the documentation of the class?

The code contains no errors, in case you'd ask that.

Upvotes: 0

Views: 1125

Answers (3)

Milad Rahimi
Milad Rahimi

Reputation: 3844

Add

namespace Acme\SuperBundle\Resources;
use \DOMDocument;
/**
 * Class XMLAnswerParser
 * @package Acme\SuperBundle\Resources
 * @author Quant
 */
class XMLAnswerParser
{

/**
 * @var \DOMDocument $dom
 */
public $dom;

private $profile;

// a whole lot of things

protected function checkDOM()
{
    $this->dom-> 

Then the IDE will know what $dom exatctly is.

Upvotes: 1

hovszabolcs
hovszabolcs

Reputation: 101

@param \DOMDocument $dom --> @property \DOMDocument $dom

Upvotes: 0

Quant
Quant

Reputation: 360

<?php
/**
* @var DOMDocument $dom
*/
public $dom
?>

Was the way to do it!

Upvotes: 4

Related Questions