With PHP Getters and Setters you can automatically generate Getters and Setters for your php classes.
A fork of PHP Getters and Setters with template in files instead of in config memory. Edit templates in their own files.
The code produced is PSR compatible
Example PHP Code
<?phpclass test {/*** foo container** @var AbcClass*/private $foo;}
Example class after generating Getters and Setters
<?phpclass test {/*** foo container* @var AbcClass*/private $foo;/*** Gets the foo container.* @return AbcClass*/public function getFoo() {return $this->foo;}/*** Sets the foo container.* @param AbcClass $foo the foo* @return self*/public 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.
This is an huge time saver!
@internal: getter and setter will be private
@private: getter and setter will be private
@protected: getter and setter will be protected
@read-only private|protected: getter will be public, setter will be private or protected (defaults to private)
doNotTypeHint: an array of items that when present in @type or @var declarations are ignored and not used as type hint
camelCasedMethodNames: method names will follow PSR rules PSR states that all method names must be camel cased, if set to false method names won't be Camel Cased
getterTemplate: the template for the getter
setterTemplate: the template for the setter
A rudimentary template editor is available at Packages -> PHP Getters and Setters -> Template Editor
/*** Get the value of %description%* @return %type%*/%scope% function %methodName%() {return $this->%variable%;}
/*** Set the value of %description%* @param %type% $%variable%* @return self*/%scope% function %methodName%(%typeHint%$%variable%) {$this->%variable% = $%variable%;return $this;}
Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.