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,49 +11,55 @@
|
||||
namespace IPS\Patterns;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Countable;
|
||||
use IteratorIterator;
|
||||
use Traversable;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* ActiveRecord IteratorIterator
|
||||
*/
|
||||
class _ActiveRecordIterator extends \IteratorIterator implements \Countable
|
||||
class ActiveRecordIterator extends IteratorIterator implements Countable
|
||||
{
|
||||
/**
|
||||
* @brief Classname
|
||||
*/
|
||||
public $classname;
|
||||
public string $classname;
|
||||
|
||||
/**
|
||||
* @brief Parent classname
|
||||
*/
|
||||
public $parentClassname = NULL;
|
||||
public mixed $parentClassname = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Traversable $iterator The iterator
|
||||
* @param Traversable $iterator The iterator
|
||||
* @param string $classname The classname
|
||||
* @param string|NULL $parentClass Parent classname, if the parent data is also available (e.g. joined in a query)
|
||||
* @param string|null $parentClassname Parent classname, if the parent data is also available (e.g. joined in a query)
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \Traversable $iterator, $classname, $parentClassname = NULL )
|
||||
public function __construct(Traversable $iterator, $classname, string $parentClassname = NULL )
|
||||
{
|
||||
$this->classname = $classname;
|
||||
$this->parentClassname = $parentClassname;
|
||||
|
||||
return parent::__construct( $iterator );
|
||||
parent::__construct( $iterator );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current
|
||||
*
|
||||
* @return \IPS\Patterns\ActiveRecord
|
||||
* @return ActiveRecord
|
||||
*/
|
||||
public function current()
|
||||
public function current(): ActiveRecord
|
||||
{
|
||||
$current = parent::current();
|
||||
|
||||
@@ -72,6 +78,7 @@ class _ActiveRecordIterator extends \IteratorIterator implements \Countable
|
||||
}
|
||||
}
|
||||
|
||||
/* @var ActiveRecord $classname */
|
||||
$classname = $this->classname;
|
||||
return $classname::constructFromData( $current );
|
||||
}
|
||||
@@ -81,7 +88,7 @@ class _ActiveRecordIterator extends \IteratorIterator implements \Countable
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
public function count(): int
|
||||
{
|
||||
return (int) $this->getInnerIterator()->count();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user