Reputation: 6872
Given a php class like:
<?php
/**
* A class description.
*
* @property int id
* @property string name
*
*/
class myClass {
public function hasId() {
if ($this->id) {
return true;
} else {
return false;
}
}
}
?>
I would like to have highlighting that $this->id is never declared. I know in PHP that isn't strictly required but our in house standards are asking for it. Is there a way to get this in Intellij/Idea?
Upvotes: 0
Views: 59
Reputation: 92274
If you remove your doc @property int id
. You'll get the warning once you remove it. IntelliJ uses those docs as additional information about a class. You're basically telling IntellJ that the class does have those properties.
There is no way to tell IntelliJ to ignore those comments.
Upvotes: 1
Reputation: 1188
//Main class
class Main{
//Let main class has variable $id
public $id = '123';
}
class myClass extends Main{
public function hasId() {
//Check it!
if (isset($this->id)) {
return true;
} else {
return false;
}
}
}
$newclass = new myClass;
var_dump($newclass->hasId());
Result:
bool(true)
If we comment line with variable declaration //public $id = '123';
Result:
bool(false)
Upvotes: 0