Skip to content

Commit 505efcb

Browse files
committed
add smart deprecation warnings
1 parent da7e2b5 commit 505efcb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/DataObjects/Printer.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,20 @@ public function __construct(
1010
public string $description,
1111
public array $options
1212
) {}
13+
14+
public function __get(string $name): mixed
15+
{
16+
return match ($name) {
17+
'status' => $this->handleDeprecatedProperty('status', 0),
18+
'isDefault' => $this->handleDeprecatedProperty('isDefault', false),
19+
default => throw new \InvalidArgumentException("Property '{$name}' does not exist on Printer class"),
20+
};
21+
}
22+
23+
private function handleDeprecatedProperty(string $property, mixed $defaultValue): mixed
24+
{
25+
logger()->warning("Deprecated: Printer::\${$property} property has been removed in upstream Electron and will no longer be available");
26+
27+
return $defaultValue;
28+
}
1329
}

0 commit comments

Comments
 (0)