Code generation fail

Issue #2 new
lyrixx created an issue

Hello.

I try your plugin, And I stubble upon few bugs:

<?php

@class Plan
@property -set -get id
@property -set -get stripeReference
@property -set -get name
@property -set -get amount
@property -set -get currency
@property -set -get interval
@property -set -get intervalCount
@endClass

result in:

<?php

class Plan 
{




    private $id;



    public function setId($value)
    {
        $this->id = $value;
    }   public function getId()
    {
        return $this->id;
    }
@



    private $stripeReference;



    public function setStripeReference($value)
    {
        $this->stripeReference = $value;
    }   public function getStripeReference()
    {
        return $this->stripeReference;
    }@p



    private $name;



    public function setName($value)
    {
        $this->name = $value;
    }   public function getName()
    {
        return $this->name;
    }pr



    private $amount;



    public function setAmount($value)
    {
        $this->amount = $value;
    }   public function getAmount()
    {
        return $this->amount;
    }ro



    private $currency;



    public function setCurrency($value)
    {
        $this->currency = $value;
    }   public function getCurrency()
    {
        return $this->currency;
    }op



    private $interval;



    public function setInterval($value)
    {
        $this->interval = $value;
    }   public function getInterval()
    {
        return $this->interval;
    }pe



    private $intervalCount;



    public function setIntervalCount($value)
    {
        $this->intervalCount = $value;
    }   public function getIntervalCount()
    {
        return $this->intervalCount;
    }la
}

With the following configuration:

{
    "debugMode": false,
    "autoGenerateDockBlocks": false,

    "defaultMethodVisibility": "public",
    "defaultPropertyVisibility": "private",

    "openingCurlyBraceOnSameLine": false,

    "newLinesAfterMethodDeclaration": 1,
    "newLinesBeforeMethodClosingBrace": 1,

}

So:

  • There are trace of code gen instruction in the result code (@, la, ...)
  • It is not possible to disable comment and have a nice code indentation
  • It could be nice if php code gen could first write all proporties, then methods, then getters / setters.

Anyway, I don't know if you know http://www.php-fig.org/ but now, in PHP, the code formation is standardized. It could be nice if the default configuration is the same as the PHP FIG one.

Comments (4)

  1. B T repo owner

    Hey, I used your config settings and I wasn't able to get get the broken output. What version of Sublime are you using and what operating system? Also, what are your tab settings?

    Also, I did notice that with comments disabled the indentation is incorrect.

    I will address that as well as:

    "It could be nice if php code gen could first write all properties, then methods, then getters / setters"

    I can't promise you that I will have these things addressed quickly, as I am tied up in some other work at the moment. However, if you'd like to contribute to the plugin, feel free to fork and do so.

    Thanks for pointing this out.

  2. lyrixx reporter

    I use

    • ST3 build 3047
    • Linux Mint 15 Olivia
    • Python 2.7.4

    I don't really understood the question about tab setting. But here is my global setting:

    {
        "caret_style": "phase",
        "close_windows_when_empty": false,
        "color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
        "default_line_ending": "unix",
        "detect_indentation": true,
        "dictionary": "Packages/Language - English/en_US.dic",
        "draw_white_space": "all",
        "ensure_newline_at_eof_on_save": true,
        "file_exclude_patterns":
        [
            ".tags*",
            "*.pyc",
            "composer.lock",
            "resources/data/"
        ],
        "font_face": "consolas",
        "font_size": 14,
        "gutter": true,
        "highlight_line": true,
        "highlight_modified_tabs": false,
        "hot_exit": false,
        "ignored_packages":
        [
            "Vintage"
        ],
        "indent_guide_options":
        [
            "draw_active"
        ],
        "match_brackets_angle": true,
        "phoenix_color_expanded_folder": true,
        "phoenix_color_green": true,
        "phoenix_dirty_bottom_bar": true,
        "phoenix_dirty_bottom_bar_green": true,
        "phoenix_highlight_current_tab": true,
        "phoenix_solid_current_tab": true,
        "phoenix_tabs_small": true,
        "rulers":
        [
            80,
            120
        ],
        "show_tab_close_buttons": true,
        "spell_check": true,
        "tab_size": 4,
        "theme": "Phoenix Dark.sublime-theme",
        "translate_tabs_to_spaces": true,
        "trim_trailing_white_space_on_save": true,
        "word_wrap": "false"
    }
    
  3. B T repo owner

    Ah yes, the setting: "translate_tabs_to_spaces". When I set it to true I got the broken output. If its set to false it won't be broken, minus the tab indent issue.

  4. Log in to comment