Skip to content

Silent failure of PHP fatal errors #6294

@wradder

Description

@wradder
Q A
PHPUnit version 12.3.0
PHP version 8.4.3
Installation Method Composer

Summary

Certain types of errors do no longer show up int he output

Current behavior

The script silently fails, without any error in the output. See cli output:

PHPUnit 12.3.0 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.3

How to reproduce

See the following test setup:

A.php

<?php declare(strict_types=1);
class A
{
  public function someFunction(): void{
    echo 'A::someFunction' . PHP_EOL;
  }
}

B.php

<?php declare(strict_types=1);
class B extends A
{
  // incorrect access level
  protected function someFunction(): void
  {
    parent::someFunction();

    echo 'B::someFunction' . PHP_EOL;
  }  
}

Test.php

<?php declare(strict_types=1);
use \PHPUnit\Framework\TestCase;

final class ExampleTest extends TestCase
{
  public function testOne(): void
  {
    require_once('A.php');
    require_once('B.php');    

    $this->assertSame(1, 1);
  }
}

Expected behavior

Some form of error in the output, see CLI output:

PHPUnit 12.0.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.3

PHP Fatal error:  Access level to B::someFunction() must be public (as in class A) in ...

NOTE: it seems 12.0.10 was the latest version where the errors were shown

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions