From f6e1dff90017b07fda8dc3c82cb465ca2275b2d3 Mon Sep 17 00:00:00 2001 From: Timm Friebe Date: Sun, 24 Mar 2024 21:01:27 +0100 Subject: [PATCH] Use `??` instead of ternary --- src/main/php/text/StreamTokenizer.class.php | 4 ++-- src/main/php/text/StringTokenizer.class.php | 4 ++-- src/main/php/text/TextTokenizer.class.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/php/text/StreamTokenizer.class.php b/src/main/php/text/StreamTokenizer.class.php index 8d2a176..a721078 100755 --- a/src/main/php/text/StreamTokenizer.class.php +++ b/src/main/php/text/StreamTokenizer.class.php @@ -64,7 +64,7 @@ public function pushBack($str) { /** * Returns the next token from this tokenizer's string * - * @param bool delimiters default NULL + * @param ?string $delimiters * @return string next token */ public function nextToken($delimiters= null) { @@ -74,7 +74,7 @@ public function nextToken($delimiters= null) { // Read until we have either find a delimiter or until we have // consumed the entire content. do { - $offset= strcspn($this->_buf, $delimiters ? $delimiters : $this->delimiters); + $offset= strcspn($this->_buf, $delimiters ?? $this->delimiters); if ($offset < strlen($this->_buf) - 1 || !$this->_src->available()) break; $this->_buf.= $this->_src->read(); } while (true); diff --git a/src/main/php/text/StringTokenizer.class.php b/src/main/php/text/StringTokenizer.class.php index f8c69d8..1c6605b 100755 --- a/src/main/php/text/StringTokenizer.class.php +++ b/src/main/php/text/StringTokenizer.class.php @@ -69,14 +69,14 @@ public function pushBack($str) { /** * Returns the next token from this tokenizer's string * - * @param bool delimiters default NULL + * @param ?string $delimiters * @return string next token */ public function nextToken($delimiters= null) { if (empty($this->_stack)) { if ($this->_ofs >= $this->_len) return null; - $offset= strcspn($this->source, $delimiters ? $delimiters : $this->delimiters, $this->_ofs); + $offset= strcspn($this->source, $delimiters ?? $this->delimiters, $this->_ofs); if (!$this->returnDelims || $offset > 0) $this->_stack[]= substr($this->source, $this->_ofs, $offset); if ($this->returnDelims && $this->_ofs + $offset < $this->_len) { $this->_stack[]= $this->source[$this->_ofs + $offset]; diff --git a/src/main/php/text/TextTokenizer.class.php b/src/main/php/text/TextTokenizer.class.php index 900f59d..68b8b1d 100755 --- a/src/main/php/text/TextTokenizer.class.php +++ b/src/main/php/text/TextTokenizer.class.php @@ -62,7 +62,7 @@ public function pushBack($str) { /** * Returns the next token from this tokenizer's string * - * @param bool delimiters default NULL + * @param ?string $delimiters * @return string next token */ public function nextToken($delimiters= null) { @@ -72,7 +72,7 @@ public function nextToken($delimiters= null) { // Read until we have either find a delimiter or until we have // consumed the entire content. do { - $offset= strcspn($this->_buf, $delimiters ? $delimiters : $this->delimiters); + $offset= strcspn($this->_buf, $delimiters ?? $this->delimiters); if ($offset < strlen($this->_buf) - 1) break; if (null === ($buf= $this->source->read())) { break;