Skip to content

Further enhance Tinker summary

Rick Hambrook requested to merge feat/tinker-enhancements into main

Enhances the Tinker summary with:

  • Refactored code in a class with separate summary functions for var types
  • Function summary (with parameters, etc)
  • List closures with the functions (configurable)
  • Show docblock for functions (omit if you don't want them)
  • Add banner for explanation of the file if wanted
  • Added configuration

The idea is that you can make the files as simple or complicated as you wish. If you add types to your parameters, they'll be shown. If you add docblocks to your functions, they'll be shown. If you want to show an intro header, you can.

Configuration

Configuration is used to change how the summary is displayed for your replay file.

You can configure:

  • coloursEnabled: bool, default true
  • closuresAsFunctions: bool, default true
  • initialSubValueIndent: string, default " "
  • columnSpacing: int, default 5
  • maxStringLength: int, default 50
  • maxArrayKeyPreview: int, default 5
  • hideSelfFromVars: bool, default false
  • varsToIgnore: array, default [,"e","_","_e","__psysh__","__psysh_include__","__out"]

::config() must be called statically.

Get current configuration by calling with no parameters:

  • $configArray = TinkerSummary::config();

All public properties can be set via:

  • ::config() method with an array, eg
    • TinkerSummary::config(['coloursEnabled' => true, 'columnSpacing' => 5]);
  • ::config() with named parameters, eg
    • TinkerSummary::config(coloursEnabled: true, columnSpacing: 5);
  • Directly setting on the instance, eg
    • TinkerSummary::instance()->coloursEnabled = true;

You can view the current config by calling ::config() with no parameters or by reading the properties directly.

Some sample replay files

Note, that replay-sample-simple.php expects a running Laravel project (it grabs a user for the example)

Notes

  • Considered updating to Termwind, but for now we still need to support older versions of Laravel.
Sample screenshot
Screenshot_2024-04-24_at_2.52.32_PM
Edited by Rick Hambrook

Merge request reports