<?php
class Number
{
    private int|float $number;
 
    public function setNumber(int|float $number): void
    {
        $this->number = $number;
    }
 
    public function getNumber(): int|float
    {
        return $this->number;
    }
}

$number = new Number();

$number->setNumber(5);
print $number->getNumber().PHP_EOL;

$number->setNumber(7.5);
print $number->getNumber().PHP_EOL;

$number->setNumber('A');