diff --git a/system/arrayClass/Aux/LegacyAux.php b/system/arrayClass/Aux/LegacyAux.php new file mode 100644 index 0000000..df15728 --- /dev/null +++ b/system/arrayClass/Aux/LegacyAux.php @@ -0,0 +1,79 @@ +_container[] = $value; + } else { + $this->_container[$offset] = $value; + } + } + + /** + * Whether or not an offset exists + * + * @param string $offset An offset to check for + * @access public + * @return bool + * @abstracting ArrayAccess + */ + public function offsetExists($offset) + { + if (is_string($offset)) $offset = strtolower($offset); + return isset($this->_container[$offset]); + } + + /** + * Unsets an offset + * + * @param string $offset The offset to unset + * @access public + * @abstracting ArrayAccess + * + * @return void + */ + public function offsetUnset($offset) + { + if (is_string($offset)) $offset = strtolower($offset); + unset($this->_container[$offset]); + } + + /** + * Returns the value at specified offset + * + * @param string $offset The offset to retrieve + * @access public + * @return mixed + * @abstracting ArrayAccess + */ + public function offsetGet($offset) + { + if (is_string($offset)) $offset = strtolower($offset); + return isset($this->_container[$offset]) + ? $this->_container[$offset] + : null; + } +} \ No newline at end of file diff --git a/system/arrayClass/Aux/ModernAux.php b/system/arrayClass/Aux/ModernAux.php new file mode 100644 index 0000000..a3b8bdc --- /dev/null +++ b/system/arrayClass/Aux/ModernAux.php @@ -0,0 +1,80 @@ +_container[] = $value; + } else { + $this->_container[$offset] = $value; + } + } + + /** + * Whether or not an offset exists + * + * @param string $offset An offset to check for + * @access public + * @return bool + * @abstracting ArrayAccess + */ + public function offsetExists($offset): bool + { + if (is_string($offset)) $offset = strtolower($offset); + return isset($this->_container[$offset]); + } + + /** + * Unsets an offset + * + * @param string $offset The offset to unset + * @access public + * @abstracting ArrayAccess + * + * @return void + */ + public function offsetUnset($offset): void + { + if (is_string($offset)) $offset = strtolower($offset); + unset($this->_container[$offset]); + } + + /** + * Returns the value at specified offset + * + * @param string $offset The offset to retrieve + * @access public + * @return mixed + * @abstracting ArrayAccess + */ + public function offsetGet($offset): mixed + { + if (is_string($offset)) $offset = strtolower($offset); + return isset($this->_container[$offset]) + ? $this->_container[$offset] + : null; + } +} \ No newline at end of file diff --git a/system/arrayClass/caseInsensitiveArray.php b/system/arrayClass/caseInsensitiveArray.php index 8e110cc..366b03d 100644 --- a/system/arrayClass/caseInsensitiveArray.php +++ b/system/arrayClass/caseInsensitiveArray.php @@ -7,82 +7,32 @@ namespace Phacil\Framework\ArrayClass; -class CaseInsensitiveArray implements \ArrayAccess -{ - private $_container = array(); +if (version_compare(phpversion(), "7.1.0", "<")) { - /** - * @param array $initial_array - * @return void - */ - public function __construct(array $initial_array = array()) - { - //$this->_container = array_map("strtolower", $initial_array); - $this->_container = array_change_key_case($initial_array); + class supCaseComp extends \Phacil\Framework\ArrayClass\Aux\LegacyAux { + } - /** - * Assigns a value to the specified offset - * - * @param string $offset The offset to assign the value to - * @param mixed $value The value to set - * @access public - * @abstracting ArrayAccess - * - * @return void - */ - public function offsetSet($offset, $value) +} else { + class supCaseComp extends \Phacil\Framework\ArrayClass\Aux\ModernAux { - if (is_string($offset)) $offset = strtolower($offset); - if (is_null($offset)) { - $this->_container[] = $value; - } else { - $this->_container[$offset] = $value; - } + } - /** - * Whether or not an offset exists - * - * @param string $offset An offset to check for - * @access public - * @return bool - * @abstracting ArrayAccess - */ - public function offsetExists($offset) - { - if (is_string($offset)) $offset = strtolower($offset); - return isset($this->_container[$offset]); - } +} - /** - * Unsets an offset - * - * @param string $offset The offset to unset - * @access public - * @abstracting ArrayAccess - * - * @return void - */ - public function offsetUnset($offset) - { - if (is_string($offset)) $offset = strtolower($offset); - unset($this->_container[$offset]); - } +class CaseInsensitiveArray extends supCaseComp implements \ArrayAccess +{ + protected $_container = array(); /** - * Returns the value at specified offset - * - * @param string $offset The offset to retrieve - * @access public - * @return mixed - * @abstracting ArrayAccess + * @param array $initial_array + * @return void */ - public function offsetGet($offset) + public function __construct(array $initial_array = array()) { - if (is_string($offset)) $offset = strtolower($offset); - return isset($this->_container[$offset]) - ? $this->_container[$offset] - : null; + //$this->_container = array_map("strtolower", $initial_array); + $this->_container = array_change_key_case($initial_array); } + } \ No newline at end of file diff --git a/system/database/databases/object/Aux/ComplementItem.php b/system/database/databases/object/Aux/ComplementItem.php new file mode 100644 index 0000000..4b6386d --- /dev/null +++ b/system/database/databases/object/Aux/ComplementItem.php @@ -0,0 +1,33 @@ + + */ + public function count(): int { + return count($this->__data); + } + + /** + * + * @return \Traversable|mixed[] + */ + public function getIterator(): \Traversable { + return new \ArrayIterator($this->__data); + } +} \ No newline at end of file diff --git a/system/database/databases/object/Aux/ComplementItemLegacy.php b/system/database/databases/object/Aux/ComplementItemLegacy.php new file mode 100644 index 0000000..1daa822 --- /dev/null +++ b/system/database/databases/object/Aux/ComplementItemLegacy.php @@ -0,0 +1,32 @@ + + */ + public function count() { + return count($this->__data); + } + + /** + * + * @return \Traversable|mixed[] + */ + public function getIterator() { + return new \ArrayIterator($this->__data); + } +} \ No newline at end of file diff --git a/system/database/databases/object/Aux/ComplementResult.php b/system/database/databases/object/Aux/ComplementResult.php new file mode 100644 index 0000000..e0920db --- /dev/null +++ b/system/database/databases/object/Aux/ComplementResult.php @@ -0,0 +1,30 @@ + + */ + public function count(): int + { + return (int) $this->getNumRows(); + } + + /** + * {@inheritdoc} + */ + public function getIterator(): \Traversable + { + $this->loop($this->rows); + return $this->data; + //return new \ArrayIterator($this->loop($this->rows)); + } +} \ No newline at end of file diff --git a/system/database/databases/object/Aux/ComplementResultLegacy.php b/system/database/databases/object/Aux/ComplementResultLegacy.php new file mode 100644 index 0000000..8aca2ee --- /dev/null +++ b/system/database/databases/object/Aux/ComplementResultLegacy.php @@ -0,0 +1,31 @@ + + */ + public function count() + { + return (int) $this->getNumRows(); + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + $this->loop($this->rows); + return $this->data; + //return new \ArrayIterator($this->loop($this->rows)); + } +} \ No newline at end of file diff --git a/system/database/databases/object/item.php b/system/database/databases/object/item.php index 7fe25d2..341d1e8 100644 --- a/system/database/databases/object/item.php +++ b/system/database/databases/object/item.php @@ -11,18 +11,23 @@ namespace Phacil\Framework\Databases\Object; use Phacil\Framework\Databases\Object\ItemInterface as ObjectInterface; use Traversable; +if (version_compare(phpversion(), "7.1.0", ">=")) { + class ComplementItem extends \Phacil\Framework\Databases\Object\Aux\ComplementItem + { + } +} else { + class ComplementItem extends \Phacil\Framework\Databases\Object\Aux\ComplementItemLegacy + { + } +} + /** * {@inheritdoc} * @method mixed getValue(string $field) * @method mixed getValues(string field, ...) * @package Phacil\Framework\Databases\Object */ -class Item implements ObjectInterface { - /** - * - * @var array|null - */ - protected $__data = null; +class Item extends ComplementItem implements ObjectInterface { /** * @@ -34,14 +39,6 @@ class Item implements ObjectInterface { return $this; } - /** - * - * @return int<0, \max> - */ - public function count(): int { - return count($this->__data); - } - /** * * @param array $data @@ -61,24 +58,16 @@ class Item implements ObjectInterface { return $this; } - /** - * - * @return \Traversable|mixed[] - */ - public function getIterator(): Traversable { - return new \ArrayIterator($this->__data); - } - /** * @param string $key * @return mixed */ private function _getValue($key){ - return $this->__data[$key] ?? null; + return isset($this->__data[$key]) ? $this->__data[$key] : null; } public function __get($key){ - return $this->__data[$key] ?? null; + return isset($this->__data[$key]) ? $this->__data[$key] : null; } /** diff --git a/system/database/databases/object/result.php b/system/database/databases/object/result.php index 3302b60..774369a 100644 --- a/system/database/databases/object/result.php +++ b/system/database/databases/object/result.php @@ -11,7 +11,19 @@ namespace Phacil\Framework\Databases\Object; use Phacil\Framework\Databases\Object\ResultInterface; use SplObjectStorage; -class Result implements ResultInterface { +if (version_compare(phpversion(), "7.1.0", ">=")) { + class ComplementResult extends \Phacil\Framework\Databases\Object\Aux\ComplementResult + { + + } + +} else { + class ComplementResult extends \Phacil\Framework\Databases\Object\Aux\ComplementResultLegacy{ + + } +} + +class Result extends ComplementResult implements ResultInterface { /** * @@ -37,14 +49,6 @@ class Result implements ResultInterface { */ public $data = null; - /** - * {@inheritdoc} - * @return int<0, \max> - */ - public function count(): int { - return (int) $this->getNumRows(); - } - /** * * {@inheritdoc} @@ -87,7 +91,7 @@ class Result implements ResultInterface { * {@inheritdoc} */ public function getRow($numRow = false){ - return $numRow ? ($this->rows[$numRow + 1]?? null ) : $this->row; + return $numRow ? (isset($this->rows[$numRow + 1])?$this->rows[$numRow + 1] : null ) : $this->row; } /** @@ -131,15 +135,5 @@ class Result implements ResultInterface { return $this->data; } - - /** - * {@inheritdoc} - */ - public function getIterator(): \Traversable - { - $this->loop($this->rows); - return $this->data; - //return new \ArrayIterator($this->loop($this->rows)); - } } \ No newline at end of file diff --git a/system/magiql/Syntax/Column.php b/system/magiql/Syntax/Column.php index 8c0a2e4..0ab538b 100644 --- a/system/magiql/Syntax/Column.php +++ b/system/magiql/Syntax/Column.php @@ -112,7 +112,7 @@ class Column implements QueryPartInterface */ public function setAlias($alias) { - if (0 == \strlen($alias)) { + if (!$alias || 0 == \strlen($alias)) { $this->alias = null; return $this;