php / php/php-src

Wrong line & file on error trace

Offen
#18,105 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Category: Engine Status: Verified
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.2k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

Description
definitions.php
<?php

class ThrowableParam {
	
   public function __construct() {
		
       // this will be line #7 for definitions.php:
      throw new Exception(sprintf('I expect to indicate file %s on line %s but it throws', basename(__FILE__), __LINE__));
		
   }
	
}

trait TraitInASeparateFile {

    // but this will be line #16 for definitions.php:		
    public function execute(ThrowableParam $param=new ThrowableParam): void {}
	
}

?>
main.php
<?php

include './definitions.php';

class Foo  {

    use TraitInASeparateFile;

}

$bar=new Foo;
$bar->execute(); // line #11 for main.php

// So, there is no line #16 for main.php

?>
RESULT :

Fatal error: Uncaught Exception: I expect to indicate file definitions.php on line 7 but it throws in ./main.php:16

  Stack trace:
  #0 ./definitions.php(7): constant expression
  #1 ./definitions.php(16): ThrowableParam->__construct()
  #2 ./main/php(11): Foo->execute()
  #3 {main}
  thrown in /var/www/html/nbcloud/_tests/bugPHP.php on line 16

BUT EXPECT :

Fatal error: Uncaught Exception: I expect to indicate file definitions.php on line 7 but it throws in ./definitions.php:7

  Stack trace:
  #0 ./definitions.php(7): constant expression
  #1 ./definitions.php(16): ThrowableParam->__construct()
  #2 ./main/php(11): Foo->execute()
  #3 {main}
  thrown in /var/www/html/nbcloud/_tests/bugPHP.php on line 16

PHP Version

8.4.5

Operating System

Debian 11

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Bericht mit definitions.php und main.php unter PHP 8.4.5 zu reproduzieren, und vergleiche die Stelle, an der der Fehler ausgelöst wird, mit dem Stacktrace. Untersuche die Laufzeitbehandlung des Defaultarguments des Konstruktors als konstanten Ausdruck und überprüfe, dass die gemeldete Stelle, an der der Fehler ausgelöst wird, definitions.php:7 und nicht main.php:16 ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.