Wallogit.com
2017 © Pedro Peláez
You don't need create all getters and setters in your class. Only create attributes extends lombok-like and comment it for display in your IDE autocomplete., (*1)
@2.1.0 - Throw an exception., (*2)
@2.0.0 - Removed abstract methods and change reflection to closure., (*3)
@1.2.1 - Change name of methods from __get to get for override., (*4)
@1.2.0 - Remove support to codes with underscore and improve to use private attributes., (*5)
@1.1.0 - Adaptated to old codes which were used with underscore before name of attribute., (*6)
composer install, (*7)
composer require k-hei/lombok-like
Include LombokLike class where you need:, (*8)
include 'vendor/autoload.php';
Extend it on all classes that you need:, (*9)
class Test extends \LombokLike\BaseEntity {}
If you want methods can be displayed in your IDE, use the PHPdoc on attributes:, (*10)
class Test extends \LombokLike\BaseEntity {
...
/**
* @method typeOfReturn getNameOfAttribute() optionally description
* @method typeOfReturn setNameOfAttribute($value) optionally description
*/
protected $nameOfAttribute;
...
}
And use!, (*11)
$test = new Test();
$test->setNameOfAttribute("Test");
echo $test->getNameOfAttribute();
//Result display is: Test
If you call a unknown method, receive a LombokException:, (*12)
$test->setUnknowAttr("Unkmow property");
Fatal error: Uncaught Call to undefined function: setUnknowAttr() In: F:\...\file.php On line: 99
thrown in F:\...\LombokLike\entity\Base.php on line 100
The LombokLike is created and maintained by Khwesten Heiner. Heiner is a senior FullStack web developer at MeuTutor and TeckS., (*13)
The LombokLike is released under the MIT public license., (*14)