Tharaka Dilshan
Tharaka Dilshan

Reputation: 4499

Define new properties of a class in phpDoc after dynamically add new property to the class

for an example I have an Eloquent modal named 'Student'

$student = Student::first();

we can add PHP doc comment to this variable like this.

/**
* @var Student $student
*/
$student = Student::first();

in Eloquent modals we can set new attributes at the runtime

$student->setAttribute('is_a_good_boy', true);

now, is there a way to add this dynamic property to the phpDOc?

Upvotes: 2

Views: 1962

Answers (1)

Flying
Flying

Reputation: 4570

Yes, you can use @property tag for this purpose. For example:

/**
 * @property boolean $is_a_good_boy
 */
class Student {

}

Upvotes: 2

Related Questions