adoy/vim-php-refactoring-toolbox

Extract property

jrean opened this issue · 0 comments

Hi,

I discover an issue with the extract property function PhpExtractClassProperty().

I have a class where the LAST property is an array as follow. (Notice it's not the default array statement but the it's custom way)

<?php
class Dir {
    /**
     * Property description
     *
     * @var array
     */
    protected $var = [
        'foo', 'bar', 'baz',
    ];

    public function __construct($path) {
        $realpath = $path;
    }       ↑
}

If I hit ep to extract it, it outputs the following..

<?php
class Dir {
    /**
     * Property description
     *
     * @var array
     */
    protected $var = [

        /**
         * @var mixed
         */
        private $realpath;
        'foo', 'bar', 'baz',
    ];


    public function __construct($path) {
        $this->realpath = $path;

    }       ↑
}

As you can see there is an issue whit the regex at https://github.com/jrean/vim-php-refactoring-toolbox/blob/master/plugin/php-refactoring-toolbox.vim#L367

:)