function Snapshot::snapshotStaticProperties
1 call to Snapshot::snapshotStaticProperties()
- Snapshot::__construct in vendor/
sebastian/ global-state/ src/ Snapshot.php
File
-
vendor/
sebastian/ global-state/ src/ Snapshot.php, line 233
Class
- Snapshot
- A snapshot of global state.
Namespace
SebastianBergmann\GlobalStateCode
private function snapshotStaticProperties() : void {
foreach ($this->classes as $className) {
$class = new ReflectionClass($className);
$snapshot = [];
foreach ($class->getProperties() as $property) {
if ($property->isStatic()) {
$name = $property->getName();
if ($this->excludeList
->isStaticPropertyExcluded($className, $name)) {
continue;
}
if (!$property->isInitialized()) {
continue;
}
$value = $property->getValue();
if ($this->canBeSerialized($value)) {
/* @noinspection UnserializeExploitsInspection */
$snapshot[$name] = unserialize(serialize($value));
}
}
}
if (!empty($snapshot)) {
$this->staticProperties[$className] = $snapshot;
}
}
}