-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c158134
commit 75b1d5f
Showing
18 changed files
with
305 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "php.h" | ||
#include "php_psr.h" | ||
#include "psr_event_dispatcher.h" | ||
|
||
#if PHP_VERSION_ID >= 70200 | ||
/* {{{ Psr\EventDispatcher\EventDispatcherInterface */ | ||
|
||
PHP_PSR_API zend_class_entry * PsrEventDispatcherEventDispatcherInterface_ce_ptr; | ||
|
||
static zend_function_entry PsrEventDispatcherEventDispatcherInterface_methods[] = { | ||
PHP_PSR_ABSTRACT_ME(PsrEventDispatcherEventDispatcherInterface, dispatch) | ||
PHP_FE_END | ||
}; | ||
|
||
static zend_always_inline void php_psr_register_PsrEventDispatcherEventDispatcherInterface(INIT_FUNC_ARGS) | ||
{ | ||
zend_class_entry ce; | ||
INIT_CLASS_ENTRY(ce, "Psr\\EventDispatcher\\EventDispatcherInterface", PsrEventDispatcherEventDispatcherInterface_methods); | ||
PsrEventDispatcherEventDispatcherInterface_ce_ptr = zend_register_internal_interface(&ce); | ||
} | ||
|
||
/* }}} Psr\EventDispatcher\EventDispatcherInterface */ | ||
/* {{{ Psr\EventDispatcher\ListenerProviderInterface */ | ||
|
||
PHP_PSR_API zend_class_entry * PsrEventDispatcherListenerProviderInterface_ce_ptr; | ||
|
||
static zend_function_entry PsrEventDispatcherListenerProviderInterface_methods[] = { | ||
PHP_PSR_ABSTRACT_ME(PsrEventDispatcherListenerProviderInterface, getListenersForEvent) | ||
PHP_FE_END | ||
}; | ||
|
||
static zend_always_inline void php_psr_register_PsrEventDispatcherListenerProviderInterface(INIT_FUNC_ARGS) | ||
{ | ||
zend_class_entry ce; | ||
INIT_CLASS_ENTRY(ce, "Psr\\EventDispatcher\\ListenerProviderInterface", PsrEventDispatcherListenerProviderInterface_methods); | ||
PsrEventDispatcherListenerProviderInterface_ce_ptr = zend_register_internal_interface(&ce); | ||
} | ||
|
||
/* }}} Psr\EventDispatcher\ListenerProviderInterface */ | ||
/* {{{ Psr\EventDispatcher\StoppableEventInterface */ | ||
|
||
PHP_PSR_API zend_class_entry * PsrEventDispatcherStoppableEventInterface_ce_ptr; | ||
|
||
static zend_function_entry PsrEventDispatcherStoppableEventInterface_methods[] = { | ||
PHP_PSR_ABSTRACT_ME(PsrEventDispatcherStoppableEventInterface, isPropagationStopped) | ||
PHP_FE_END | ||
}; | ||
|
||
static zend_always_inline void php_psr_register_PsrEventDispatcherStoppableEventInterface(INIT_FUNC_ARGS) | ||
{ | ||
zend_class_entry ce; | ||
INIT_CLASS_ENTRY(ce, "Psr\\EventDispatcher\\StoppableEventInterface", PsrEventDispatcherStoppableEventInterface_methods); | ||
PsrEventDispatcherStoppableEventInterface_ce_ptr = zend_register_internal_interface(&ce); | ||
} | ||
|
||
/* }}} Psr\EventDispatcher\StoppableEventInterface */ | ||
#endif | ||
|
||
/* {{{ PHP_MINIT_FUNCTION */ | ||
PHP_MINIT_FUNCTION(psr_event_dispatcher) | ||
{ | ||
#if PHP_VERSION_ID >= 70200 | ||
php_psr_register_PsrEventDispatcherEventDispatcherInterface(INIT_FUNC_ARGS_PASSTHRU); | ||
php_psr_register_PsrEventDispatcherListenerProviderInterface(INIT_FUNC_ARGS_PASSTHRU); | ||
php_psr_register_PsrEventDispatcherStoppableEventInterface(INIT_FUNC_ARGS_PASSTHRU); | ||
#endif | ||
|
||
return SUCCESS; | ||
} | ||
/* }}} */ | ||
|
||
/* | ||
* Local variables: | ||
* tab-width: 4 | ||
* c-basic-offset: 4 | ||
* End: | ||
* vim600: fdm=marker | ||
* vim: et sw=4 ts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
#ifndef PSR_EVENT_DISPATCHER_H | ||
#define PSR_EVENT_DISPATCHER_H | ||
|
||
#include "php.h" | ||
#include "php_psr.h" | ||
|
||
#if PHP_VERSION_ID >= 70200 | ||
#define PHP_PSR_EVENT_DISPATCHER_VERSION "1.0.0" | ||
|
||
extern PHP_PSR_API zend_class_entry * PsrEventDispatcherEventDispatcherInterface_ce_ptr; | ||
extern PHP_PSR_API zend_class_entry * PsrEventDispatcherListenerProviderInterface_ce_ptr; | ||
extern PHP_PSR_API zend_class_entry * PsrEventDispatcherStoppableEventInterface_ce_ptr; | ||
|
||
extern PHP_MINIT_FUNCTION(psr_event_dispatcher); | ||
|
||
PHP_PSR_BEGIN_ARG_INFO(PsrEventDispatcherEventDispatcherInterface, dispatch, 1) | ||
ZEND_ARG_TYPE_INFO(0, event, IS_OBJECT, 0) | ||
PHP_PSR_END_ARG_INFO() | ||
|
||
PHP_PSR_BEGIN_ARG_WITH_RETURN_TYPE_INFO(PsrEventDispatcherListenerProviderInterface, getListenersForEvent, 1, IS_ITERABLE, 0) | ||
ZEND_ARG_TYPE_INFO(0, event, IS_OBJECT, 0) | ||
PHP_PSR_END_ARG_INFO() | ||
|
||
PHP_PSR_BEGIN_ARG_WITH_RETURN_TYPE_INFO(PsrEventDispatcherStoppableEventInterface, isPropagationStopped, 0, _IS_BOOL, 0) | ||
PHP_PSR_END_ARG_INFO() | ||
#endif | ||
|
||
#endif /* PSR_EVENT_DISPATCHER_H */ | ||
|
||
/* | ||
* Local variables: | ||
* tab-width: 4 | ||
* c-basic-offset: 4 | ||
* End: | ||
* vim600: fdm=marker | ||
* vim: et sw=4 ts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
Psr\EventDispatcher\EventDispatcherInterface | ||
--SKIPIF-- | ||
<?php include('skip_lt_php72.inc'); ?> | ||
--FILE-- | ||
<?php | ||
include __DIR__ . '/SampleEventDispatcher.inc'; | ||
var_dump(interface_exists('\\Psr\\EventDispatcher\\EventDispatcherInterface', false)); | ||
var_dump(class_implements('SampleEventDispatcher', false)); | ||
$dispatcher = new SampleEventDispatcher(); | ||
var_dump($dispatcher instanceof SampleEventDispatcher); | ||
$event = new stdClass(); | ||
$return = $dispatcher->dispatch($event); | ||
var_dump(is_object($return)); | ||
--EXPECT-- | ||
bool(true) | ||
array(1) { | ||
["Psr\EventDispatcher\EventDispatcherInterface"]=> | ||
string(44) "Psr\EventDispatcher\EventDispatcherInterface" | ||
} | ||
bool(true) | ||
string(31) "SampleEventDispatcher::dispatch" | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
Psr\EventDispatcher\ListenerProviderInterface | ||
--SKIPIF-- | ||
<?php include('skip_lt_php72.inc'); ?> | ||
--FILE-- | ||
<?php | ||
include __DIR__ . '/SampleListenerProvider.inc'; | ||
var_dump(interface_exists('\\Psr\\EventDispatcher\\ListenerProviderInterface', false)); | ||
var_dump(class_implements('SampleListenerProvider', false)); | ||
$provider = new SampleListenerProvider(); | ||
var_dump($provider instanceof SampleListenerProvider); | ||
$event = new stdClass(); | ||
$return = $provider->getListenersForEvent($event); | ||
var_dump(is_iterable($return)); | ||
--EXPECT-- | ||
bool(true) | ||
array(1) { | ||
["Psr\EventDispatcher\ListenerProviderInterface"]=> | ||
string(45) "Psr\EventDispatcher\ListenerProviderInterface" | ||
} | ||
bool(true) | ||
string(44) "SampleListenerProvider::getListenersForEvent" | ||
bool(true) | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
Psr\EventDispatcher\StoppableEventInterface | ||
--SKIPIF-- | ||
<?php include('skip_lt_php72.inc'); ?> | ||
--FILE-- | ||
<?php | ||
include __DIR__ . '/SampleStoppableEvent.inc'; | ||
var_dump(interface_exists('\\Psr\\EventDispatcher\\StoppableEventInterface', false)); | ||
var_dump(class_implements('SampleStoppableEvent', false)); | ||
$event = new SampleStoppableEvent(); | ||
var_dump($event instanceof SampleStoppableEvent); | ||
$return = $event->isPropagationStopped(); | ||
var_dump(is_bool($return)); | ||
--EXPECT-- | ||
bool(true) | ||
array(1) { | ||
["Psr\EventDispatcher\StoppableEventInterface"]=> | ||
string(43) "Psr\EventDispatcher\StoppableEventInterface" | ||
} | ||
bool(true) | ||
string(42) "SampleStoppableEvent::isPropagationStopped" | ||
bool(true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
use Psr\EventDispatcher\EventDispatcherInterface; | ||
|
||
class SampleEventDispatcher implements EventDispatcherInterface | ||
{ | ||
public function dispatch(object $event) | ||
{ | ||
var_dump(__METHOD__, is_object($event)); | ||
|
||
return $event; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
use Psr\EventDispatcher\ListenerProviderInterface; | ||
|
||
class SampleListenerProvider implements ListenerProviderInterface | ||
{ | ||
public function getListenersForEvent(object $event): iterable | ||
{ | ||
var_dump(__METHOD__, is_object($event)); | ||
|
||
return new ArrayIterator([]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
use Psr\EventDispatcher\StoppableEventInterface; | ||
|
||
class SampleStoppableEvent implements StoppableEventInterface | ||
{ | ||
public function isPropagationStopped(): bool | ||
{ | ||
var_dump(__METHOD__); | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.