Giter Site home page Giter Site logo

phpactor.el's Introduction

phpactor.el - PHP refactoring and introspection

This package is Emacs interface to Phpactor.

NOTICE: This package is in development. Since some functions are running, this is released as an alpha version.

NOTICE: Phpactor is also in development stage.

Build Status MELPA: phpactor MELPA stable: phpactor

Consider moving to LSP

Phpactor is a language server that supports the LSP Protocol and its own RPC protocol. This package only implements Phpactor’s own RPC protocol.

They won’t be removed immediately, but the LSP provides a comprehensive better user experience. This package will continue to be maintained and we will follow any changes to the RPC protocol.

Please read LSP Support · emacs-php/php-mode Wiki for LSP clients in PHP.

Installation

Requirement: You need to have composer globally installed.

First step

Installation with use-package :

(use-package phpactor :ensure t)
(use-package company-phpactor :ensure t)

Installation with straight.el

(here using straight.el with use-package)

(use-package phpactor
  :straight (phpactor
             :host github
             :type git
             :repo "emacs-php/phpactor.el"
             :branch "master"
             :files ("*.el" "composer.json" "composer.lock" (:exclude "*test.el"))
             )
  )

Second step

After having installed this package, run `phpactor-install-or-update` (this will install a supported version of phpactor inside `.emacs.d/phpactor`).

NOTICE: To ensure the supported version of Phpactor is installed, you might need to run this command again after an upgrade of this package.

Alternatively, you can install Phpactor on your own and customize `phpactor-executable` but please be aware that any change in Phpactor’s rpc protocol can introduce breakages.

Configuration

completion

(use-package php-mode
  ;;
  :hook ((php-mode . (lambda () (set (make-local-variable 'company-backends)
       '(;; list of backends
         company-phpactor
         company-files
         ))))))

eldoc integration

(add-hook 'php-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function
                  'phpactor-hover)))

Jump (go to definition)

(with-eval-after-load 'php-mode
  (phpactor-smart-jump-register))

without Smart-jump

(with-eval-after-load 'php-mode
  (define-key php-mode-map (kbd "M-.") #'phpactor-goto-definition)
  (define-key php-mode-map (kbd "M-?") #'phpactor-find-references))

phpactor itself

See https://phpactor.github.io/phpactor/configuration.html

keybindings

Phpactor.el doesn’t bring any keybindings and it’s up to you to configure them as you wish.

You could for example limit yourself to only one by using transient.el like this

(define-transient-command php-transient-menu ()
  "Php"
  [["Class"
    ("cc" "Copy" phpactor-copy-class)
    ("cn" "New" phpactor-create-new-class)
    ("cr" "Move" phpactor-move-class)
    ("ci" "Inflect" phpactor-inflect-class)
    ("n"  "Namespace" phpactor-fix-namespace)]
   ["Properties"
    ("a"  "Accessor" phpactor-generate-accessors)
    ("pc" "Constructor" phpactor-complete-constructor)
    ("pm" "Add missing props" phpactor-complete-properties)
    ("r" "Rename var locally" phpactor-rename-variable-local)
    ("R" "Rename var in file" phpactor-rename-variable-file)]
  ["Extract"
    ("ec" "constant" phpactor-extract-constant)
    ("ee" "expression" phpactor-extract-expression)
    ("em"  "method" phpactor-extract-method)]
  ["Methods"
    ("i" "Implement Contracts" phpactor-implement-contracts)
    ("m"  "Generate method" phpactor-generate-method)]
  ["Navigate"
    ("x" "List refs" phpactor-list-references)
    ("X" "Replace refs" phpactor-replace-references)
    ("."  "Goto def" phpactor-goto-definition)]
  ["Phpactor"
    ("s" "Status" phpactor-status)
    ("u" "Install" phpactor-install-or-update)]])

Troubleshooting

You can run “phpactor-status“ while visiting a project file.

If needed, configure the way the project root is detected via .dir-locals.el

Phpactor Output” buffer might also contain useful informations.

About Phpactor

We will assume your emacs configuration is stored under “~/.emacs.d/”

Where is phpactor installed

After running `phpactor-install-or-update`, phpactor should be installed under “~/.emacs.d/phpactor/”. And the phpactor executable should be “~/.emacs.d/phpactor/vendor/bin/phpactor”

Contribute to phpactor

Phpactor’s packages are cloned (using git) under “~/.emacs.d/phpactor/vendor/phpactor”. If you make a modification to phpactor you’d like to contribute, you can just of git straight away to open a pull request therefrom.

phpactor.el's People

Contributors

alypeng avatar br3athein avatar conao3 avatar fuco1 avatar jcs090218 avatar kermorgant avatar marienz avatar markredeman avatar martango avatar nanasess avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpactor.el's Issues

cache of completion results

For every character typed, company-phpactor starts a rpc call to phpactor.

company has a builtin caching mechanism but it does not seem to be used (see company-calculate-candidates)

I don't know how this caching is intented to work, but I think invoking phpactor successively with the same initial prefix + additional chars should benefit from caching.

Implement RPC features

https://phpactor.github.io/phpactor/rpc.html

Editor Actions

  • return
  • return_choice
  • echo #3
  • error
  • collection #39
  • open_file #3
  • close_file #39
  • file_references
  • input_callback 51f82e8
  • information #3
  • replace_file_source

Phpactor Commands

  • complete
  • class_search
  • goto_definition 22e285e
  • copy_class #10
  • move_class #10
  • offset_info
  • transform
  • class_new
  • class_inflect
  • references
  • extract_constant
  • generate_method
  • generate_accessor e16cec9
  • context_menu #24
  • navigate
  • status b6f68f7
  • import_class #34 by @kermorgant

ensure complete output of phpactor-status is readable

Currently, the output of 'phpactor-status' is shown in the minibuffer.

The max height of the minibuffer is governed by the value of "max-mini-window-height". By default, it is a float and thus specifies a fraction of frame height.

Due to this, the top of the output is sometimes truncated.

Could not decode JSON

I get an error when calling the phpactor-goto-definition function:
json-read-string: Bad string format: "doesn't start with "'!"
Phpactor Output:

In RpcCommand.php line 58:
                          
  Could not decode JSON:  
                          

rpc [--replay] [--pretty]

improve goto-definition with interfaces

When working with interfaces, you might be tempted to use goto-definition to look into an implementation of the interface.

Would be great to show a list consisting of the interface and its implementions, maybe using completing-read

This will require some work upstream : phpactor/phpactor#698

fix completion for variables

phpactor's company backend works for methods and classes, but not for variables.

I've had a look at it and it is related to an incompatibility between company-grab-symbol which strips the $ before the variable name and phpactor's suggestions which contains the $ symbol.

I've asked for help here

rename not working

rename doesn't seem to work properly - it doesn't recognise accessors/getters or the member data within them. eg here I rename member variable $logger to $_logger both locally and "in file" - neither correctly updates the logger() method.

Screenshot from 2020-01-10 07-47-04

Here I tried renaming from the declaration. Trying to rename from an "$this->logger" results in:-

user-error: Expected Variable or Parameter node, got
"Microsoft\PhpParser\Node\Expression\MemberAccessExpression"

Possibly the worst problem though is renaming a member variable that has parameters named after it. eg here I rename member var "cache" to "cache2" and it renames method parameters in that class and not the actual member variable usages.

Screenshot from 2020-01-10 07-53-29

fearture request : improve completion with meta and auto-import

There's some work going on on phpactor's vim plugin to enable auto import of completed classes.

Looking at the example, it would be nice to have

  • fully qualified name of the class shown beside every class candidate . Thats is already brought by phpactor in the info key for each class candidate
  • auto-import of the class name in the top of the file

I'll try to find some time to work on it, not sure when though.

Looking at company-mode's code, it seems we could use

Currently, the main issue is that the company-phpactor backend receives a list of candidates like this

{
  "action": "return",
  "parameters": {
    "value": {
      "suggestions": [
        {
          "type": "t",
          "name": "QueryCache",
          "info": "Doctrine\\ORM\\Cache\\QueryCache"
        },
        {
          "type": "t",
          "name": "QueryCacheEntry",
          "info": "Doctrine\\ORM\\Cache\\QueryCacheEntry"
        },
      ],
      "issues": []
    }
  }
}

and builds a list using only the name key. Thus, when calling the annotation or post-completion function, the argument passed to them is the value associated to name. As there could be several; candidates having the same key, that's a problem.

missing autoloader comment ?

Hello,

I've given a try at this package, and first results were good (using spacemacs, invoking phpactor-goto-definition interactively).

After that, I've been trying to setup a private spacemacs layer and got lost while trying to get spacemacs/jump-to-definition invoke phpactor-goto-definition.

I've propably messed up a few things but for reasons I could not explain, phpactor-goto-definition would sometimes not show up among other functions, while phpactor-status or phpactor-echo would.

And I noticed phpactor-goto-definition does not have an #autoloader comment. Is this on purpose ?

issue with phpactor-copy-class

phpactor-copy-class used to work well but I just stumbled upon a project where it failed.

{
  "action": "error",
  "parameters": {
    "message": "Could not copy file \"/path/to/project/api/src/Validator/User/Constraints/UniqueEmail.php\" to \"/path/to/project/api/src/Validator/ProductAttribute/Constraints/ValidProductAttribute.php\"",
    "details": "0: Trying to create descendant from absolute path \"/path/to/project/api/src/Validator/User/Constraints/UniqueEmail.php\" that does not lie within context path \"/path-to-other-project\"\n#0 /home/mikael/src/phpactor/vendor/phpactor/source-code-filesystem/lib/Adapter/Git/GitFilesystem.php(79)...

The relevant part is imho does not lie within context path \"/path-to-other-project which for some reason has been used here.

Facts to consider

  • I have several projects opened (using projectile + persp)
  • the .git folder is not at the root of the php project but in the parent folder

I will try to debug that a bit more later

Invalid version of PHP

I get invalid version error when I trying to install
M-x phpactor-install-or-update

Debugger entered--Lisp error: (error "Invalid version syntax: ‘8.1.2-1ubuntu2.14’")
  error("Invalid version syntax: `%s'" "8.1.2-1ubuntu2.14")
  version-to-list("8.1.2-1ubuntu2.14")
  version<("8.1.2-1ubuntu2.14" "7.4.0")
  phpactor-install-or-update()
  funcall-interactively(phpactor-install-or-update)
  command-execute(phpactor-install-or-update record)
  execute-extended-command(nil "phpactor-install-or-update" nil)
  funcall-interactively(execute-extended-command nil "phpactor-install-or-update" nil)
  command-execute(execute-extended-command)

PHP version
php -v

PHP 8.1.2-1ubuntu2.14 (cli) (built: Aug 18 2023 11:41:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.14, Copyright (c), by Zend Technologies
~/.config/emacs/.local/straight/repos/phpactor.el >                                                                                                                                                                  10/10/2023 05:41:14 PM

OS Version
sb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

How to install?

Hi, am trying to get this running in Spacemacs, but as I only used Emacs for about 3 hours, I am struggling :)

Can you suggest the minimum I need to do to get phpactor.el running in vanilla Spacemacs? (or maybe suggest a similar project with a docmented installation guide?)

Thanks!

Refactor Definition of RPC Commands

See the code in the refactor-rpc-functions branch for all of the details. The code is not finished. But while looking at the project it struck me as a potentially useful refactoring. Please do not merge it because it needs more testing, and discussion, as not everyone may agree it's a worthwhile change.

Semantic Versioning

I am a big fan and supporter of Semantic Versioning. I have been thinking it could be useful on various @emacs-php projects, to help give both users and devs important information at a glance about neeeew, big releases, when updates are minor and unlikely to affect their installation and ettings, and so on. I felt like phpactor.el could be a good "test-bed" for using Semantic Versioning and evaluating whether or not it would be valuable to use in future proeects.

Thoughts?

*Phpactor* buffer keeps popping up

Hello,

As put in the title, the Phpactor buffer keeps popping up when I use this package, although I've disabled debug. I usually work with a 2 buffers side by side, and Phpactor pops up in the inactive one. A bit annoying as I have to get into that buffer and close Phpactor buffer quite often.

I'm not using the package from melpa but instead use load the files from the source code cloned locally, so maybe my issue could stem from that ?

Any advice about how to disable that behaviour ?

company-phpactor undesired behaviour

  • Autocompletion will display all candidates, even if the text doesn't match up with what you've typed
  • If working in a file with code after the cursor, won't display any methods which have been defined after the cursor. (easy fix)

goto definition error when looked up method does not exist

I invoked phpactor-goto-definition on setDeadLine method, on a codeline like this

                $project->setDeadLine(new \DateTime('+ 2 months'));

There is a typo error, the "setDeadline" method does not have an uppercase L, so I got this error

apply: Symbol’s function definition is void: phpactor-action-error

I guess this is already on the todolist, I hope you don't mind me reporting minor issues like this.

phpactor-action-open-file fails after replace reference

When the replace reference refactoring is invoked, afftected files are opened with the phpactor-action-open-file function and offset argument equals 0.

(byte-to-position offset) returns nil in that case, and the whole operation halts on the subsequent error.

Bump version 0.1.0

Since some problems have been fixed since 0.0.2, we will release it as 0.0.3 or 0.1.0.


Changelog

Keep a Changelog principle

Add

  • Implement actions
    • RPC action import_class #34
    • RPC action close-file #39
    • Editor action collection #39

Changed

  • Replace company-grab-symbol by specific company-phpactor--grab-symbol #29
  • Automatically add appropriate use statement after class completion #34

Fixed

  • Alter php-mode's syntax table on the fly to use correct completion prefix #29
  • Fix completion and goto definition when file contains multi-byte chars #40 #46
  • Fix move_class RPC action #36 #39

Create class not working

I have some problems with the phpactor-create-new-class seems the json serialization is not working correclty (it may be related to this issue.
I'm using Emacs 27.1 compiled from the official tarball from the Emacs page.
This is part of the command output

Debugger entered--Lisp error: (wrong-type-argument json-value-p :null) json-serialize((:action "class_new" :parameters (:new_path :null :variant :null :overwrite_existing :null :current_path "/usr/Data_2/Programming/drupal-9.0.6/core/modules/aggregator/src/Entity/Feed.php")) :null-object nil :false-object :json-false)

(let ((json (phpactor--serialize-json (list :action action :parameters arguments))) (output (get-buffer-create "*Phpactor Output*")) (coding-system-for-write 'utf-8) (cwd (phpactor-get-working-dir))) (save-current-buffer (set-buffer output) (erase-buffer)) (save-current-buffer (set-buffer (get-buffer-create "*Phpactor Input*")) (setq default-directory cwd) (erase-buffer) (insert json) (call-process-region (point-min) (point-max) phpactor-executable nil output nil "rpc" (format "--working-dir=%s" default-directory)) (phpactor--parse-json output))) phpactor--rpc("class_new" (:new_path :null :variant :null :overwrite_existing :null :current_path "/usr/Data_2/Programming/drupal-9.0.6/core/modules/aggregator/src/Entity/Feed.php")) (apply #'phpactor-action-dispatch (phpactor--rpc (plist-get callback :action) parameters))

Thank you

feature request : completion outside of php files

It's not uncommon (for example in a Symfony project) to specify class names (FQN) in a xml or yaml file.

In those case, having a specific completion backend would be nice but I wonder how feasible this is.

  • first, phpactor doen't yet provide a completion rpc call that would work in such case
  • but if that was solved, I'm not really about how things should be :
    ** should it be a specific company-phpactor-fqn completion backend that could be added to other modes ?
    ** does the context of buffer matter ? ie should we activate such a completion backend only in a php project and if yes, by which means ?
    ** should the completion only focus on typing the FQN (that's the use case I have in mind, for symfony files like services.yaml)

FR: work better with flycheck after refactorings

I'm using flycheck-phpstan and have sometimes a bit annoying behaviour :

Currently, if the buffer is modified by phpactor.el (like after using extract_constant), flycheck will suggest an error until I save the file.

It would be nice to provide a solution so that flycheck dynamically updates its linting after a refactoring has happened (a hook ?)

creating getters doesn't work - or documentation needed

When I have my cursor on a member variable and select "properties/accesor(a)" from the transient command or using php-generate-accessors I get:

phpactor--action-input-parameters: Keyword argument :multi not one of (:default :label :choices :type)
helm-M-x-execute-command: Keyword argument :multi not one of (:default :label :choices :type)

Screenshot from 2020-01-08 21-34-03

incorrect working directory when php code in subfolder

I'm working on a project based on api-platform which has the following folder structure

/.git
/api => symfony code
/client => client javascript code

php-project-get-root-dir seems to use git as the dominant root folder detection factor, which is not appropriate within this project (should be api)

Feature request : no completion caching when limit reached

phpactor enforces a limit (configurable) on the number of returned completion candidates.

Sometimes (rarely in my experience), the desired candidate was not among the first candidates due to that limit, and due to company's caching, it can take more keystrokes than expected to have it suggested (= bad user experience).

Thus, I think it would be useful to selectively disable company's caching, based on the number of returned results (phpactor fixes that limit at 100 by default).

installation from melpa and phpactor-update broken?

Installation done with use-package like that

(use-package phpactor )
(use-package company-phpactor )

then after a run of phpactor-update, got this error


In DocblockFactory.php line 50:
                                                                               
  Warning: "continue" targeting switch is equivalent to "break". Did you mean  
   to use "continue 2"?                                                        

Tried with an updated phpactor (develop branch), ended up with this

_ % ./vendor/bin/phpactor     
PHP Warning:  require(/home/mikael/.emacs.d/elpa/phpactor-20181028.556/vendor/composer/../../tests/src/functions.php): failed to open stream: No such file or directory in /home/mikael/.emacs.d/elpa/phpactor-20181028.556/vendor/composer/autoload_real.php on line 57
PHP Fatal error:  require(): Failed opening required '/home/mikael/.emacs.d/elpa/phpactor-20181028.556/vendor/composer/../../tests/src/functions.php' (include_path='.:') in /home/mikael/.emacs.d/elpa/phpactor-20181028.556/vendor/composer/autoload_real.php on line 57

update rpc call as replace_file_source has been deprecated

see phpactor/phpactor#530

Quoting phpactor's author

Now supports generating a diff and applying the text edits
Quite a big change and introduces a new RPC call and deprecates replace_file_source
Also the Emacs integration will have to support update_file_source - but it can simply delegate to the legacy "replace_file_source" for now, as the new call also contains the old response

support version sent from phpactor

see pr 598 : phpactor now sends a version key .

this version should be compared against a constant defining the oldest supported version by this package, and trigger an error if if phpactor is too old

show php function documentation upon completion

during completion, we rely on phpactor's output to show extra information (such as FQN) for each completion candidate, using company's annotation function.

company provides other ways to give contextual help for each candidate. Here's an extract from its source

meta: The second argument is a completion candidate. Return a (short)
documentation string for it.

doc-buffer: The second argument is a completion candidate. Return a
buffer with documentation for it. Preferably use `company-doc-buffer'. If
not all buffer contents pertain to this candidate, return a cons of buffer
and window start position.

It would be nice to use php's documentation when completion candidates are php functions (maybe using php-mode's php-search-local-documentation function ?)

Eldoc integration is broken

Enabling eldoc support as described in the readme results in constant errors:

eldoc error: (json-string-format doesn't start with `"'!)

Unable to `phpactor-copy-class` "Trying to create descendant from absolute path.."

Could not copy file "/Users/martintang/test/test-php-project/src/MyClass.php" to "/Users/martintang/test/test-php-project/src/MyOtherClass.php"

0: Trying to create descendant from absolute path "/Users/martintang/test/test-php-project/src/MyClass.php" that does not lie within context path "/Users/martintang/test/test-php-project/"
#0 /Users/martintang/tools/phpactor/vendor/phpactor/source-code-filesystem/lib/Adapter/Git/GitFilesystem.php(70): Phpactor\Filesystem\Domain\FilePath->makeAbsoluteFromString(Object(Phpactor\Filesystem\Domain\FilePath))
#1 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Application/ClassCopy.php(94): Phpactor\Filesystem\Adapter\Git\GitFilesystem->createPath('/Users/martinta...')
#2 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Application/ClassCopy.php(83): Phpactor\Extension\ClassMover\Application\ClassCopy->doCopyFile(Object(Phpactor\Extension\ClassMover\Application\Logger\NullLogger), '/Users/martinta...', '/Users/martinta...')
#3 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Application/ClassCopy.php(51): Phpactor\Extension\ClassMover\Application\ClassCopy->copyFile(Object(Phpactor\Extension\ClassMover\Application\Logger\NullLogger), '/Users/martinta...', '/Users/martinta...')
#4 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Rpc/ClassCopyHandler.php(53): Phpactor\Extension\ClassMover\Application\ClassCopy->copy(Object(Phpactor\Extension\ClassMover\Application\Logger\NullLogger), '/Users/martinta...', '/Users/martinta...')
#5 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/RequestHandler.php(39): Phpactor\Extension\ClassMover\Rpc\ClassCopyHandler->handle(Array)
#6 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/ExceptionCatchingHandler.php(25): Phpactor\Extension\Rpc\RequestHandler\RequestHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#7 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/LoggingHandler.php(39): Phpactor\Extension\Rpc\RequestHandler\ExceptionCatchingHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#8 /Users/martintang/tools/phpactor/lib/Extension/Rpc/Command/RpcCommand.php(74): Phpactor\Extension\Rpc\RequestHandler\LoggingHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#9 /Users/martintang/tools/phpactor/lib/Extension/Rpc/Command/RpcCommand.php(62): Phpactor\Extension\Rpc\Command\RpcCommand->processRequest(Object(Phpactor\Extension\Rpc\Request))
#10 /Users/martintang/tools/phpactor/vendor/symfony/console/Command/Command.php(264): Phpactor\Extension\Rpc\Command\RpcCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(Phpactor\Extension\Rpc\Command\RpcCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /Users/martintang/tools/phpactor/lib/Application.php(42): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(130): Phpactor\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /Users/martintang/tools/phpactor/bin/phpactor(43): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 {main}

1: Could not copy file "/Users/martintang/test/test-php-project/src/MyClass.php" to "/Users/martintang/test/test-php-project/src/MyOtherClass.php"
#0 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Application/ClassCopy.php(51): Phpactor\Extension\ClassMover\Application\ClassCopy->copyFile(Object(Phpactor\Extension\ClassMover\Application\Logger\NullLogger), '/Users/martinta...', '/Users/martinta...')
#1 /Users/martintang/tools/phpactor/lib/Extension/ClassMover/Rpc/ClassCopyHandler.php(53): Phpactor\Extension\ClassMover\Application\ClassCopy->copy(Object(Phpactor\Extension\ClassMover\Application\Logger\NullLogger), '/Users/martinta...', '/Users/martinta...')
#2 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/RequestHandler.php(39): Phpactor\Extension\ClassMover\Rpc\ClassCopyHandler->handle(Array)
#3 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/ExceptionCatchingHandler.php(25): Phpactor\Extension\Rpc\RequestHandler\RequestHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#4 /Users/martintang/tools/phpactor/lib/Extension/Rpc/RequestHandler/LoggingHandler.php(39): Phpactor\Extension\Rpc\RequestHandler\ExceptionCatchingHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#5 /Users/martintang/tools/phpactor/lib/Extension/Rpc/Command/RpcCommand.php(74): Phpactor\Extension\Rpc\RequestHandler\LoggingHandler->handle(Object(Phpactor\Extension\Rpc\Request))
#6 /Users/martintang/tools/phpactor/lib/Extension/Rpc/Command/RpcCommand.php(62): Phpactor\Extension\Rpc\Command\RpcCommand->processRequest(Object(Phpactor\Extension\Rpc\Request))
#7 /Users/martintang/tools/phpactor/vendor/symfony/console/Command/Command.php(264): Phpactor\Extension\Rpc\Command\RpcCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(228): Symfony\Component\Console\Application->doRunCommand(Object(Phpactor\Extension\Rpc\Command\RpcCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /Users/martintang/tools/phpactor/lib/Application.php(42): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /Users/martintang/tools/phpactor/vendor/symfony/console/Application.php(130): Phpactor\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /Users/martintang/tools/phpactor/bin/phpactor(43): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main}

improve find-references

currently, phpactor-find-references opens a separate buffer, listing all references

  • integrate with ivy (inspiration could be taken herefrom
  • make buffer with references easily closable (like pressing q)
  • make buffer listing references immune to replacement when clicking on one of its elements (clicking on a link should open the related buffer in another window)

complete methods with parentheses

When completion suggests methods, parentheses could be added automatically. In other cases, change nothing.

If that doesn't sound wrong, I'll try to add that to the current completion function.

phpactor - how to auto insert namespaces?

I have created a new constructor parameter using company-phpactor completion and unlike the company-lsp completion it doesnt add the namespace. I had thought that phpactor-fix-namespace would fix this or prompt to fix things up but it doesn't. Can someone advise please.

add a command to install phpactor

Currently, it's up to the user to install phpactor.

As every change in the rpc protocol can possibly break phpactor.el, it might be helpful to provide a command to run composer install targeting a supported version of phpactor

preparation of beta release ?

Having used this package for a while, I find it globally quite usable, and believe phpactor is a really good solution for completion. Thus, I'd like to focus on making it easier to try, and also maybe move towards a beta quality release.

Do you see any things that should be addressed for that goal ?

From the top of my head, I can mention

  • close issue #59 about installation
  • [ ] code cleanup (like prefix uniformization towards phpactor-- ?)
  • readme improvements ?
  • provide company-phpactor through package (to be confirmed)
  • start using a develop branch for new features

Maybe for later

  • tests, but that's a chapter I can't see opening really soon

Any suggestion welcome

Is the alpha release usable/testable?

I am an Emacs beginner, I try to use phpactor.el to improve my PHP experience.
I installed phpactor by following the standalone way and it seems to be working. When I use it in my directory it works.
I've installed phpactor.el by using package-install in Emacs.
When I use Emacs to type code, automatically in the mini buffer I see an error.

Here is a code to reproduce it. My point is after the arrow (where I put a pipe) when I the an error.

<?php
class Stuff
{
    public function test()
    {
    }
}

$s = new Stuff();
$s->|

The error I get:

Phpactor: Unknown item "", known items: "", "", ""

Testing the Phpactor installation:

$ phpactor status
Version: 7db7a5c (il y a 4 semaines) updated-composer-749
Filesystems: git, simple, composer
Working directory: /var/www/html/work/libs/myrepo

Config files (missing is not bad):

  ✘ /home/john/.config/phpactor/phpactor.json
  ✘ /home/john/.config/phpactor/phpactor.yml
  ✘ /var/www/html/work/libs/myrepo/.phpactor.json
  ✘ /var/www/html/work/libs/myrepo/.phpactor.yml

Diagnostics:

  ✔ Composer detected - faster class location and more features!
  ✔ Git detected - enables faster refactorings in your repository scope!
  ✔ XDebug is disabled. XDebug has a negative effect on performance.

My .emacs about phpactor.el.

(add-hook 'php-mode-hook
          (lambda ()
            (make-local-variable 'eldoc-documentation-function)
            (setq eldoc-documentation-function
                  'phpactor-hover)))

Since phpactor is under development and phpactor.el is in alpha version, is it usable/testable? Is the error from me/my install, or the plugin isn't usable?
As a side note I'll add that I'm already using phpactor in Vim (in Vim it's not using the standalone install I think though).

phpactor-move-class does not work

Invoking function phpactor-move-class ends with the following error

cond: Unknown input type confirm

which stems from

(cl-defun phpactor--action-input-parameters (value-type &key default label choices type)
...
    (cl-case type
      (file (read-file-name label nil default))
      (text (read-string label default))
...
      (t (error "Unknown input type %s" type)))))

I still haven't looked into the details of why value-type has the value "confirm" but I tried to add a condition like this

    (cl-case type
      (confirm (read-string label  default))
      (file (read-file-name label nil default))

with that, I get a confirmation question to which I answered yes. After that, I got this error message

apply: Symbol’s function definition is void: phpactor-action-collection

The *Phpactor input* buffer contains

{
  "action": "collection",
  "parameters": {
    "actions": [
      {
        "name": "close_file",
        "parameters": {
          "path": "/.../AppBundle/Security/Voter/RandomClass1.php"
        }
      },
      {
        "name": "open_file",
        "parameters": {
          "path": "/.../AppBundle/Security/Voter/RandomClass2.php",
          "offset": 0
        }
      }
    ]
  }
}

I'm not sure if my first modification is appropriate, it just happened to make the code run some steps further.

But for sure, we need a phpactor-action-collection function to perform a collection of actions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.