Skip to content

Commit

Permalink
Use ?? instead of ternary
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 24, 2024
1 parent 359f1a5 commit f6e1dff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/php/text/StreamTokenizer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/text/StringTokenizer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/main/php/text/TextTokenizer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit f6e1dff

Please sign in to comment.