<?php
class Point
{
    // private $x;
    // private $y;

    public function __construct(private int $x = 0, private int $y = 0)
    {
        echo 'Вызов конструктора <br />';
        $this->x = $x;
        $this->y = $y;
    }

    public function inner()
    {
        $this->__construct();
    }

    // public function setX(int $x): void
    // {
    //     $this->x = $x;
    // }
    // public function setY(int $y): void
    // {
    //     $this->y = $y;
    // }

    public function __get($key)
    {
        if ($key === 'distance') {
            return sqrt($this->getX() ** 2 + $this->getY() ** 2);
        } else {
            return null;
        }
    }
    public function getX(): int
    {
        return $this->x;
    }
    public function getY(): int
    {
        return $this->y;
    }

    public function listVariables(): array
    {
        return get_object_vars($this);
    }

    public function __destruct()
    {
        echo 'Вызов деструктора <br />';
    }
}