Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,40 +11,47 @@
|
||||
namespace IPS\Notification;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use IPS\Member;
|
||||
use Iterator;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data Structure for storing notification recipieints - basically a non-unique SplObjectStorage
|
||||
*/
|
||||
class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
class Recipients implements Countable, Iterator, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @brief Recipients
|
||||
*/
|
||||
protected $recipients = array();
|
||||
protected array $recipients = array();
|
||||
|
||||
/**
|
||||
* @brief Count
|
||||
*/
|
||||
protected $count = 0;
|
||||
protected int $count = 0;
|
||||
|
||||
/**
|
||||
* @brief Current position
|
||||
*/
|
||||
protected $position = 0;
|
||||
protected int $position = 0;
|
||||
|
||||
/**
|
||||
* [SplObjectStorage] Add a recipient
|
||||
*
|
||||
* @param \IPS\Member $member The member object
|
||||
* @param array|null $followData If the notification is about something being followed, the appropriate row from core_follow
|
||||
* @param Member $member The member object
|
||||
* @param array|null $followData If the notification is about something being followed, the appropriate row from core_follow
|
||||
* @return void
|
||||
*/
|
||||
public function attach( \IPS\Member $member, $followData = NULL )
|
||||
public function attach( Member $member, array $followData = NULL ) : void
|
||||
{
|
||||
$this->recipients[] = array( 'member' => $member, 'followData' => $followData );
|
||||
$this->count++;
|
||||
@@ -53,10 +60,10 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
/**
|
||||
* [SplObjectStorage] Remove a recipient
|
||||
*
|
||||
* @param \IPS\Member $member The member object
|
||||
* @param Member $member The member object
|
||||
* @return void
|
||||
*/
|
||||
public function detach( \IPS\Member $member, $followData = NULL )
|
||||
public function detach( Member $member ) : void
|
||||
{
|
||||
foreach ( $this->recipients as $k => $data )
|
||||
{
|
||||
@@ -73,7 +80,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
@@ -81,9 +88,9 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
/**
|
||||
* [Iterator] Get current
|
||||
*
|
||||
* @return \IPS\Member
|
||||
* @return Member
|
||||
*/
|
||||
public function current()
|
||||
public function current(): Member
|
||||
{
|
||||
return $this->recipients[ $this->position ]['member'];
|
||||
}
|
||||
@@ -93,7 +100,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function getInfo()
|
||||
public function getInfo(): ?array
|
||||
{
|
||||
return $this->recipients[ $this->position ]['followData'];
|
||||
}
|
||||
@@ -103,7 +110,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
public function key(): int
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
@@ -113,7 +120,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next()
|
||||
public function next() : void
|
||||
{
|
||||
$this->position++;
|
||||
}
|
||||
@@ -123,7 +130,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind()
|
||||
public function rewind() : void
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
@@ -133,7 +140,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
public function valid(): bool
|
||||
{
|
||||
return $this->position < $this->count;
|
||||
}
|
||||
@@ -144,7 +151,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
* @param mixed $offset The offset
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists( $offset )
|
||||
public function offsetExists( mixed $offset ): bool
|
||||
{
|
||||
return $offset < $this->count;
|
||||
}
|
||||
@@ -153,9 +160,9 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
* [ArrayAccess] Get offset
|
||||
*
|
||||
* @param mixed $offset The offset
|
||||
* @return \IPS\Member
|
||||
* @return Member
|
||||
*/
|
||||
public function offsetGet( $offset )
|
||||
public function offsetGet( mixed $offset ): Member
|
||||
{
|
||||
return $this->recipients[ $offset ]['member'];
|
||||
}
|
||||
@@ -165,9 +172,9 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
*
|
||||
* @param mixed $offset The offset
|
||||
* @param mixed $value The value
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet( $offset, $value )
|
||||
public function offsetSet( mixed $offset, mixed $value ): void
|
||||
{
|
||||
$this->recipients[] = array( 'member' => $value, 'followData' => NULL );
|
||||
|
||||
@@ -183,7 +190,7 @@ class _Recipients implements \Countable, \Iterator, \ArrayAccess
|
||||
* @param mixed $offset The offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset( $offset )
|
||||
public function offsetUnset( mixed $offset ) : void
|
||||
{
|
||||
if ( isset( $this->recipients[ $offset ] ) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user