Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #914 +/- ##
============================================
+ Coverage 70.78% 73.42% +2.63%
- Complexity 3769 5609 +1840
============================================
Files 163 264 +101
Lines 8870 13479 +4609
============================================
+ Hits 6279 9897 +3618
- Misses 2591 3582 +991 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
A pure-PHP readline replacement purpose-built for PsySH. Instead of
delegating to ext-readline or ext-libedit, this gives PsySH full control
over input, editing, completion, and rendering.
The completion system is syntax, type, and runtime-value aware; it
parses your input, resolves types from live objects in scope, and
completes based on what your code actually is, not just string matching
on symbol names.
Highlights:
- Completions that understand your code: $user->getA resolves $user's
type at runtime and completes with its actual methods and properties.
Fuzzy matching and interactive selection menu.
- Multi-line editing that just works: auto-continues on unclosed brackets
or incomplete statements, with syntax-aware indent/dedent
- Smart bracket and quote auto-pairing
- Reverse history search (Ctrl-R)
Opt in via config or CLI flag:
'useExperimentalReadline' => true
psysh --experimental-readline
…dle multiline natively)
…dline availability
27c7619 to
4c0d732
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Experimental interactive readline
PsySH has always been limited by what
ext-readlineandext-libeditexpose: flat completion lists, single-line input, no context awareness. This is a pure-PHP readline replacement that gives PsySH full control over the interactive experience.This is opt-in and experimental. Default behavior is completely unchanged.
Completions that actually understand your code
The old tab completion system matches strings against lists of known symbol names. The new completion engine is fundamentally different; it's syntax-aware, type-aware, and runtime-value-aware:
$foo->needs instance methods,Foo::needs static members, and a barearraneeds global functions or classes.$repo->find(1)->with the right type.$useris aUserinstance,$user->completes withUser's real methods and properties, not just every method name PHP knows about.Completions show in a navigable multi-column menu (arrow keys to browse, type to filter). Fuzzy matching means
asumfindsarray_sumandstlfindsstrtolower.Multi-line editing that just works
Press Enter with unclosed brackets or an incomplete statement and the input continues on the next line, with proper indentation. Closing brackets auto-dedent. Shift+Enter always inserts a newline. No more fighting the shell to write a multi-line closure.
Feels like a real editor
(inserts()with cursor inside, typing)skips over the existing one, backspace between()deletes both)How to try it
# Or from the command line psysh --experimental-readlineRequires a TTY (interactive terminal). Falls back to the standard readline stack in non-interactive contexts.
Architecture notes
Readline\Interactive\Input engine: action-based key dispatch, text buffer, key bindings, terminal management, frame-based renderingCompletion\New completion system: context analysis via php-parser, runtime type resolution, 14+ completion sources, fuzzy matchingMatcherAdapterSourceRelated issues
This addresses a bunch of long-standing readline and tab completion issues:
(to autocompletable methods to distinguish from props #869 ✅… and lays the groundwork for even more:
SourceInterface)What's NOT changing
GnuReadline,Libedit,Userland) are untouched