summaryrefslogtreecommitdiff
path: root/src/ste/STEStandardLibrary.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-05-01 17:33:13 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-05-01 17:33:13 +0200
commit7449faaa76a5b4008fd51a6562cca2e0a852ea6b (patch)
tree9e6bc34afe9e4e7d49b1a26f0b67485869b0a9de /src/ste/STEStandardLibrary.php
parentb0c9a4aeb61aff8a8fa60746cd566e6dbe05a3b5 (diff)
downloadste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.tar.gz
ste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.tar.bz2
ste-7449faaa76a5b4008fd51a6562cca2e0a852ea6b.zip
Clean up code and improve documentation
This switches the code documentation genarator (we're now using phpdoc instead of NaturalDoc). Also various small code cleanup tasks: - Remove unused code - Get rid of `and` / `or`, we're using `&&` / `||` now - Adding missing return values - Helping PhpStorm to detect some dynamically called functions (mark_builtin_callable in Transcompiler) - Reword transcompiling => compiling in documentation
Diffstat (limited to 'src/ste/STEStandardLibrary.php')
-rw-r--r--src/ste/STEStandardLibrary.php74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/ste/STEStandardLibrary.php b/src/ste/STEStandardLibrary.php
index 9850afe..e39b7af 100644
--- a/src/ste/STEStandardLibrary.php
+++ b/src/ste/STEStandardLibrary.php
@@ -13,6 +13,12 @@ class STEStandardLibrary
}
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ */
public static function escape($ste, $params, $sub)
{
if ($ste->evalbool(@$params["lines"])) {
@@ -22,11 +28,24 @@ class STEStandardLibrary
}
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ */
public static function strlen($ste, $params, $sub)
{
return strlen($sub($ste));
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function arraylen($ste, $params, $sub)
{
if (empty($params["array"])) {
@@ -36,6 +55,13 @@ class STEStandardLibrary
return (is_array($a)) ? count($a) : "";
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function inc($ste, $params, $sub)
{
if (empty($params["var"])) {
@@ -45,6 +71,13 @@ class STEStandardLibrary
$ref++;
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function dec($ste, $params, $sub)
{
if (empty($params["var"])) {
@@ -54,11 +87,24 @@ class STEStandardLibrary
$ref--;
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ */
public static function date($ste, $params, $sub)
{
return @strftime($sub($ste), empty($params["timestamp"]) ? @time() : (int) $params["timestamp"]);
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function in_array($ste, $params, $sub)
{
if (empty($params["array"])) {
@@ -71,6 +117,13 @@ class STEStandardLibrary
return in_array($sub($ste), $ar) ? "y" : "";
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function join($ste, $params, $sub)
{
if (empty($params["array"])) {
@@ -79,6 +132,13 @@ class STEStandardLibrary
return implode($sub($ste), $ste->get_var_by_name($params["array"]));
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function split($ste, $params, $sub)
{
if (empty($params["array"])) {
@@ -90,6 +150,13 @@ class STEStandardLibrary
$ste->set_var_by_name($params["array"], explode($params["delim"], $sub($ste)));
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function array_add($ste, $params, $sub)
{
if (empty($params["array"])) {
@@ -104,6 +171,13 @@ class STEStandardLibrary
}
}
+ /**
+ * @param STECore $ste
+ * @param array $params
+ * @param callable $sub
+ * @return string
+ * @throws RuntimeError
+ */
public static function array_filter($ste, $params, $sub)
{
if (empty($params["array"])) {