[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-internals
Subject:    Re: [PHP-DEV] [RFC][Vote] Covariant Returns and Contravariant Parameters
From:       Levi Morrison <levim () php ! net>
Date:       2018-12-27 17:48:44
Message-ID: CAFMT4NqxV4zsepa-Zh7vYCj6yjr9Xr0cb__eqhF6J2TnApGvpA () mail ! gmail ! com
[Download RAW message or body]

> 2. But this test misses warning
>
>
> <?php
> $q = 1;
> if ($q) {
>         class C {}
>         class D {}
> }
>
> class A {
>         function bar(C $c) {}
> }
> class B extends A {
>         function bar(D $D) {
>                 echo "ok\n";
>         }
> }
> ?>

The code detects this as an error but intentionally does not report it
because in other cases a warning is already issued and I did not want
to re-issue the warning again. I'll dig into this more to see why it
is not issued the first time in this case.

However, this should *remain* a warning to be consistent with existing
code. When a class extends another non-abstract class and there isn't
an interface involved then it's only a warning. We should fix this in
PHP 8.0 for all cases.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic