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

Support psysh 'requireSemicolons' in php:cli #5160

Closed
andriokha opened this issue Jun 15, 2022 · 4 comments
Closed

Support psysh 'requireSemicolons' in php:cli #5160

andriokha opened this issue Jun 15, 2022 · 4 comments

Comments

@andriokha
Copy link

Is your feature request related to a problem? Please describe.
By default psysh does a kind of JS-like automatic semicolon insertion for convenience, automatically adding one after each line break. And a lot of time it's convenient. But I'm always frustrated when I have a bit of multiline code that I want to test in the REPL, and instead of just copying and pasting, I have to reformat it onto one line.

Describe the solution you'd like
Psysh has an option that requires semicolons: requireSemicolons. I've tested it locally and it works as advertised. I suggest supporting that. I'm not sure if it makes more sense to have a dedicated option, or a general mechanism to pass psysh config options through (insert obligatory xkcd reference!).

Thanks for this life-saving tool ❤️

@andriokha
Copy link
Author

Thought a possible alternative might be to change it dynamically from within the REPL itself, but it looks like that's not possible at the mo: bobthecow/psysh#361

@andriokha
Copy link
Author

Ah, I can use a psysh config file without any change to drush. In combination with the PSYSH_CONFIG env var I can use something like

PSYSH_CONFIG=config-multiline.php drush php

I'll leave the request open because it's not super convenient, see what others think (:

Thanks!

@andriokha
Copy link
Author

K, I'm going to close this. If you'd like to be able to copy and paste a single logical line that's spread over multiple actual lines in drush core:cli you can use the following.

  1. Put this in some PHP file:
    <?php
    return [
      'requireSemicolons' => TRUE,
    ];
  2. Run the following:
    PSYSH_CONFIG=path/to/file/from/docroot/file.php drush php
  3. You should be able to paste eg. the following and it will work (note the required semicolon):
    \Drupal::entityTypeManager()
      ->getStorage('node')
      ->getQuery()
      ->count()
      ->accessCheck(FALSE)
      ->execute();

Thanks!

@bobthecow
Copy link

You should also be able to add a .psysh.php file with that config to your project directory and it'll do this by default!

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

No branches or pull requests

2 participants