diff options
| author | Simon Rettberg | 2023-11-15 17:53:47 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2023-11-15 17:53:47 +0100 |
| commit | aa49154e5a9ee135c3f0286ddda8a01a5290b1ed (patch) | |
| tree | 0397403f11a8a890ee11458ea0b1887796480115 /inc/arrayutil.inc.php | |
| parent | idea: Always inspect as if strict_types is enabled (diff) | |
| download | slx-admin-aa49154e5a9ee135c3f0286ddda8a01a5290b1ed.tar.gz slx-admin-aa49154e5a9ee135c3f0286ddda8a01a5290b1ed.tar.xz slx-admin-aa49154e5a9ee135c3f0286ddda8a01a5290b1ed.zip | |
Fix more type errors, stricter typing
Diffstat (limited to 'inc/arrayutil.inc.php')
| -rw-r--r-- | inc/arrayutil.inc.php | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/inc/arrayutil.inc.php b/inc/arrayutil.inc.php index 7aded4db..3d93d7d5 100644 --- a/inc/arrayutil.inc.php +++ b/inc/arrayutil.inc.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + class ArrayUtil { @@ -68,4 +70,14 @@ class ArrayUtil return true; } + /** + * Force each element of given array to be of type $type. + */ + public static function forceType(array &$array, string $type): void + { + foreach ($array as &$elem) { + settype($elem, $type); + } + } + }
\ No newline at end of file |
