php / php/php-src

Interactive shell doesn't complete property names

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

まだ誰も着手していません。

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

説明

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)

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

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

はじめの一歩

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

調査の方向性

まず php -a を実行し、issue にある変数とプロパティの補完例を再現します。インタラクティブシェルの補完エントリポイントを追跡し、現在の候補がどのように選択されているかを特定します。$co$container のみに補完され、$object-\u003efofoo に補完され、文書化されている補完動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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