2

In my controller I have code like this:

public function showStudent($id)
{
    $student = new Student();
    $student->loadFromId($id);

    /* call the view */
    include '/path/to/student/view.php';
}

In the view.php file I want my code editor (netbeans, of course) to know $student is an instance of the Student class so it can suggest and check methods and properties etc. Can I help the editor to know this with an annotation, like

<?php
/**
* @magic Student $student
*/
?>
<html>
....
<p>Good day, <?= $student->name; ?></p>
</html>

1 Answer 1

1
/* @var $student Student */
$student->name;

Netbeans, of course? You should look at Sublime Text.

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry, doesn't work for me. According to the ApiGen docs @var takes two arguments: datatype and description and should precede the variable declaration. I don't want to redeclare the variable
No dice. Maybe it's Sublime specific?
Your answer should work on a healthy netbeans install: netbeans.org/bugzilla/show_bug.cgi?id=222012 Thanks for putting me on the right track.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.