Dustin Wilson
3 years ago
15 changed files with 158 additions and 36 deletions
@ -0,0 +1,31 @@ |
|||
<?php |
|||
/** @license MIT |
|||
* Copyright 2021 Dustin Wilson et al. |
|||
* See LICENSE file for details */ |
|||
|
|||
declare(strict_types=1); |
|||
namespace dW\Lit\Grammar; |
|||
use dW\Lit\Grammar; |
|||
|
|||
/** |
|||
* A weak reference to a grammar's self. This indeed doesn't have to exist, but |
|||
* exists to maintain sanity when checking types. |
|||
*/ |
|||
class SelfReference extends Reference { |
|||
protected ?Grammar $grammar; |
|||
|
|||
|
|||
public function __construct(Grammar $grammar) { |
|||
$this->grammar = $grammar; |
|||
} |
|||
|
|||
public function __destruct() { |
|||
parent::__destruct(); |
|||
$this->grammar = null; |
|||
} |
|||
|
|||
|
|||
public function get(): Grammar { |
|||
return $this->grammar; |
|||
} |
|||
} |
Loading…
Reference in new issue