bobthecow / psysh

A REPL for PHP

Home Page:https://psysh.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Deprecated functionality when deleting input

aligent-lturner opened this issue · comments

Using 0.11.3 via https://github.com/netz98/n98-magerun2, but I believe this is an issue with the latest version also.

If I enter some input at the command line, and then attempt to delete a character via backspace, I get the following error:

Exception with message 'Deprecated Functionality: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in phar:///app/bin/n98-magerun2.phar/vendor/psy/psysh/src/Readline/Hoa/ConsoleCursor.php on line 138'

This corresponds to

\str_replace(
'%p1%d',
$repeat,
$tput->get('parm_left_cursor')

I assume that this will just need to use ?? or similar to handle the null case

interesting. can you share the output of:

sudo Psy\Readline\Hoa\Console::getTput()->_informations

Here's the output on the server where the error is happening:

>>> sudo Psy\Readline\Hoa\Console::getTput()->_informations
=> [
     "file" => "/lib/terminfo/x/xterm-256color",
     "headers" => [
       "data_size" => 3535,
       "header_size" => 12,
       "magic_number" => 542,
       "names_size" => 37,
       "bool_count" => 38,
       "number_count" => 15,
       "string_count" => 413,
       "string_table_size" => 1518,
     ],
     "name" => "xterm-256color",
     "description" => "xterm with 256 colors",
     "booleans" => [
       "auto_left_margin" => false,
       "auto_right_margin" => true,
       "no_esc_ctlc" => false,
       "ceol_standout_glitch" => false,
       "eat_newline_glitch" => true,
       "erase_overstrike" => false,
       "generic_type" => false,
       "hard_copy" => false,
       "meta_key" => true,
       "status_line" => false,
       "insert_null_glitch" => false,
       "memory_above" => false,
       "memory_below" => false,
       "move_insert_mode" => true,
       "move_standout_mode" => true,
       "over_strike" => false,
       "status_line_esc_ok" => false,
       "dest_tabs_magic_smso" => false,
       "tilde_glitch" => false,
       "transparent_underline" => false,
       "xon_xoff" => false,
       "needs_xon_xoff" => false,
       "prtr_silent" => true,
       "hard_cursor" => false,
       "non_rev_rmcup" => false,
       "no_pad_char" => true,
       "non_dest_scroll_region" => false,
       "can_change" => true,
       "back_color_erase" => true,
       "hue_lightness_saturation" => false,
       "col_addr_glitch" => false,
       "cr_cancels_micro_mode" => false,
       "print_wheel" => false,
       "row_addr_glitch" => false,
       "semi_auto_right_margin" => false,
       "cpi_changes_res" => false,
       "lpi_changes_res" => false,
       "backspaces_with_bs" => true,
     ],
     "numbers" => [
       "columns" => 80,
       "init_tabs" => 0,
       "lines" => 8,
       "lines_of_memory" => 0,
       "magic_cookie_glitch" => 24,
       "padding_baud_rate" => 0,
       "virtual_terminal" => -1,
       "width_status_line" => -1,
       "num_labels" => -1,
       "label_height" => -1,
       "label_width" => -1,
       "max_attributes" => -1,
       "maximum_windows" => -1,
       "max_colors" => -1,
       "max_pairs" => -1,
     ],
     "strings" => [
       "cursor_down" => "t",
       "cursor_home" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_invisible" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_left" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_mem_address" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_normal" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_right" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_to_ll" => b"ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿè\x05ë\x05\e[Z",
       "cursor_up" => b"ÿè\x05ë\x05\e[Z",
       "cursor_visible" => "\e[Z",
       "delete_character" => "\e[%i%p1%d;%p2%dr",
       "delete_line" => "%p1%d;%p2%dr",
       "dis_status_line" => "d;%p2%dr",
       "enter_alt_charset_mode" => "3g",
       "enter_blink_mode" => "J",
       "enter_bold_mode" => "\e[%i%p1%dG",
       "enter_ca_mode" => "%p1%dG",
       "enter_delete_mode" => "\e[%i%p1%d;%p2%dH",
       "enter_insert_mode" => "%i%p1%d;%p2%dH",
       "enter_secure_mode" => "H",
       "enter_reverse_mode" => "\e[H",
       "enter_standout_mode" => "\e[?25l",
       "enter_underline_mode" => "[?12l\e[?25h",
       "erase_chars" => "l\e[?25h",
       "exit_ca_mode" => "25h",
       "exit_delete_mode" => "\e[C",
       "exit_insert_mode" => "[A",
       "exit_standout_mode" => "?12;25h",
       "flash_screen" => "0",
       "form_feed" => "m",
       "from_status_line" => "m",
       "init_2string" => "1049h\e[22;0;0t",
       "init_3string" => "\e[22;0;0t",
       "init_file" => "0;0t",
       "insert_character" => "\e[2m",
       "insert_line" => "",
       "insert_padding" => "m",
       "key_backspace" => "\e[7m",
       "key_clear" => "",
       "key_ctab" => "\e(B\e[m",
       "key_dc" => "",
       "key_dl" => "49l\e[23;0;0t",
       "key_eos" => "\e[27m",
       "key_f2" => "<100/>\e[?5l",
       "key_f4" => "/>\e[?5l",
       "key_f8" => "\e[?5l",
       "key_home" => "",
       "key_npage" => "p\e[?3;4l\e[4l\e>",
       "key_ppage" => "3;4l\e[4l\e>",
       "key_right" => "4l\e>",
       "key_sf" => "",
       "key_sr" => "",
       "key_stab" => "[3~",
       "key_up" => "B",
       "keypad_local" => "\e[21~",
       "keypad_xmit" => "\eOQ",
       "lab_f0" => "R",
       "lab_f1" => "\e[15~",
       "lab_f10" => "~",
       "lab_f3" => "7~",
       "lab_f5" => "[18~",
       "lab_f6" => "\e[19~",
       "lab_f7" => "",
       "lab_f8" => "0~",
       "lab_f9" => "\e[2~",
       "meta_on" => "D",
       "newline" => "6~",
       "pad_char" => "\eOC",
       "pkey_local" => "2B",
       "pkey_xmit" => "",
       "prtr_on" => "l\e>",
       "repeat_char" => "\e=",
       "reset_1string" => "4l",
       "reset_2string" => "4h",
       "reset_3string" => "dP",
       "reset_file" => "dM",
       "restore_cursor" => "dB",
       "row_address" => "d@",
       "save_cursor" => "dS",
       "scroll_forward" => "dL",
       "set_window" => "dD",
       "tab" => "[%p1%dC",
       "to_status_line" => "dC",
       "up_half_line" => "%p1%dT",
       "init_prog" => "%p1%dA",
       "key_b2" => "5i",
       "key_c1" => "\ec\e]104\x07",
       "key_c3" => "!p\e[?3;4l\e[4l\e>",
       "prtr_non" => "[?3;4l\e[4l\e>",
       "char_padding" => "3;4l\e[4l\e>",
       "acs_chars" => "l\e[4l\e>",
       "plab_norm" => "%t;7%;%?%p4%t;5%;%?%p7%t;8%;m",
       "enter_xon_mode" => "7%;%?%p4%t;5%;%?%p7%t;8%;m",
       "label_on" => ";%?%p4%t;5%;%?%p7%t;8%;m",
       "key_command" => "p4%t;5%;%?%p7%t;8%;m",
       "key_create" => "pqqrrssttuuvvwwxxyyzz{{||}}~~",
       "key_exit" => "rssttuuvvwwxxyyzz{{||}}~~",
       "key_find" => "uvvwwxxyyzz{{||}}~~",
       "key_refresh" => "xyyzz{{||}}~~",
       "key_replace" => "z{{||}}~~",
       "key_sprevious" => "|}}~~",
       "key_sreplace" => "[Z",
       "key_sundo" => "h",
       "req_for_input" => "",
       "key_f11" => "M",
       "key_f14" => "~",
       "key_f16" => "F",
       "key_f20" => "H",
       "key_f26" => "~",
       "key_f27" => "2D",
       "key_f28" => ";2~",
       "key_f29" => ";2~",
       "key_f30" => ";2C",
       "key_f31" => "3~",
       "key_f32" => "~",
       "key_f33" => "",
       "key_f34" => "\e[1;2R",
       "key_f35" => "[1;2S",
       "key_f36" => "15;2~",
       "key_f37" => "17;2~",
       "key_f38" => "18;2~",
       "key_f39" => "19;2~",
       "key_f40" => "20;2~",
       "key_f41" => "[21;2~",
       "key_f42" => "\e[23;2~",
       "key_f43" => "",
       "key_f44" => "~",
       "key_f45" => "",
       "key_f46" => "\e[1;5R",
       "key_f47" => "[1;5S",
       "key_f48" => "15;5~",
       "key_f49" => "17;5~",
       "key_f50" => "18;5~",
       "key_f51" => "19;5~",
       "key_f52" => "20;5~",
       "key_f53" => "[21;5~",
       "key_f54" => "\e[23;5~",
       "key_f55" => "",
       "key_f56" => "~",
       "key_f57" => "",
       "key_f58" => "\e[1;6R",
       "key_f59" => "[1;6S",
       "key_f60" => "15;6~",
       "key_f61" => "17;6~",
       "key_f62" => "18;6~",
       "key_f63" => "19;6~",
       "clr_bol" => "20;6~",
       "clear_margins" => "[21;6~",
       "set_left_margin" => "\e[23;6~",
       "set_right_margin" => "",
       "label_format" => "~",
       "set_clock" => "",
       "display_clock" => "\e[1;3R",
       "remove_clock" => "[1;3S",
       "create_window" => "15;3~",
       "goto_window" => "17;3~",
       "hangup" => "18;3~",
       "dial_phone" => "19;3~",
       "quick_dial" => "20;3~",
       "tone" => "[21;3~",
       "pulse" => "\e[23;3~",
       "flash_hook" => "",
       "define_char" => ";3~",
       "enter_doublewide_mode" => "\e[1;4Q",
       "enter_draft_quality" => "Q",
       "enter_italics_mode" => "d;%dR",
       "enter_leftward_mode" => "R",
       "enter_micro_mode" => "?%[;0123456789]c",
       "enter_near_letter_quality" => "3456789]c",
       "exit_superscript_mode" => "X/%p4%{255}%*%{1000}%/%2.2X\e\",
       "parm_left_micro" => "%{255}%*%{1000}%/%2.2X\e\",
       "bit_image_repeat" => "%*%{1000}%/%2.2X\e\",
       "define_bit_image_region" => "1000}%/%2.2X\e\",
       "end_bit_image_region" => "%t9%p1%{8}%-%d%e38;5;%p1%d%;m",
     ],
   ]

>>>

Interestingly, I don't have the same problem in my local (docker) environment - and I can see parm_left_cursor populated there.

What's weird is you have the micro-version of it: parm_left_micro but not parm_left_cursor. Of course, you don't have any of the rest of them, so something's obviously not right with your terminfo.

Alright, try @dev one more time. It's not great, but it's the best I can figure out to do 😕