1: <?php
2: /**
3: * @author Jefferson González
4: * @license MIT
5: * @link http://github.com/peg-org/peg-src Source code.
6: */
7:
8: namespace Peg\Lib\Definitions\Element;
9:
10: /**
11: * Represents a function or class method element.
12: */
13: class FunctionElement
14: {
15:
16: /**
17: * Holds the name of the element
18: * @var string
19: */
20: public $name;
21:
22: /**
23: * Description of the element.
24: * @var string
25: */
26: public $description;
27:
28: /**
29: * List of overloads for this function/method
30: * @var \Peg\Lib\Definitions\Element\Overload[]
31: */
32: public $overloads;
33:
34: /**
35: * Reference to the class containing this element if applicable.
36: * @var \Peg\Lib\Definitions\Element\ClassElement
37: */
38: public $parent_class;
39:
40: /**
41: * Reference to the header containing this element.
42: * @var \Peg\Lib\Definitions\Element\Header
43: */
44: public $header;
45:
46: /**
47: * Reference to the namespace containing this element.
48: * @var \Peg\Lib\Definitions\Element\NamespaceElement
49: */
50: public $namespace;
51:
52: /**
53: * Creates a function element.
54: * @param string $name
55: * @param string $description
56: */
57: public function __construct($name, $description="")
58: {
59: $this->name = $name;
60: $this->description = $description;
61:
62: $this->overloads = array();
63: }
64:
65: /**
66: * Adds a new overload for the function.
67: * @param \Peg\Lib\Definitions\Element\Overload $overload
68: * @return \Peg\Lib\Definitions\Element\FunctionElement
69: */
70: public function AddOverload(\Peg\Lib\Definitions\Element\Overload $overload)
71: {
72: $overload->function =& $this;
73: $this->overloads[] = $overload;
74:
75: return $this;
76: }
77:
78: }