I am sending PHP objects to template files and would like to document at the top of my template file which properties of the object (using __get) are available and what they are, and make them available for code hinting.
Here is an example.
In my controller:
$obj = new Template("welcomePage"); $obj->title = "Welcome!"; $obj->render();
In my view / template:
<?php /** * @var $obj Template The template data wrapper * @property $obj->title string The page header text /* ?> <h1><?php echo $obj->title; ?></h1>
Is there something similar to this that will work? The way I did this will now not be automatically completed if I started typing $obj-> , that is, I (or a team member) need to refer to the top of the template to find every available property.
I was considering expanding the Template class for each type of template, but this seems like an unnecessary overhead since I could only add a row and an array to the page, and also create a separate class for each template, partial template and combination both seem a little silly.
Thanks ~
php model-view-controller templates
Prodikl
source share