Browse Source

Fixing bugs in scope serialization

main
Dustin Wilson 3 years ago
parent
commit
a4707060c0
  1. 10
      lib/Scope/Expression.php
  2. 2
      lib/Scope/Filter.php
  3. 6
      lib/Scope/Path.php
  4. 4
      lib/Scope/Scope.php

10
lib/Scope/Expression.php

@ -42,15 +42,15 @@ class Expression extends Node {
public function __toString(): string { public function __toString(): string {
switch ($this->_operator) { switch ($this->_operator) {
case OPERATOR_NONE: $operator = ''; case self::OPERATOR_NONE: $operator = '';
break; break;
case OPERATOR_AND: $operator = '& '; case self::OPERATOR_AND: $operator = '& ';
break; break;
case OPERATOR_OR: $operator = '| '; case self::OPERATOR_OR: $operator = '| ';
break; break;
case OPERATOR_NOT: $operator = '- '; case self::OPERATOR_NOT: $operator = '- ';
} }
return "$operator${$this->_child}"; return "$operator{$this->_child}";
} }
} }

2
lib/Scope/Filter.php

@ -36,6 +36,6 @@ class Filter extends Node {
public function __toString(): string { public function __toString(): string {
return "${$this->side}: ${$this->_child}"; return "{$this->_side}:{$this->_child}";
} }
} }

6
lib/Scope/Path.php

@ -14,7 +14,7 @@ class Path extends Node {
'anchor' => false 'anchor' => false
]; ];
protected array $scopes = []; protected array $_scopes = [];
const ANCHOR_NONE = 0; const ANCHOR_NONE = 0;
const ANCHOR_START = 1; const ANCHOR_START = 1;
@ -32,7 +32,7 @@ class Path extends Node {
return false; return false;
} }
$this->scopes = $scopes; $this->_scopes = $scopes;
$this->frozen['add'] = true; $this->frozen['add'] = true;
return true; return true;
} }
@ -56,7 +56,7 @@ class Path extends Node {
public function __toString(): string { public function __toString(): string {
$result = ''; $result = '';
if ($this->_anchor === self::ANCHOR_START || $this->_anchor === self::ANCHOR_BOTH) { if ($this->_anchor === self::ANCHOR_START || $this->_anchor === self::ANCHOR_BOTH) {
$result .= '^'; $result .= '^';
} }

4
lib/Scope/Scope.php

@ -8,7 +8,7 @@ namespace dW\Lit\Scope;
class Scope extends Node { class Scope extends Node {
protected bool $_anchorToPrevious; protected bool $_anchorToPrevious;
protected array $atoms = []; protected array $_atoms = [];
protected bool $frozen = false; protected bool $frozen = false;
@ -23,7 +23,7 @@ class Scope extends Node {
return false; return false;
} }
$this->atoms = $atoms; $this->_atoms = $atoms;
$this->frozen = true; $this->frozen = true;
return true; return true;
} }

Loading…
Cancel
Save