Source Code:
(back to article)
<?php class MyClass { /** * @var int */ private int $myProperty; public function __construct() { $this->myProperty = 0; } public function getMyProperty(): int { return $this->myProperty; } public function setMyProperty(int $value): void { $this->myProperty = $value; } } // Example usage $obj = new MyClass(); echo $obj->getMyProperty() . PHP_EOL; // Output: 0 $obj->setMyProperty(42); echo $obj->getMyProperty(); // Output: 42
Result:
Report an issue