Support for PHP - Dynamic code

PHP support in Spider also includes a hint mechanism called Dynamic Code. In fact, this mechanism consists of two tools:

Dynamic code takes data from PHP definition file and parses existing script code. This way, it is possible to give names and argument lists of built-in functions (and there are well over 2000 of them in total, including the ones included in the modules) and predefined and declared PHP variables and constants in the script. This makes it much more efficient to write scripts - you don't have to remember the exact names of all PHP functions, you don't have to remember the names of methods in classes, or the long list of variables.

However, support for PHP begins in Spider as soon as the string string indicating the beginning of a PHP block. When you enter it, and then press Space or Enter, the code will be automatically completed with the ?> symbol (the end of the PHP block). Depending on the selected option in Program settings / Other settings / Enablers... / Dynamic PHP Hints, an extra blank line may or may not be inserted between those symbols.

Dynamic code

Dynamic code works by suggesting the names of usable elements (functions, class methods, variables and constants). The tool can be called in two ways:

  1. - using the dynamic code activation command on the editor mini bar (the icon shown next). Hints will appear after a while of inactivity.
  2. using keyboard shortcut - you can always call up a balloon with a hint to the currently typed function by pressing Ctrl+Spacekeyboard shortcut

If you have enabled automatic display, type a function name (e.g. mysql_) and wait a moment - a list of items you can use will appear. The list will highlight the first item that most closely matches the string you typed (e.g. for mysql_c this will be the name of the function mysql_connect()). If auto-hints is disabled, use Ctrl+Space to get a hint.

The tool also hints method names in classes based on which objects were created. For example, if there is a class and its object:

class A
{
   function A ()
   {
      // function code
   }
}

$obj = new A;

Now just type (vertical line means the cursor in the document):

$obj->|
and use the shortcut Ctrl+Space (or wait a moment if you activated the dynamic code). A window will appear with the name of the A() method. Similarly, you can use the described mechanism when creating a class definition extending another class (inheriting from a class) using the extends keyword. The program takes into account the scope of visibility of fields and methods:
class A
{
   public function A ()
   {
      // code
   }

   protected function R ()
   {
      // code
   }
}

class B extends A
{
  public function B ()
   {
     // code
   }

   private function P ()
   {
      // code
   }
}

$obj = new B;

In the above example, the mechanism of dynamic code will also come to our aid when selecting the class from which class B should inherit (just press Ctrl+Space after typing the word extends, and a list of classes will appear), as well as when using the methods provided by both classes. As you know, the object created on the basis of class B will also handle the methods contained in class A, so in the construction hint:

$obj->|
method names A() and B() will be found, but the function names R () and P() will not.

In the case of PHP built-in functions, the type of the variable returned by the function is displayed before the function name, e.g.: int count( ) (which means that the count() function returns an integer result).

You can navigate through the list using scroll bars, arrows, etc. (as in any window). To insert the selected structure into the document, press Enter, or click on it.

The icons next to the names indicate whether it is a variable, constant, or function name

Dynamic hints

Dynamic hints work by prompting for function arguments as the script is being written. The tool gets the data similarly to the dynamic code - from the definition file and from the script analysis results. Thanks to that you don't have to remember or search in the code which arguments are required by the function.

The tool can be invoked in two ways:

  1. automatic hints - use the command in the editor's mini bar. After typing the function name and opening parenthesis (eg. mysql_connect( ), wait for a moment and a balloon will pop up with arguments to use. The argument you want to use will be highlighted in bold. The command icon is shown above.
  2. using keyboard shortcut - you can always call up a balloon with a tooltip for the currently used function by pressing ctrl+keyboard shortcut

Settings and other dynamic hints options
When developing complex projects, you may also need hints for functions not directly linked to the script being edited. For example, the current script may be attached to another file or the entire system (e.g. as a module/plugin ). In this case, there are no functions declared anywhere in the current script that you may want to use. However, to make the Dynamic Code work for these functions as well, you can force the file (or files) with their declarations to be included in the Dynamic Code mechanism. To do this, you need to use the Program Settings - Dynamic PHP Hints window.

In the same window, you can select the pledges of functions and variables to appear in the hints.

Related topics

To top