|
@@ -297,7 +297,9 @@ class Tokens extends \SplFixedArray
|
|
{
|
|
{
|
|
$this->changed = true;
|
|
$this->changed = true;
|
|
$this->namespaceDeclarations = null;
|
|
$this->namespaceDeclarations = null;
|
|
- $this->unregisterFoundToken($this[$index]);
|
|
|
|
|
|
+ if (isset($this[$index])) {
|
|
|
|
+ $this->unregisterFoundToken($this[$index]);
|
|
|
|
+ }
|
|
|
|
|
|
parent::offsetUnset($index);
|
|
parent::offsetUnset($index);
|
|
}
|
|
}
|
|
@@ -322,7 +324,6 @@ class Tokens extends \SplFixedArray
|
|
if (isset($this[$index])) {
|
|
if (isset($this[$index])) {
|
|
$this->unregisterFoundToken($this[$index]);
|
|
$this->unregisterFoundToken($this[$index]);
|
|
}
|
|
}
|
|
-
|
|
|
|
$this->registerFoundToken($newval);
|
|
$this->registerFoundToken($newval);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1048,7 +1049,7 @@ class Tokens extends \SplFixedArray
|
|
public function isAllTokenKindsFound(array $tokenKinds): bool
|
|
public function isAllTokenKindsFound(array $tokenKinds): bool
|
|
{
|
|
{
|
|
foreach ($tokenKinds as $tokenKind) {
|
|
foreach ($tokenKinds as $tokenKind) {
|
|
- if (empty($this->foundTokenKinds[$tokenKind])) {
|
|
|
|
|
|
+ if (!isset($this->foundTokenKinds[$tokenKind])) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1064,7 +1065,7 @@ class Tokens extends \SplFixedArray
|
|
public function isAnyTokenKindsFound(array $tokenKinds): bool
|
|
public function isAnyTokenKindsFound(array $tokenKinds): bool
|
|
{
|
|
{
|
|
foreach ($tokenKinds as $tokenKind) {
|
|
foreach ($tokenKinds as $tokenKind) {
|
|
- if (!empty($this->foundTokenKinds[$tokenKind])) {
|
|
|
|
|
|
+ if (isset($this->foundTokenKinds[$tokenKind])) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1079,7 +1080,7 @@ class Tokens extends \SplFixedArray
|
|
*/
|
|
*/
|
|
public function isTokenKindFound($tokenKind): bool
|
|
public function isTokenKindFound($tokenKind): bool
|
|
{
|
|
{
|
|
- return !empty($this->foundTokenKinds[$tokenKind]);
|
|
|
|
|
|
+ return isset($this->foundTokenKinds[$tokenKind]);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1381,7 +1382,7 @@ class Tokens extends \SplFixedArray
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Register token as found.
|
|
|
|
|
|
+ * Unregister token as not found.
|
|
*
|
|
*
|
|
* @param array{int}|string|Token $token token prototype
|
|
* @param array{int}|string|Token $token token prototype
|
|
*/
|
|
*/
|
|
@@ -1392,11 +1393,11 @@ class Tokens extends \SplFixedArray
|
|
? ($token->isArray() ? $token->getId() : $token->getContent())
|
|
? ($token->isArray() ? $token->getId() : $token->getContent())
|
|
: (\is_array($token) ? $token[0] : $token);
|
|
: (\is_array($token) ? $token[0] : $token);
|
|
|
|
|
|
- if (!isset($this->foundTokenKinds[$tokenKind])) {
|
|
|
|
- return;
|
|
|
|
|
|
+ if (1 === $this->foundTokenKinds[$tokenKind]) {
|
|
|
|
+ unset($this->foundTokenKinds[$tokenKind]);
|
|
|
|
+ } else {
|
|
|
|
+ --$this->foundTokenKinds[$tokenKind];
|
|
}
|
|
}
|
|
-
|
|
|
|
- --$this->foundTokenKinds[$tokenKind];
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|