mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2026-07-30 00:30:19 +08:00
Merge commit 'de4bf25cb3' into release/8.4.0-beta
# Conflicts:
# public/legacy/data/SugarBean.php
# public/legacy/include/Smarty/plugins/function.sugarvar.php
# public/legacy/include/SugarDateTime.php
# public/legacy/include/database/MysqliManager.php
# public/legacy/modules/Alerts/metadata/listviewdefs.php
# public/legacy/modules/SugarFeed/Dashlets/SugarFeedDashlet/SugarFeedDashlet.php
# public/legacy/modules/Trackers/metadata/SearchFields.php
# public/legacy/modules/Trackers/metadata/listviewdefs.php
# public/legacy/modules/UpgradeWizard/SugarMerge/EditViewMerge.php
# public/legacy/suitecrm_version.php
36 lines
1 KiB
PHP
36 lines
1 KiB
PHP
<?php
|
|
/**
|
|
* Smarty plugin
|
|
*
|
|
* @package Smarty
|
|
* @subpackage PluginsModifier
|
|
*/
|
|
/**
|
|
* Smarty count modifier plugin
|
|
* Type: modifier
|
|
* Name: count
|
|
* Purpose: counts all elements in an array or in a Countable object
|
|
* Input:
|
|
* - Countable|array: array or object to count
|
|
* - mode: int defaults to 0 for normal count mode, if set to 1 counts recursive
|
|
*
|
|
* @param mixed $arrayOrObject input array/object
|
|
* @param int $mode count mode
|
|
*
|
|
* @return int
|
|
*/
|
|
function smarty_modifier_count($arrayOrObject, $mode = 0)
|
|
{
|
|
/*
|
|
* @see https://www.php.net/count
|
|
* > Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface,
|
|
* > 1 would be returned, unless value was null, in which case 0 would be returned.
|
|
*/
|
|
|
|
if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) {
|
|
return count($arrayOrObject, (int) $mode);
|
|
} elseif ($arrayOrObject === null) {
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|