File: DojoFunctionCall.php

package info (click to toggle)
dojo 1.10.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 97,980 kB
  • ctags: 10,348
  • sloc: php: 10,616; xml: 3,429; java: 3,098; sql: 928; sh: 484; pascal: 205; perl: 182; makefile: 77; python: 45; sed: 37; ruby: 10
file content (81 lines) | stat: -rw-r--r-- 2,110 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

require_once('DojoParameters.php');
require_once('DojoBlock.php');

class DojoFunctionCall extends DojoBlock
{
  private $object = 'DojoFunctionCall';

  private $name;
  private $parameters;

  public function __construct($package, $line_number = false, $position = false){
    parent::__construct($package, $line_number, $position);
    $this->parameters = new DojoParameters($package);
  }

  public function __destruct() {
    parent::__destruct();
    unset($this->parameters);
  }

  public function build() {
    if (!$this->start) {
      return null; // FIXME: does this ever die?
        die("DojoFunctionCall->build() used before setting a start position");
      }

      $code = $this->package->getCode();
      $this->parameters->setStart($this->start[0], strpos($code[$this->start[0]], '(', $this->start[1]));
      $end = $this->parameters->build();

      $this->setEnd($end[0], $end[1]);
      return $end;
  }

  public function getAssignment() {
    $this->build();
    $code = $this->package->getCode();
    $line = Text::blankOutAt($code[$this->start[0]], $this->start[1]);
    if (preg_match('%([\w_.$]+)\s*=\s*$%', $line, $match)) {
      return $match[1];
    }
  }

  public function removeCodeFrom($lines){
    for($i = $this->start[0]; $i <= $this->end[0]; $i++){
      $line = $lines[$i];
      if ($i == $this->start[0]) {
        $lines[$i] = Text::blankOutAt($line, $this->start[1]);
      }
      elseif ($i == $this->end[0]) {
        $lines[$i] = Text::blankOutAt($line, 0, $this->end[1]);
      }else{
        $lines[$i] = Text::blankOut($line, $line);
      }
    }
    return $lines;
  }

  public function getName(){
    if($this->name){
    return $this->name;
  }

    $line = Text::chop($this->package->getCode(), $this->start[0], $this->start[1], $this->start[0]);
    $line = $line[$this->start[0]];
    return $this->name = trim(substr($line, 0, strpos($line, '(')));
  }

  public function getParameter($pos){
    return $this->parameters->getParameter($pos);
  }

  public function getParameters(){
    return $this->parameters->getParameters();
  }

}

?>