php / php/php-src

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

オープン
#22,684 コメント 0 件 リアクション 1 件 担当者 1 名 GitHub で見る

@DanielEScherzer がすでに取り組んでいます。

2026年7月10日 から。

Extension: reflection Feature
主要言語
C
スター
40.4k
フォーク
8.1k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

<?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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。