NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Good Code Insight implementation in variable references.


Joined: 07 Mar 2007
Posts: 44
Location: Lithuania
Reply with quote
Hi to all,

first of all - your IDE rocks. The best IDE I have seen ever! Respect.

I'm not sure, in which board to put this thread, but, I have problems with such code in global context, ex.:

Code:
$object = & new someClass();

// then I'm writing a new class ex.:

class myClass {
     var $objectReference;

     function myClass() {
          global $object;

          // we assign a reference of existing object to our class, but seems that phpED messes with that up.
          // while calling Code Insight like this: $object-> returns list of methods, but...
          $this->objectReference = & object;
         
          // later trying to execute Code Insight like this:
          // $this->objectReference-> returns no inner methods of this object
     }
}


I and (I think) a lot of developers work with objects, that inherits other global objects, but code Insight desn't work in this case, althought it should.
If that would be fixed/implemented in next version of phpED, I'd be the happy'iest person in the earth! Smile Smile

Thank you!
Bye Smile
View user's profileFind all posts by thunder-ltuSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
you need to tell code insight what object instance is stored in objectReference. You may use phpdoc comment for this, like suggested there: http://forum.nusphere.com/tip-type-hints-t1563.html

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 44
Location: Lithuania
Reply with quote
Ah, I got the idea, but still, this is unnecessary code/comment writing. This should be auto detected still...

Thanks again!
Bye Smile
View user's profileFind all posts by thunder-ltuSend private messageVisit poster's website
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
You're right. It can be resolved and we've implemeted this in build 4635 (it's in beta testing now).
Even more, it resolves fine when $object (per your sample) is assigned in another file. See screenshots below:



(BTW, I tried the IDE you mentioned, it supports this only when object is assigned with class instance in the same file and does not support the case shown above)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 44
Location: Lithuania
Reply with quote
Very good news from You Smile! Tried to use your first solution mentioned above. Works well, but waiting for new release Smile.

Best regards, dmitri
Bye Smile
View user's profileFind all posts by thunder-ltuSend private messageVisit poster's website


Joined: 07 Mar 2007
Posts: 44
Location: Lithuania
Reply with quote
Btw, where could I find this beta release?
Thank you!
View user's profileFind all posts by thunder-ltuSend private messageVisit poster's website
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
IMHO They have a select public of beta testers and you can only get the version before official release if they ask you to test it.
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 21 Mar 2007
Posts: 1
Reply with quote
(sorry for my english) If will allow, I would like to add the comment on this theme:
I read topic N1563, and it working, but... If to write:
Code:
<?php

$MyVar = null; //I don't know MyVar type now.
$MySelector = /*0*/ 1 /*2*/;

class Test
{
   function abc()
   {
      echo 'abc';
   }
}

class Test1 extends Test
{
   function def()
   {
      echo 'def';
   }
}

class Test2 extends Test
{
   function xyz()
   {
      echo 'xyz';
   }
}

function InitMyVar()
{
   global $MySelector;
   global $MyVar;
   
   switch ($MySelector)
   {
      case 1:
          $MyVar = new Test1();
          break;
      case 2:
          $MyVar = new Test2();
          break;
       default:
          $MyVar = new Test();
   }
}

function TestMyVar()
{
   global $MySelector;
   global $MyVar;

   /**
    * $MyVar will have tips as Test in this block
    * @var Test
    */
   $MyVar->abc(); // <--- has tips as Test2 now
   
   if ($MySelector === 1)
   {
      /**
       * $MyVar will have tips as Test1 in this block
       * @var Test1
       */
      $MyVar->def(); // <--- has not tips as Test1 now
   }
   elseif ($MySelector === 2)
   {
      /**
       * $MyVar will have tips as Test2 in this block
       * @var Test2
       */
      $MyVar->xyz();// <--- has tips as Test2 now
   }
   
   //Then $MyVar will have tips as Test again when end if-else blocks
}

if (true)
{
   InitMyVar();
   TestMyVar();
}
else
   exit();
?>
View user's profileFind all posts by riffSend private message
Good Code Insight implementation in variable references.
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic