Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » how to write javadoc for var without defining it?(CodeIgniter views present a challenge)
how to write javadoc for var without defining it? [message #1751279] Fri, 06 January 2017 21:45 Go to next message
sneakyimp Mising name is currently offline sneakyimp Mising nameFriend
Messages: 41
Registered: December 2009
I'm wondering if there's some way to write javadoc comments in an included/required PHP file such that I can assign datatypes to variables defined outside that document so that I get all the cool autocompletion features for my classes.

I ask this because of the way CodeIgniter loads its views. You define controllers to handle user requests and these have methods which load views:
// a controller method
public function mycont() {
  // blah blah do some stuff

  // define an array of data to send to the view
  $data = array(
    "var1" => "i am var one",
    "var2" => "I am var 2"
    "var3" => $someCrazyObject
  $this->load->view("myview", $data); // loads myview.php

then, within myview.php the array keys are instantiated as variables in the local scope:
// myview.php
echo $var1; // outputs i am var one
echo $var2; // outputs i am var2

Sadly, when I open myview.php in PDT, Eclipse doesn't know that $var3 is an instance of the class SomeCrazyObject so I don't get the amazing eclipse code completion features and so on. Is there some way to declare a javadoc comment for $var3 without altering its value?
Re: how to write javadoc for var without defining it? [message #1751367 is a reply to message #1751279] Mon, 09 January 2017 12:22 Go to previous message
Marc-Oliver Stuehmer is currently offline Marc-Oliver StuehmerFriend
Messages: 1
Registered: October 2010
Junior Member
Just put something like this on top of your variable (Of course you may omit the namespace if the class is already "used"):

/** @var $var3 \MyNamespace\SomeCrazyObject */

That should do the trick.
Previous Topic:Installing PDT plugin
Next Topic:[bug?] Rename File
Goto Forum:

Current Time: Fri Jan 27 02:52:44 GMT 2023

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top