PHP,使用父类属性作为子类中的另一种类型

i got 2 class Node and ChildNode, ChildNode extends Node. There property in parent:

class Node {
    protected $discount;
    public function __construct($discount) {
        $this->discount = $discount;

and i use it there like integer value, in the ChildNode i need to hold array of integer values

class ChildNode extends Node {
    public function __construct(Array $discount) {
        $this->discount = $discount; 

Is it normal to do like this?

I don't see any issue with this. If you have multiple classes that will all benefit from a parent class structured this way it makes it easy to add another method or another variable to all of the child classes at once in the future. I also checked to see how PHP handles inheritance since I was not 100% sure on this and also because php will automagically set variables for you if you assign to something like $this->doesnotexistyet = "magic!"; however the below outputs the following...

class A {

    protected $d;

    public function __construct() {
        $this->d = "A";
    }

    public function getDP() {
        return $this->d;
    }

}

class B extends A {

    public function __construct() {
        $this->d = "B";
    }

    public function getD() {
        return $this->d;
    }

}

$a = new A();
echo $a->getDP() . PHP_EOL;

$b = new B();
echo $b->getD() . PHP_EOL;
echo $b->getDP() . PHP_EOL;

var_dump($a , $b);

Output.

A
B
B
object(A)#1 (1) {
  ["d":protected]=>
  string(1) "A"
}
object(B)#2 (1) {
  ["d":protected]=>
  string(1) "B"
}

This was more for me than anything but thought I would add it if it helps others who come across this.