php / php/php-src

Reflection(Class)Constant::__toString() should print booleans as booleans

Offen
#22,684 0 Kommentare 1 Reaktion 1 zugewiesene Person Auf GitHub ansehen

@DanielEScherzer arbeitet bereits daran.

Seit 10.7.2026.

Extension: reflection Feature
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

<?php

echo new ReflectionConstant('true');
echo new ReflectionConstant('false');

class Demo {
    public const MY_TRUE = true;
    public const MY_FALSE = false;
    
    public $true = true;
    public $false = false;
}
echo new ReflectionClassConstant(Demo::class, 'MY_TRUE');
echo new ReflectionClassConstant(Demo::class, 'MY_FALSE');
echo new ReflectionProperty(Demo::class, 'true');
echo new ReflectionProperty(Demo::class, 'false');

function demo($t = true, $f = false) {}
echo new ReflectionFunction('demo');

shows:

Constant [ <persistent> bool TRUE ] { 1 }
Constant [ <persistent> bool FALSE ] {  }
Constant [ public bool MY_TRUE ] { 1 }
Constant [ public bool MY_FALSE ] {  }
Property [ public $true = true ]
Property [ public $false = false ]
Function [ <user> function demo ] {
  @@ /in/5nqGe 18 - 18

  - Parameters [2] {
    Parameter #0 [ <optional> $t = true ]
    Parameter #1 [ <optional> $f = false ]
  }
}

booleans in constants should be true or false, not 1 or (missing)
Marking as a feature request since this is a behavior change and shouldn't be applied to released versions

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.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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