From 2964153e54b269c833810194f16bd9bccc9267ce Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Sun, 31 Dec 2023 22:37:04 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- .idea/nulib.iml | 2 +- composer.json | 2 +- php/src_php/ICloseable.php | 10 ++ php/{src_sys => src_php}/README.md | 2 +- php/{src_sys => src_php/content}/IContent.php | 2 +- .../content}/IPrintable.php | 2 +- .../content}/IStaticContent.php | 2 +- php/{src_sys => src_php/content}/content.php | 3 +- php/{src_sys => src_php}/func.php | 2 +- php/src_php/iter/AbstractIterator.php | 148 ++++++++++++++++++ php/src_php/json/JsonException.php | 20 +++ php/src_ref/{sys => php}/ref_func.php | 2 +- .../{sys => php/content}/contentTest.php | 5 +- .../{sys => php/content}/impl/AContent.php | 4 +- .../{sys => php/content}/impl/APrintable.php | 4 +- .../content}/impl/AStaticContent.php | 5 +- php/tests/{sys => php/content}/impl/ATag.php | 6 +- php/tests/{sys => php/content}/impl/html.php | 4 +- php/tests/{sys => php}/funcTest.php | 2 +- 19 files changed, 205 insertions(+), 22 deletions(-) create mode 100644 php/src_php/ICloseable.php rename php/{src_sys => src_php}/README.md (78%) rename php/{src_sys => src_php/content}/IContent.php (89%) rename php/{src_sys => src_php/content}/IPrintable.php (85%) rename php/{src_sys => src_php/content}/IStaticContent.php (87%) rename php/{src_sys => src_php/content}/content.php (99%) rename php/{src_sys => src_php}/func.php (99%) create mode 100644 php/src_php/iter/AbstractIterator.php create mode 100644 php/src_php/json/JsonException.php rename php/src_ref/{sys => php}/ref_func.php (96%) rename php/tests/{sys => php/content}/contentTest.php (92%) rename php/tests/{sys => php/content}/impl/AContent.php (65%) rename php/tests/{sys => php/content}/impl/APrintable.php (62%) rename php/tests/{sys => php/content}/impl/AStaticContent.php (59%) rename php/tests/{sys => php/content}/impl/ATag.php (77%) rename php/tests/{sys => php/content}/impl/html.php (86%) rename php/tests/{sys => php}/funcTest.php (99%) diff --git a/.idea/nulib.iml b/.idea/nulib.iml index 4a9634a..670e1a9 100644 --- a/.idea/nulib.iml +++ b/.idea/nulib.iml @@ -7,7 +7,7 @@ - + diff --git a/composer.json b/composer.json index e4c7711..544d425 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "psr-4": { "nulib\\": "php/src_base", "nulib\\ref\\": "php/src_ref", - "nulib\\sys\\": "php/src_sys", + "nulib\\php\\": "php/src_php", "nulib\\output\\": "php/src_output", "nulib\\web\\": "php/src_web" } diff --git a/php/src_php/ICloseable.php b/php/src_php/ICloseable.php new file mode 100644 index 0000000..7b26316 --- /dev/null +++ b/php/src_php/ICloseable.php @@ -0,0 +1,10 @@ +rewind(); + } + + ############################################################################# + # Implémentation par défaut + + private $setup = false; + private $valid = false; + private $toredown = true; + + private $index = 0; + protected $key; + protected $item = null; + + function key() { + return $this->key; + } + + function current() { + return $this->item; + } + + function next(): void { + if ($this->toredown) return; + $this->valid = false; + try { + $item = $this->_next($key); + } catch (EOFException $e) { + $this->beforeClose(); + try { + $this->_teardown(); + } catch (Exception $e) { + } + $this->toredown = true; + return; + } + $this->cook($item); + $this->item = $item; + if ($key !== null) { + $this->key = $key; + } else { + $this->index++; + $this->key = $this->index; + } + $this->valid = true; + } + + function rewind(): void { + if ($this->setup) { + if (!$this->toredown) { + $this->beforeClose(); + try { + $this->_teardown(); + } catch (Exception $e) { + } + } + $this->setup = false; + $this->valid = false; + $this->toredown = true; + $this->index = 0; + $this->key = null; + $this->item = null; + } + } + + function valid(): bool { + if (!$this->setup) { + try { + $this->_setup(); + } catch (Exception $e) { + } + $this->setup = true; + $this->toredown = false; + $this->beforeIter(); + $this->next(); + } + return $this->valid; + } +} diff --git a/php/src_php/json/JsonException.php b/php/src_php/json/JsonException.php new file mode 100644 index 0000000..97c3d8c --- /dev/null +++ b/php/src_php/json/JsonException.php @@ -0,0 +1,20 @@ +