alexanderweiss / nova-prettier

Prettier extension for Nova
MIT License
35 stars 6 forks source link

Bug in PHP - It made some of my files unreadable #21

Closed undisconnected closed 4 years ago

undisconnected commented 4 years ago

I have a file with this code in it :

`<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Event_type_model extends CI_Model {

function construct() { // Call the Model constructor parent::construct(); }

public function get_event_types(){

$this -> db -> where("event_type_slug", NULL);
$this -> db -> order_by("event_type_name");
$q = $this -> db -> get("event_type");

$res = $q -> result_array();

return $res;

}

public function get_event_type_id_by_slug($event_type_slug){

$q = $this -> db -> get_where("event_type", array("event_type_slug" => $event_type_slug));
$res = $q -> result_array();

if(count($res) == 1){
  return $res[0]["event_type_id"];
}

}

}`

If I save the file, all the code is reorganised in a way that does not make sens. And the file is not working, providing big errors. Try to create a file with the code above and save it, you should see the result. Here's a screenshot.

Capture d’écran, le 2020-09-26 à 18 40 21

If I deactivate Prettier from Nova, all saves as normal.

Hope you can do something, as I really like it for other languages. At least, if it could do nothing for PHP, that'd be just better.

Thanks

alexanderweiss commented 4 years ago

Hi @undisconnected, it's been fixed in the latest release (v1.5.0). By default it won't try to format PHP files anymore. If you'd like to use Prettier for PHP it does also have a new Run Prettier in a separate process (experimental) option in the preferences in the Extension Library. Enabling that adds support for plugins. So if you have Prettier and @prettier/plugin-php installed in your project it should format PHP as you'd expect. It would be awesome if you could test it out and let me know how it works.

undisconnected commented 4 years ago

Hey Alexander,

Thanks for your answer. I see it must have updated alone, I'm now at 1.51 of prettier. I just tested the file I had problem with and it seems to work fine now.

I did not test yet the separate process thing as I want it as automated as it can be.

Thanks for a great extension:)

Take care

Le sam. 26 sept. 2020 à 19:02, Alexander Weiss notifications@github.com a écrit :

Hi @undisconnected https://github.com/undisconnected, it's been fixed in the latest release (v1.5.0). By default it won't try to format PHP files anymore. If you'd like to use Prettier for PHP it does also have a new Run Prettier in a separate process (experimental) option in the preferences in the Extension Library. Enabling that adds support for plugins. So if you have Prettier and @prettier/plugin-php installed in your project it should format PHP as you'd expect. It would be awesome if you could test it out and let me know how it works.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alexanderweiss/nova-prettier/issues/21#issuecomment-699528280, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELHZGKJ6E5XFDE6FS66QY3SHYUBXANCNFSM4R3AYCPA .

--


Matt

http://undisconnected.com https://twitter.com/undisconnected

alexanderweiss commented 4 years ago

Okay. Good to hear. The separate process option will soon be the default, so no worry about automation.