forked from phpDocumentor/phpDocumentor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventAbstract.php
More file actions
145 lines (135 loc) · 3.86 KB
/
Copy pathEventAbstract.php
File metadata and controls
145 lines (135 loc) · 3.86 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Event;
/**
* Abstract class representing the base elements of a phpDocumentor event.
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2012 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
*/
abstract class EventAbstract extends \Symfony\Component\EventDispatcher\Event implements \ArrayAccess
{
/** @var object Represents an object that is the subject of this event */
protected $subject;
/**
* Initializes this event with the given subject.
*
* @param object $subject
*/
public function __construct($subject)
{
$this->subject = $subject;
}
/**
* Returns the object that is the subject of this event.
*
* @return object
*/
public function getSubject()
{
return $this->subject;
}
/**
* Creates a new instance of a derived object and return that.
*
* Used as convenience method for fluent interfaces.
*
* @param object $subject
*
* @return EventAbstract
*/
public static function createInstance($subject)
{
return new static($subject);
}
/**
* Convenience method to return properties of this event.
*
* Prior to the refactoring to Symfony2's EventDispatcher there were no
* clearly defined event classes and was properties passed using array
* elements.
*
* Since 2.0.0a8 we now use explicit properties and getters and setter for
* this as it makes code more readable and the event writer more flexible.
*
* This method triggers an E_USER_DEPRECATED and should be removed when
* going Beta or RC.
*
* @param string $offset
*
* @deprecated should be removed in 2.0.0 and getters should be used
*
* @return mixed
*/
public function offsetGet($offset)
{
trigger_error(
'Calling event attributes as array elements is deprecated since '
.'2.0.0a8, please use the Event object\'s getters as this feature '
.'will be removed in 2.0.0',
E_USER_DEPRECATED
);
$offset = str_replace('_', ' ', $offset);
$offset = 'get'.str_replace(' ', '', ucwords($offset));
return $this->$offset();
}
/**
* Requirement of the ArrayAccess interface; we do not implement it as it is
* deprecated.
*
* @param string $offset
*
* @throws \Exception because method is explicitly not implemented.
*
* @deprecated should be removed in 2.0.0 beta or rc
*
* @return void
*/
public function offsetExists($offset)
{
throw new \Exception('Not implemented');
}
/**
* Requirement of the ArrayAccess interface; we do not implement it as it is
* deprecated.
*
* @param string $offset
* @param string $value
*
* @throws \Exception because method is explicitly not implemented.
*
* @deprecated should be removed in 2.0.0 beta or rc
*
* @return void
*/
public function offsetSet($offset, $value)
{
throw new \Exception('Not implemented');
}
/**
* Requirement of the ArrayAccess interface; we do not implement it as it is
* deprecated.
*
* @param string $offset
*
* @throws \Exception because method is explicitly not implemented.
*
* @deprecated should be removed in 2.0.0 beta or rc
*
* @return void
*/
public function offsetUnset($offset)
{
throw new \Exception('Not implemented');
}
}