If PHP7 Type Hints is enabled, but property has no type declared, a colon is inserted after getter method.
AlexJBSilva opened this issue · 3 comments
vscode-php-getters-setters/src/extension.ts
Line 317 in f4cc160
The method getReturnTypeHint stores an empty string in 'type' when a null is passed as first argument , and if PHP7 Type Hints is enabled, it will end up as a wrong colon inserted in getter function just after (), thus breaking the php code.
Hello @AlexJBSilva
Thanks for the report and PR. Could you just give me a code example of what you use as input, what you get (with the bug) and what do you expect to have ?
Thanks
Sure! Here is a simple code example:
Input:
<?php
class ID
{
private $value;
public function __construct($value)
{
$this->value = $value;
}
}
Then, we ask the extension to do its work:
Output (with the bug):
<?php
class ID
{
private $value;
public function __construct($value)
{
$this->value = $value;
}
/**
* Get the value of value
*/
public function getValue():
{
return $this->value;
}
}
We expect to NOT have that colon.
Thank You for keeping this extension alive!
Thanks for the quick reply and details 👌
Merged and new release on the way ;)