|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Fwk |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) 2011-2015, Julien Ballestracci <[email protected]>. |
|
6
|
|
|
* All rights reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
12
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
13
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
14
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
15
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
16
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
17
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
18
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
19
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
20
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
21
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
22
|
|
|
* POSSIBILITY OF SUCH DAMAGE. |
|
23
|
|
|
* |
|
24
|
|
|
* PHP Version 5.3 |
|
25
|
|
|
* |
|
26
|
|
|
* @category Dependency Injection |
|
27
|
|
|
* @package Fwk\Di |
|
28
|
|
|
* @author Julien Ballestracci <[email protected]> |
|
29
|
|
|
* @copyright 2011-2015 Julien Ballestracci <[email protected]> |
|
30
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
31
|
|
|
* @link http://www.phpfwk.com |
|
32
|
|
|
*/ |
|
33
|
|
|
namespace Fwk\Di; |
|
34
|
|
|
|
|
35
|
|
|
use Fwk\Events\Event as BaseEvent; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @category Listeners |
|
39
|
|
|
* @package Fwk\Di |
|
40
|
|
|
* @author Julien Ballestracci <[email protected]> |
|
41
|
|
|
* @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
42
|
|
|
* @link http://www.phpfwk.com |
|
43
|
|
|
*/ |
|
44
|
|
|
class Event extends BaseEvent |
|
45
|
|
|
{ |
|
46
|
|
|
/** |
|
47
|
|
|
* Constructor |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $name |
|
50
|
|
|
* @param array $data |
|
51
|
|
|
* @param Container $container |
|
|
|
|
|
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
|
|
|
|
|
54
|
|
|
*/ |
|
55
|
|
|
public function __construct($name, $data = array(), Container $container = null) |
|
56
|
|
|
{ |
|
57
|
|
|
parent::__construct( |
|
58
|
|
|
$name, array_merge( |
|
59
|
|
|
$data, array( |
|
60
|
|
|
'container' => $container, |
|
61
|
|
|
'returnValue' => null |
|
62
|
|
|
) |
|
63
|
|
|
) |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Defines a returnValue which can be used to override standard return values by functions handling this event. |
|
69
|
|
|
* |
|
70
|
|
|
* @param mixed $value |
|
71
|
|
|
* |
|
72
|
|
|
* @return void |
|
73
|
|
|
*/ |
|
74
|
|
|
public function setReturnValue($value) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->returnValue = $value; |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns the "returnValue" if defined |
|
81
|
|
|
* |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getReturnValue() |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->returnValue; |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Tells if the event has a return value defined |
|
91
|
|
|
* |
|
92
|
|
|
* @return boolean |
|
93
|
|
|
*/ |
|
94
|
|
|
public function hasReturnValue() |
|
95
|
|
|
{ |
|
96
|
|
|
return isset($this->returnValue); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Returns the Dependency Injection Container |
|
101
|
|
|
* |
|
102
|
|
|
* @return Container |
|
103
|
|
|
*/ |
|
104
|
|
|
public function getContainer() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->container; |
|
|
|
|
|
|
107
|
|
|
} |
|
108
|
|
|
} |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.