-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated PushHttpProxy for dynamic properties in PHP 8.2 and later
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License, | ||
* version 3, along with this program. If not, see | ||
* http://www.gnu.org/licenses/ | ||
* | ||
*/ | ||
|
||
namespace ZK\Engine; | ||
|
||
/** | ||
* DynamicPropertyTrait implements dynamic properties for a class. | ||
* | ||
* Automatic dynamic properties are deprecated as of PHP 8.2; | ||
* see: https://www.php.net/manual/en/migration82.deprecated.php | ||
* | ||
* This trait adds support for dynamic properties to any class, | ||
* for any version of PHP. | ||
*/ | ||
trait DynamicPropertyTrait { | ||
protected $propertyMap = []; | ||
|
||
public function __isset($var) { | ||
return key_exists($var, $this->propertyMap); | ||
} | ||
|
||
public function __get($var) { | ||
if(key_exists($var, $this->propertyMap)) | ||
return $this->propertyMap[$var]; | ||
|
||
$shortName = (new \ReflectionClass($this))->getShortName(); | ||
trigger_error("Undefined property $shortName::$var", E_USER_WARNING); | ||
} | ||
|
||
public function __set($var, $val) { | ||
$this->propertyMap[$var] = $val; | ||
} | ||
|
||
public function __unset($var) { | ||
unset($this->propertyMap[$var]); | ||
} | ||
} |