Browse Source

refactor: Déplacement de propriétés communes dans AbstractIterateur

remotes/checkIfPRContentChanged-1664374821295033898/issue_5056_composer_road
Matthieu Marcillaud 5 months ago
parent
commit
2880b2037b
  1. 19
      ecrire/src/Core/Iterateur/AbstractIterateur.php
  2. 19
      ecrire/src/Core/Iterateur/Data.php
  3. 19
      ecrire/src/Core/Iterateur/Sql.php

19
ecrire/src/Core/Iterateur/AbstractIterateur.php

@ -4,18 +4,23 @@ namespace Spip\Core\Iterateur;
abstract class AbstractIterateur
{
protected string $type;
/**
* Erreur presente ?
* Calcul du total des elements
*
* @var bool
*/
public $err = false;
* @var int|null
**/
public $total = null;
/** Erreur presente ? **/
public bool $err = false;
public $command;
protected array $command = [];
public $info;
protected array $info = [];
public function __construct($command, $info = []) {
public function __construct(array $command, array $info = []) {
$this->command = $command;
$this->info = $info;
}

19
ecrire/src/Core/Iterateur/Data.php

@ -21,7 +21,6 @@ class Data extends AbstractIterateur implements Iterator
*/
protected array $filtre = [];
/**
* Cle courante
*
@ -36,29 +35,13 @@ class Data extends AbstractIterateur implements Iterator
*/
protected $valeur = null;
protected string $type = 'DATA';
protected array $command = [];
protected array $info = [];
/** Erreur presente ? */
public bool $err = false;
/**
* Calcul du total des elements
*
* @var int|null
**/
public $total = null;
/**
* Constructeur
*
* @param $command
* @param array $info
*/
public function __construct($command, $info = []) {
public function __construct(array $command, array $info = []) {
$this->type = 'DATA';
$this->command = $command;
$this->info = $info;

19
ecrire/src/Core/Iterateur/Sql.php

@ -11,12 +11,6 @@ use Iterator;
*/
class Sql extends AbstractIterateur implements Iterator
{
/**
* Calcul du total des elements.
*
* @var null|int
*/
public $total;
/**
* Ressource sql.
@ -36,21 +30,12 @@ class Sql extends AbstractIterateur implements Iterator
protected int $pos = -1;
protected string $type = 'SQL';
protected array $command = [];
protected array $info = [];
/** Erreur presente ? **/
public bool $err = false;
/*
* array command: les commandes d'initialisation
* array info: les infos sur le squelette
*/
public function __construct($command, $info = []) {
public function __construct(array $command, array $info = []) {
$this->type = 'SQL';
parent::__construct($command, $info);
$this->select();

Loading…
Cancel
Save