Giter Site home page Giter Site logo

php-refactoring's Introduction

This package is not maintained anymore, sorry

PHP Refactoring for Atom

PHP Refactoring Browser implementation for atom.

Screenshot

Installation

Requirements

  • PHP
  • patch command on your system
  • refactor.phar download here

Just search php refactoring in Settings > Install. If you are Windows user you have to install Git Bash first because this plugins require patch command in your system to change code.

Settings

If you can't see package settings open Extract Method panel and close it. Then go to Settings and you will see settings. (It's Atom bug)

If you are Windows user you will have to specify patch command path. When you are using Git Bash it's located at: C:/Users/<Your User Name>/AppData/Local/Programs/Git/usr/bin/patch.exe

Usage

You can use default key bindings or select code range / variable and right click on it. Also you can use navigation in Packages > PHP Refactoring.

To rename or convert variable you have to have selected variable, not just cursor on it.

Default key bindings

  • ctrl-alt-r e Extract method
  • ctrl-alt-r r Rename variable
  • ctrl-alt-r c Convert local variable to instance variable
  • ctrl-alt-r o Optimize use statements

Commands

  • php-refactoring:extract
  • php-refactoring:rename-variable
  • php-refactoring:convert-variable
  • php-refactoring:optimize

php-refactoring's People

Contributors

fbohorquez avatar mihaliak avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

ikstar fbohorquez

php-refactoring's Issues

Uncaught Error: Can't save buffer with no file path

[Enter steps to reproduce below:]

  1. click optimize use statements in a empty Project

Atom Version: 1.7.3
System: HARRY
Thrown From: php-refactoring package, v1.4.0

Stack Trace

Uncaught Error: Can't save buffer with no file path

At C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1089

Error: Can't save buffer with no file path
    at TextBuffer.module.exports.TextBuffer.saveAs (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1089:15)
    at TextBuffer.module.exports.TextBuffer.save (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\node_modules\text-buffer\lib\text-buffer.js:1083:19)
    at TextEditor.module.exports.TextEditor.save (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\text-editor.js:660:26)
    at Object.module.exports.PhpRefactoring.runCommand (file:///C:/Users/marc/.atom/packages/php-refactoring/lib/php-refactoring.coffee:101:17)
    at Object.module.exports.PhpRefactoring.optimize (file:///C:/Users/marc/.atom/packages/php-refactoring/lib/php-refactoring.coffee:98:10)
    at atom-text-editor.subscriptions.add.atom.commands.add.php-refactoring:optimize (file:///C:/Users/marc/.atom/packages/php-refactoring/lib/php-refactoring.coffee:53:45)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:260:29)
    at CommandRegistry.handleCommandEvent (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:3:61)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\command-registry.js:160:19)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\atom-environment.js:1100:28)
    at EventEmitter.outerCallback (C:\Users\marc\AppData\Local\atom\app-1.7.3\resources\app.asar\src\application-delegate.js:314:25)
    at emitTwo (events.js:87:13)
    at EventEmitter.emit (events.js:172:7)

Commands

     -5:49.6.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -3:05.8.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -3:03.3.0 core:confirm (atom-text-editor.editor.mini.is-focused)
  5x -0:36.6.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:33.6.0 editor:newline (atom-text-editor.editor.is-focused)
  2x -0:33.1.0 core:backspace (atom-text-editor.editor.is-focused)
  2x -0:31.9.0 editor:newline (atom-text-editor.editor.is-focused)
  2x -0:26 core:move-up (atom-text-editor.editor.is-focused)
     -0:25.5.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:24.9.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:24.1.0 core:move-down (atom-text-editor.editor.is-focused)
     -0:23.8.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:22.7.0 core:move-up (atom-text-editor.editor.is-focused)
     -0:15 php-cs-fixer:fix (atom-text-editor.editor.is-focused)
     -0:10.8.0 php-refactoring:extract (atom-text-editor.editor.is-focused)
     -0:02.5.0 php-refactoring:optimize (atom-text-editor.editor.mini.is-focused)

Config

{}

Installed Packages

# User
php-cs-fixer, v2.5.6
php-refactoring, v1.4.0

# Dev
No dev packages

Changes required due to TextBuffer.save becoming async in Atom 1.19

Hi! Thanks for maintaining the php-refactoring package!

In Atom v1.19, we will release a major change to Atom's core text buffer data structure. As part of this change, we have made TextBuffer.save asynchronous; rather than blocking until the save is complete, it now immediately returns a Promise that resolves when the save is complete. Because of this, a few other Atom APIs that use save have similarly become async:

  • Pane.close
  • TextBuffer.save
  • TextEditor.save
  • Pane.saveItem
  • Pane.saveItemAs
  • Pane.saveActiveItem
  • Pane.saveActiveItemAs
  • Pane.saveItems
  • Workspace.saveActivePaneItem
  • Workspace.saveActivePaneItemAs

Effects on this package

We think this package could be impacted by this upgrade because it calls the changed methods in the following places:

  • TextEditor.save

We found these calls using a regex search, so this list might be incomplete, and it might contain some false positives.

What to do about the change

It should be pretty easy to adjust your package code and/or tests to work with the new async behavior, and to simultaneously keep it working with older versions of Atom. Here are some examples of pull requests we opened on our bundled packages to cope with the change:

Please let me know if you have any questions. I would be happy to help!

Uncaught Error: Can't save destroyed buffer

[Enter steps to reproduce:]

  1. Open file
  2. Select variable to rename '$ant'
  3. Select PHP refactor - rename
  4. Enter new variable name '$body'
  5. Try to refactor-rename

Atom: 1.16.0 x64
Electron: 1.3.13
OS: Ubuntu 16.04.2
Thrown From: php-refactoring package 1.4.0

Stack Trace

Uncaught Error: Can't save destroyed buffer

At /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:1064

Error: Can't save destroyed buffer
    at TextBuffer.module.exports.TextBuffer.saveAs (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1064:15)
    at TextBuffer.module.exports.TextBuffer.save (/app.asar/node_modules/text-buffer/lib/text-buffer.js:1058:19)
    at TextEditor.module.exports.TextEditor.save (/app.asar/src/text-editor.js:920:26)
    at Object.runCommand (/packages/php-refactoring/lib/php-refactoring.coffee:101:17)
    at Object.renameVariable (/packages/php-refactoring/lib/php-refactoring.coffee:86:10)
    at Object.handleConfirm (/packages/php-refactoring/lib/php-refactoring.coffee:61:10)
    at /packages/php-refactoring/lib/php-refactoring.coffee:55:102)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/app.asar/src/command-registry.js:259:29)
    at /app.asar/src/command-registry.js:3:59
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:599:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:390:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/app.asar/src/window-event-handler.js:106:36)
    at /app.asar/src/window-event-handler.js:3:59)

Commands

     -4:46.3.0 core:cancel (input.hidden-input)
     -1:46.4.0 php-refactoring:rename-variable (span.syntax--variable.syntax--other.syntax--php)
  2x -1:43.5.0 core:confirm (input.hidden-input)
     -0:23 php-refactoring:rename-variable (span.syntax--variable.syntax--other.syntax--php)
     -0:21.4.0 core:confirm (input.hidden-input)
     -0:18.6.0 editor:consolidate-selections (input.hidden-input)
     -0:18.6.0 core:cancel (input.hidden-input)
     -0:18.1.0 editor:consolidate-selections (input.hidden-input)
     -0:18.1.0 core:cancel (input.hidden-input)
     -0:16 intentions:highlight (input.hidden-input)
     -0:15.6.0 core:save (input.hidden-input)
     -0:11.8.0 php-refactoring:extract (span.syntax--variable.syntax--other.syntax--php)
     -0:11.1.0 editor:consolidate-selections (input.hidden-input)
     -0:11.1.0 core:cancel (input.hidden-input)
     -0:08.7.0 php-refactoring:rename-variable (span.syntax--variable.syntax--other.syntax--php)
     -0:06.6.0 core:confirm (input.hidden-input)

Non-Core Packages

hacking-the-kernel 1.6.2 
hacking-the-kernel-ui 1.6.2 
hyperclick 0.0.40 
intentions 1.1.2 
php-integrator-annotations 1.1.1 
php-integrator-autocomplete-plus 1.5.0 
php-integrator-base 2.1.11 
php-integrator-call-tips 1.2.1 
php-integrator-linter 1.3.0 
php-integrator-navigation 1.1.2 
php-integrator-refactoring 1.3.1 
php-integrator-tooltips 1.1.5 
php-refactoring 1.4.0 
project-manager 3.3.4 

Uncaught TypeError: this.editor.getPath is not a function

[Enter steps to reproduce below:]

  1. Attempt to refactor code via extracting.

Atom Version: 1.8.0
System: Mac OS X 10.11.6
Thrown From: php-refactoring package, v1.4.0

Stack Trace

Uncaught TypeError: this.editor.getPath is not a function

At /Users/Josh/.atom/packages/php-refactoring/lib/php-refactoring.coffee:73

TypeError: this.editor.getPath is not a function
    at Object.module.exports.PhpRefactoring.extractMethod (/Users/Josh/.atom/packages/php-refactoring/lib/php-refactoring.coffee:73:24)
    at Object.module.exports.PhpRefactoring.handleConfirm (/Users/Josh/.atom/packages/php-refactoring/lib/php-refactoring.coffee:61:10)
    at atom-text-editor.<anonymous> (/Users/Josh/.atom/packages/php-refactoring/lib/php-refactoring.coffee:55:102)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
    at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:580:16)
    at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:388:22)
    at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeyEvent (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:98:36)
    at HTMLDocument.<anonymous> (/Applications/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)

Commands

     -1:21.3.0 php-refactoring:extract (atom-text-editor.editor)
 37x -1:15.9.0 core:backspace (atom-text-editor.editor.mini.is-focused)
     -0:54.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:46.8.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
     -0:46.8.0 core:cancel (atom-text-editor.editor.mini.is-focused)
     -0:32.1.0 core:undo (atom-text-editor.editor.is-focused)
     -0:30 core:save (atom-text-editor.editor.is-focused)
     -0:26.1.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -0:26.1.0 core:cancel (atom-text-editor.editor.is-focused)
     -0:21.7.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -0:19.8.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:19.8.0 php-refactoring:extract (atom-text-editor.editor)
  9x -0:13.7.0 core:backspace (atom-text-editor.editor.mini.is-focused)
  9x -0:03.8.0 core:move-left (atom-text-editor.editor.mini.is-focused)
     -0:02.2.0 core:move-right (atom-text-editor.editor.mini.is-focused)
     -0:00.8.0 core:confirm (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {
    "themes": [
      "one-dark-ui",
      "an-old-hope-syntax"
    ]
  }
}

Installed Packages

# User
an-old-hope-syntax, v0.5.0
language-blade, v0.25.3
language-htaccess, v0.1.1
language-ini, v1.16.0
minimap, v4.24.7
php-refactoring, v1.4.0
pretty-json, v1.4.4

# Dev
No dev packages

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.