Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Context.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{ "caption" : "-" },
{ "command": "php_generate_getters_setters", "caption": "Generate All" },
{ "command": "php_generate_getters", "caption": "Generate Getters" },
{ "command": "php_generate_setters", "caption": "Generate setters" },
{ "command": "php_generate_setters", "caption": "Generate Setters" },
{ "command": "php_generate_getters_setter_unavailable", "caption": "" }
]
}
Expand Down
2 changes: 1 addition & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"caption": "PHP: Generate Setters",
"command": "php_generate_getters"
"command": "php_generate_setters"
},
{
"command": "php_generate_getter_for",
Expand Down
18 changes: 9 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Usage Instruction:
* @var AbcClass
*/
private $foo;

/**
* Gets the foo container.
*
Expand All @@ -51,7 +51,7 @@ Usage Instruction:
{
return $this->foo;
}

/**
* Sets the foo container.
*
Expand All @@ -60,13 +60,13 @@ Usage Instruction:
private function _setFoo(AbcClass $foo)
{
$this->foo = $foo;

return $this;
}
}
```

As you can see if get to trouble of commenting your variables, the generated functions can be used without modification.
As you can see, if you go though the trouble of commenting your variables, the generated functions can be used without modification.

This is an huge time saver!

Expand All @@ -81,7 +81,7 @@ Commands available are:
* Generate Getter for...
* Generate Setter for...

These can be accesed via the context menu (right click on the source of any open PHP file) or the command pallette. The currently open file *must* be a PHP file.
These can be accessed via the context menu (right click on the source of any open PHP file) or the command palette. The currently open file *must* be a PHP file.

Settings Reference
------------------
Expand All @@ -91,7 +91,7 @@ _type_ : **boolean**

_default_ : **false**

_description_: ignore visibilty for setters generation
_description_: ignore visibility for setters generation

###registerTemplates
_type_ : **array**
Expand Down Expand Up @@ -133,7 +133,7 @@ Creating your own template
class myTemplate(object):
name = "myTemplate"
style = 'camelCase' # can also be snakeCase
getter = """
getter = """
/**
* Gets the %(description)s.
*
Expand All @@ -145,7 +145,7 @@ class myTemplate(object):
}
"""

setter = """
setter = """
/**
* Sets the %(description)s.
*
Expand All @@ -170,4 +170,4 @@ class myTemplate(object):
"template" : "myTemplate",
```
* restart sublime to use the new template

7 changes: 4 additions & 3 deletions php-getter-setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,13 @@ def getDescription(self):
def getPartialFunctionName(self):
style = self.style
name = self.getName()
length = len(name)

if name[0] == '_' and name[1].islower() and name[2].isupper():
if length > 1 and name[0] == '_' and name[1].islower() and name[2].isupper():
name = name[2:] # _aTest
elif (name[0].islower() and name[1].isupper()):
elif length > 1 and (name[0].islower() and name[1].isupper()):
name = name[1:] # aTest
elif (name[0] == '_'):
elif length > 1 and (name[0] == '_'):
name = name[1:] # _test OR _Test

if 'camelCase' == style:
Expand Down