Page 1 of 1

php7.0 strict types

PostPosted: Mon Mar 20, 2017 9:25 pm
by sany6014
Hi everyone!
Do you agree with behavior in code below:
Code: Select all
declare(strict_types=1);

abstract class Core {
    abstract public function foo(array $arr): int;
}

class A extends Core {
    public function foo(array $arr): string {
        return 'asdas';
    }
}
- this one will thrown Fatal error because of function signature,

but not this -
Code: Select all
declare(strict_types=1);

trait Core {
    abstract public function foo(array $arr): int;
}

class A {
    use Core;
   
    public function foo(array $arr): string {
        return 'asdas';
    }
}


And what do you think about this?