Fatal error mutator interface #1908
-
1) K:\php-forge\html\src\Attribute\Input\HasValue.php:33 [M] PublicVisibility
--- Original
+++ New
@@ @@
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-value
*/
- public function value(mixed $value) : static
+ protected function value(mixed $value) : static
{
$new = clone $this;
$new->attributes['value'] = $value;
$ C:\php\php.exe K:\php-forge\html\vendor\bin\phpunit --configuration "C:/Users/ap117/AppData/Local/Temp/infection/phpunitConfiguration.eeab4355db766d8708c96d853c99f893.infection.xml"
PHPUnit 10.5.4 by Sebastian Bergmann and contributors.
Runtime: PHP 8.1.13
Configuration: C:\Users\ap117\AppData\Local\Temp\infection\phpunitConfiguration.eeab4355db766d8708c96d853c99f893.infection.xml
Fatal error: Access level to PHPForge\Html\Input\Base\AbstractChoiceList::value() must be public (as in class PHPForge\Html\Input\InputInterface) in K:\php-forge\html\src\Attribute\Input\HasValue.php on line 31
As you can see, infection tries to mutate a method that is in a trait and belongs to an interface, I have tried to add it in exclude in infection.json.dist and in phpunit.xml.dist without being able to avoid the fatal error, is there a way to solve it , I use phpunit 10.5 and the latest version of the infection. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, I don't think we can do something smart here and prevent generating this mutation by Infection out of the box. Reproducer: https://infection-php.dev/r/kop7 At the time of mutating, Infection sees the trait and it doesn't know in which class this trait is going to be used - it just mutates the trait. Traits can't implement interfaces, so it's impossible to understand if the public method of the trait is part of the contract (interface), looking only to the trait. Fatal errors are treated as killed Mutants, so the only issue here is we are wasting time by generating always killed mutant. Still, we can ignore such mutations by adding |
Beta Was this translation helpful? Give feedback.
Hi, I don't think we can do something smart here and prevent generating this mutation by Infection out of the box.
Reproducer: https://infection-php.dev/r/kop7
At the time of mutating, Infection sees the trait and it doesn't know in which class this trait is going to be used - it just mutates the trait.
Traits can't implement interfaces, so it's impossible to understand if the public method of the trait is part of the contract (interface), looking only to the trait.
Fatal errors are treated as killed Mutants, so the only issue here is we are wasting time by generating always killed mutant.
Still, we can ignore such mutations by adding
ignore
rules: see https://infection-php.dev/r/grde