From b568ece8f01b256b1403b4d4d3c51dc1ee0fb6fe Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Thu, 4 Jun 2020 09:15:40 +0700 Subject: [PATCH] convert symbol to string --- src/Lib/Types.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Lib/Types.php b/src/Lib/Types.php index 02b04fc..175aed8 100644 --- a/src/Lib/Types.php +++ b/src/Lib/Types.php @@ -29,7 +29,7 @@ class Types implements ILib )); $env->set('str', new CoreFunc('str', 'Convert arguments to string and concatenate them together.', 0, -1, - fn (...$args) => implode('', array_map('strval', $args)) + fn (...$args) => implode('', array_map([$this, 'getStrValue'], $args)) )); $env->set('symbol', new CoreFunc('symbol', 'Convert argument to symbol.', 1, 1, @@ -134,4 +134,13 @@ class Types implements ILib fn ($a) => $a % 2 !== 0 )); } + + private function getStrValue($a) + { + if ($a instanceof Symbol) { + return $a->getName(); + } + + return strval($a); + } }