pfefferle / atom-php-cs-fixer

Run the 'PHP Coding Standards Fixer' within Atom
https://atom.io/packages/php-cs-fixer
MIT License
28 stars 16 forks source link

Uncaught TypeError: Cannot read property 'toString' of undefined #69

Open vickybiswas opened 7 years ago

vickybiswas commented 7 years ago

[Enter steps to reproduce:]

  1. Create a simple HTML
  2. Run the plugin

Atom: 1.19.5 x64 Electron: 1.6.9 OS: Mac OS X 10.12.6 Thrown From: php-cs-fixer package 4.1.1

Stack Trace

Uncaught TypeError: Cannot read property 'toString' of undefined

At /Users/vickybiswas/.atom/packages/php-cs-fixer/lib/php-cs-fixer.coffee:134

TypeError: Cannot read property 'toString' of undefined
    at Object.fix (/packages/php-cs-fixer/lib/php-cs-fixer.coffee:134:72)
    at /packages/php-cs-fixer/lib/php-cs-fixer.coffee:106:84)
    at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:265:35)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:3:65)
    at CommandRegistry.module.exports.CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:166:25)
    at AtomEnvironment.module.exports.AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1338:34)
    at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app/src/application-delegate.js:334:31)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:194:7)

Commands

     -3:12.6.0 core:move-down (input.hidden-input)
     -3:09.5.0 core:paste (input.hidden-input)
     -3:07.3.0 core:move-down (input.hidden-input)
  4x -3:06.6.0 core:select-down (input.hidden-input)
     -3:04.8.0 core:backspace (input.hidden-input)
  2x -3:03.5.0 core:move-down (input.hidden-input)
 14x -3:02.7.0 core:select-down (input.hidden-input)
     -3:00.9.0 core:select-up (input.hidden-input)
     -3:00.3.0 core:select-down (input.hidden-input)
     -2:59.4.0 core:backspace (input.hidden-input)
     -2:55.9.0 core:save (input.hidden-input)
     -2:48.1.0 core:select-all (input.hidden-input)
     -2:47.2.0 core:cut (input.hidden-input)
     -0:40.8.0 core:undo (input.hidden-input)
     -0:22.3.0 core:move-right (input.hidden-input)
     -0:11 php-cs-fixer:fix (input.hidden-input)

Non-Core Packages

git-plus 7.9.3 
php-cs-fixer 4.1.1 
php-integrator-linter 0.2.1 
php-integrator-linter-legacy-php56 1.3.1 
quick-editor 0.4.3 
remote-edit 1.9.0 
remote-sync 4.1.5 
sass-autocompile 0.13.3 
femartin commented 6 years ago

Same problem

KEINOS commented 6 years ago

Same problem

ATOM: 1.27.2 x64 OS: macOS HighSierra ( OSX 10.13.5) Thrown From: php-cs-fixer package 4.1.1

Code Tested

Not saved and run [Package]-[php-cs-fixer]-[FIX(^⌘S)].

<?php

echo sayHello();

function sayHello(){
  return 'Hello world!';
}

Stack Trace

TypeError: Cannot read property 'toString' of undefined
    at Object.fix (/Volumes/Macintosh_SD/Users/admin/.atom/packages/php-cs-fixer/lib/php-cs-fixer.coffee:134:72)
    at HTMLElement.subscriptions.add.atom.commands.add.php-cs-fixer:fix (/Volumes/Macintosh_SD/Users/admin/.atom/packages/php-cs-fixer/lib/php-cs-fixer.coffee:106:84)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49)
    at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:273:23)
    at AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1347:25)
    at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app/src/application-delegate.js:339:53)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:197:7)

Non-Core Packages

atom-autocomplete-php 0.25.6
japanese-menu 1.14.9
linter-php 1.5.1
php-cs-fixer 4.1.1
teletype 0.13.3
Daksh14 commented 5 years ago

Same problem

CyberMarsl commented 3 years ago

Fix error messsage by setting the php path.

I have seen this issue if the php path is not set. Setting the php path in settings of this module solves the 'toString' problem.