On Fri, Dec 5, 2025, 02:42 Bob Weinand <[email protected]> wrote:
>
> Hey Larry,
>
> On 5.12.2025 01:21:43, Larry Garfield wrote:
>
> I've long argued against allowing __toString() for reasons others have 
> already covered, so I won't bother repeating it.  But off hand I don't see 
> why __debugInfo() would cause a problem.  I am not sure it's useful before 
> ADTs happen, but I don't think it would cause any harm?
>
> I found to semi-commonly (the ergonomics of querying are bad) add attributes 
> to enum cases. A __debugInfo() handler could provide information about all 
> attached metadata.
>
>
> Bob

Slight correction: not metadata, we already have it in the form of the
entire internal object state. It's full of noise, the user rarely
wants that.

__debugInfo() could contain a user-readable representation of the
important parts of an object.

For example dumping a Carbon object:

Illuminate\Support\Carbon 2025-12-05 09:38:17.634246 Europe/Berlin (+01:00)

vs

Illuminate\Support\Carbon @1764923897 {#304
  #endOfTime: false
  #startOfTime: false
  #constructedObjectId: "00000000000001300000000000000000"
  #localMonthsOverflow: null
  #localYearsOverflow: null
  #localStrictModeEnabled: null
  #localHumanDiffOptions: null
  #localToStringFormat: null
  #localSerializer: null
  #localMacros: null
  #localGenericMacros: null
  #localFormatFunction: null
  #localTranslator: null
  #dumpProperties: array:3 [
    0 => "date"
    1 => "timezone_type"
    2 => "timezone"
  ]
  #dumpLocale: null
  #dumpDateProperties: null
}

Reply via email to