summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Wisselink <wisskid@users.noreply.github.com>2024-04-19 10:42:54 +0200
committerGitHub <noreply@github.com>2024-04-19 10:42:54 +0200
commit9a8702d9372b7e68b41303cd2182b7c30a688ec7 (patch)
treed769748e931e7d8eda0b2076dc94079fb89c56c3 /src
parent5ee4363000ce32bfa45be5156a665bb6132313b4 (diff)
downloadsmarty-9a8702d9372b7e68b41303cd2182b7c30a688ec7.tar.gz
smarty-9a8702d9372b7e68b41303cd2182b7c30a688ec7.tar.bz2
smarty-9a8702d9372b7e68b41303cd2182b7c30a688ec7.zip
Corrected invalid classnames in Runtime code for foreach (#1001)
Fixes #1000
Diffstat (limited to 'src')
-rw-r--r--src/Runtime/ForeachRuntime.php18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/Runtime/ForeachRuntime.php b/src/Runtime/ForeachRuntime.php
index fc311df0..06da7d54 100644
--- a/src/Runtime/ForeachRuntime.php
+++ b/src/Runtime/ForeachRuntime.php
@@ -116,22 +116,20 @@ class ForeachRuntime {
*
* @return int the count for arrays and objects that implement countable, 1 for other objects that don't, and 0
* for empty elements
+ * @throws \Exception
*/
- public function count($value) {
- if ($value instanceof IteratorAggregate) {
+ public function count($value): int
+ {
+ if ($value instanceof \IteratorAggregate) {
// Note: getIterator() returns a Traversable, not an Iterator
// thus rewind() and valid() methods may not be present
return iterator_count($value->getIterator());
- } elseif ($value instanceof Iterator) {
- return $value instanceof Generator ? 1 : iterator_count($value);
- } elseif ($value instanceof Countable) {
+ } elseif ($value instanceof \Iterator) {
+ return $value instanceof \Generator ? 1 : iterator_count($value);
+ } elseif ($value instanceof \Countable) {
return count($value);
- } elseif ($value instanceof PDOStatement) {
- return $value->rowCount();
- } elseif ($value instanceof Traversable) {
- return iterator_count($value);
}
- return count((array)$value);
+ return count((array) $value);
}
/**