Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive shell doesn't complete property names #17670

Open
GromNaN opened this issue Feb 2, 2025 · 2 comments
Open

Interactive shell doesn't complete property names #17670

GromNaN opened this issue Feb 2, 2025 · 2 comments

Comments

@GromNaN
Copy link
Member

GromNaN commented Feb 2, 2025

Description

According to the documentation:

The interactive shell also features tab completion for functions, constants, class names, variables, static method calls and class constants.

Only function, class and method names seems to be completing when hitting the TAB key.

Also, the completion is not contextualized: after $, it should be only variable names (not function and class names), and after -> it should be only property and method names of the current object.

The following command to run the interactive shell:

php -a

Completion of variable name

The following shell code:

php > $container = 'hello';
php > $co [⇥TAB]

Resulted in this output:

Collator                     collator_get_strength        constant                    
collator_asort               collator_set_attribute       convert_uudecode            
collator_compare             collator_set_strength        convert_uuencode            
collator_create              collator_sort                copy                        
collator_get_attribute       collator_sort_with_sort_keys cos                         
collator_get_error_code      compact                      cosh                        
collator_get_error_message   CompileError                 count                       
collator_get_locale          connection_aborted           count_chars                 
collator_get_sort_key        connection_status            Countable     

But I expected this output instead:

$container

Completion of property name

The following shell code:

php > $object = (object) ['foo' => 'bar'];
php > $object->fo [⇥TAB]

Resulted in this output:

fopen                     forward_static_call       forward_static_call_array

But I expected this output instead:

foo

PHP version

PHP 8.4.3 (cli) (built: Jan 15 2025 01:03:17) (NTS)
Copyright (c) The PHP Group
Built by Homebrew
Zend Engine v4.4.3, Copyright (c) Zend Technologies
    with Xdebug v3.4.1, Copyright (c) 2002-2025, by Derick Rethans
    with Zend OPcache v8.4.3, Copyright (c), by Zend Technologies

PHP Version

PHP 8.4.3

Operating System

Mac 15.3 (24D60)

@nielsdos
Copy link
Member

nielsdos commented Feb 2, 2025

The autocomplete for a local variable does work for me. Can you try running without xdebug?
As for property names, this is known:

/*
TODO:
- constants
- maybe array keys
- language constructs and other things outside a hashtable (echo, try, function, class, ...)
- object/class members

I'm reclassifying as a feature request.

@nielsdos nielsdos changed the title Interactive shell doesn't complete variable and property names Interactive shell doesn't complete property names Feb 2, 2025
@cmb69 cmb69 removed the Bug label Feb 2, 2025
@GromNaN
Copy link
Member Author

GromNaN commented Feb 4, 2025

Thanks for checking. I tried by disabling Xdebug, Opcache and MongoDB extension, and I still have the same unexpected behavior.

I tried on Mac with docker docker run --rm -it php:8.4-cli php -a, the variable completion is working correctly. But the object properties and methods are not completed (this might be a different topic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants