Closed uonick closed 5 years ago
and.. use Laravel stubs for more customizable class content and clean code:
Something like that:
/**
* Return file template
*/
public function getTemplate(): string
{
return str_replace(
[
'${class}',
],
[
$this->getInterfaceName(),
],
$this->getStubContents()
);
}
/**
* Return interface name
*/
private function getInterfaceName(): string
{
return sprintf(
'%sRepositoryInterface',
$this->getClassName()
);
}
public function getTemplate(): string
{
return str_replace(
[
'${namespace}',
'${extends}',
'${extends_class}',
'${class}',
'${constants}',
'${getters}',
],
[
$this->getNamespace(),
$this->getExtends(),
$this->getExtendsClass(),
$this->getClassName(),
$this->getColumns(),
$this->getGetterMethods(),
],
$this->getStubContents()
);
}
protected function getStubContents(): string
{
return file_get_contents(
sprintf(
'%s/%s.stub',
config('generator.stubs'),
$this->getType()
)
);
}
This looks pretty good. But are you sure that all the of these added return types are supported in PHP 7.0? That's the current supported version in order to remain compatible with Laravel 5.5.
Sure. But not all of them. It wasn't until 7.1 void
and nullable types were supported.
Unfortunately we need to maintain compatibility with 7.0 in order to support the latest Laravel LTS version (5.5).
Feel free to break these up into smaller PRs and we can get the other stuff through, or remove the incompatibilities. 👍
array → [] return types added some syntax fixes
😟