Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 94e2cd4

Browse files
committed
feat: StoppableEventInterface implementation
Since v3 still targets PHP versions prior to PHP 7.2, this patch provides a forwards-compatibility shim for the PSR-14 `StoppableEventInterface` via an additional, package-specific version that is now also implemented by default in the `Event` class.
1 parent 27eb148 commit 94e2cd4

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

src/Event.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22
/**
3-
* Zend Framework (http://framework.zend.com/)
4-
*
5-
* @link http://github.com/zendframework/zend-eventmanager for the canonical source repository
6-
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7-
* @license https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md
3+
* @see https://github.com/zendframework/zend-eventmanager for the canonical source repository
4+
* @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md New BSD License
86
*/
97

108
namespace Zend\EventManager;
@@ -17,7 +15,7 @@
1715
* Encapsulates the target context and parameters passed, and provides some
1816
* behavior for interacting with the event manager.
1917
*/
20-
class Event implements EventInterface
18+
class Event implements EventInterface, StoppableEventInterface
2119
{
2220
/**
2321
* @var string Event name
@@ -192,10 +190,20 @@ public function stopPropagation($flag = true)
192190
/**
193191
* Is propagation stopped?
194192
*
193+
* @deprecated Use isPropagationStopped instead, to make your application
194+
* forwards-compatible with PSR-14 and zend-eventmanager v4.
195195
* @return bool
196196
*/
197197
public function propagationIsStopped()
198198
{
199199
return $this->stopPropagation;
200200
}
201+
202+
/**
203+
* {@inheritDoc}
204+
*/
205+
public function isPropagationStopped()
206+
{
207+
return $this->stopPropagation;
208+
}
201209
}

src/EventInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ public function stopPropagation($flag = true);
9090
/**
9191
* Has this event indicated event propagation should stop?
9292
*
93+
* @deprecated Implement StoppableEventInterface instead, to make your
94+
* application forwards-compatible with PSR-14 and zend-eventmanager v4.
9395
* @return bool
9496
*/
9597
public function propagationIsStopped();

src/StoppableEventInterface.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-eventmanager for the canonical source repository
4+
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-eventmanager/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace Zend\EventManager;
9+
10+
/**
11+
* Forwards-compatibility shim for the PSR-14 StoppableEventInterface
12+
*
13+
* This interface can be mixed into the `Event` instance to make it
14+
* forwards-compatible with PSR-14.
15+
*/
16+
interface StoppableEventInterface
17+
{
18+
/**
19+
* @return bool
20+
*/
21+
public function isPropagationStopped();
22+
}

0 commit comments

Comments
 (0)