1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00
Arsse/lib/Context/ExclusionContext.php

32 lines
894 B
PHP
Raw Permalink Normal View History

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
2021-04-14 15:17:01 +00:00
namespace JKingWeb\Arsse\Context;
2017-08-29 14:50:31 +00:00
class ExclusionContext extends AbstractContext {
2022-04-20 03:20:20 +00:00
use ExclusionMembers;
public function __construct(?Context $parent = null) {
2022-04-20 03:20:20 +00:00
$this->parent = $parent;
}
public function __clone() {
// if the context was cloned because its parent was cloned, change the parent to the clone
if ($this->parent) {
$t = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS | \DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1];
if (($t['object'] ?? null) instanceof Context && $t['function'] === "__clone") {
$this->parent = $t['object'];
}
}
}
/** @codeCoverageIgnore */
public function __destruct() {
unset($this->parent);
}
2017-08-29 14:50:31 +00:00
}