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
+22
-17
@@ -11,51 +11,56 @@
|
||||
namespace IPS\Patterns;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ArrayAccess;
|
||||
use function defined;
|
||||
use function is_string;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise Class
|
||||
*/
|
||||
class _Bitwise implements \ArrayAccess
|
||||
class Bitwise implements ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @brief Values
|
||||
*/
|
||||
public $values = array();
|
||||
public array $values = array();
|
||||
|
||||
/**
|
||||
* @brief Original Values
|
||||
*/
|
||||
public $originalValues = 0;
|
||||
public int|array $originalValues = 0;
|
||||
|
||||
/**
|
||||
* @brief Keys
|
||||
*/
|
||||
protected $keys = array();
|
||||
protected array $keys = array();
|
||||
|
||||
/**
|
||||
* @brief Keys Lookup
|
||||
*/
|
||||
protected $lookup = array();
|
||||
protected array $lookup = array();
|
||||
|
||||
/**
|
||||
* @brief Callback when value is changed
|
||||
*/
|
||||
protected $callback = NULL;
|
||||
protected ?string $callback = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $values The numbers
|
||||
* @param array $keys Multi-dimensional array. Keys match keys in $value, value is associative array with keys and representive value, or just a list of keys in order
|
||||
* @param callback|null $callback Callback when value is changed
|
||||
* @param callback|null $callback Callback when value is changed
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( array $values, array $keys, $callback=NULL )
|
||||
public function __construct(array $values, array $keys, callable $callback=NULL )
|
||||
{
|
||||
$this->values = $values;
|
||||
$this->originalValues = $values;
|
||||
@@ -65,7 +70,7 @@ class _Bitwise implements \ArrayAccess
|
||||
$i = 1;
|
||||
foreach ( $fields as $k => $v )
|
||||
{
|
||||
if ( \is_string( $v ) )
|
||||
if ( is_string( $v ) )
|
||||
{
|
||||
$this->keys[ $groupKey ][ $v ] = $i;
|
||||
$this->lookup[ $k ] = $groupKey;
|
||||
@@ -96,7 +101,7 @@ class _Bitwise implements \ArrayAccess
|
||||
* @param string $offset Offset
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists( $offset )
|
||||
public function offsetExists( $offset ): bool
|
||||
{
|
||||
return isset( $this->lookup[ $offset ] );
|
||||
}
|
||||
@@ -107,7 +112,7 @@ class _Bitwise implements \ArrayAccess
|
||||
* @param string $offset Offset
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetGet( $offset )
|
||||
public function offsetGet( $offset ): bool
|
||||
{
|
||||
$group = $this->lookup[ $offset ];
|
||||
return (bool) ( $this->values[ $group ] & $this->keys[ $group ][ $offset ] );
|
||||
@@ -120,7 +125,7 @@ class _Bitwise implements \ArrayAccess
|
||||
* @param bool $value Value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet( $offset, $value )
|
||||
public function offsetSet( mixed $offset, mixed $value ): void
|
||||
{
|
||||
if ( $this->callback !== NULL )
|
||||
{
|
||||
@@ -145,9 +150,9 @@ class _Bitwise implements \ArrayAccess
|
||||
* @param string $offset Offset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset( $offset )
|
||||
public function offsetUnset( mixed $offset ): void
|
||||
{
|
||||
return $this->offsetSet( $offset, FALSE );
|
||||
$this->offsetSet( $offset, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +160,7 @@ class _Bitwise implements \ArrayAccess
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function asArray()
|
||||
public function asArray(): array
|
||||
{
|
||||
$return = array();
|
||||
|
||||
|
||||
Reference in new issue
Block a user