-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP: wrong inlay hints #19
Comments
What parameters do you see when you hover your mouse over the |
I have unfortunately been unable to recreate this issue. Are you able to recreate this in a file such as the |
@RobertOstermann, <?php
class Account
{
private int $minorUnits = 0;
public function getMinorUnits(): int
{
return $this->minorUnits;
}
public function setMinorUnits(int $minorUnits): self
{
$this->minorUnits = $minorUnits;
return $this;
}
}
class Currency
{
private string $currencyCode = 'USD';
public function getCurrencyCode(): int
{
return $this->currencyCode;
}
public function setCurrencyCode(int $currencyCode): self
{
$this->currencyCode = $currencyCode;
return $this;
}
}
class Payment
{
private ?Currency $currency = null;
public function getCurrency(): ?Currency
{
return $this->currency;
}
public function setCurrencyCode(Currency $currency): self
{
$this->currency = $currency;
return $this;
}
}
interface PaymentServiceInterface
{
/**
* @param callable $minorUnitsCallback (Account $sourceAccount, Account $destAccount): int
* @param callable|null $beforePaymentIsBuilt (Account $sourceAccount, Account $destAccount, int $minorUnits): void
* @param callable|null $whenPaymentIsCreated (Payment $payment, Account $sourceAccount, Account $destAccount): void
* @param callable|null $whenMoneyAreTransferred (Payment $payment, Account $sourceAccount, Account $destAccount): void
*/
public function transfer(
int $sourceAccountId,
int $destinationAccountId,
Currency $currency,
callable $minorUnitsCallback,
string $paymentReference,
int $paymentType,
?Payment $parent = null,
callable $beforePaymentIsBuilt = null,
callable $whenPaymentIsCreated = null,
callable $whenMoneyAreTransferred = null
): Payment;
}
function testInterface(PaymentServiceInterface $p)
{
return $p->transfer(
1,
2,
((new Currency())->setCurrencyCode('USD')),
fn () => 1,
'qqq',
1,
null,
);
} |
@AndreiOrmanji You are correct, seems to be an issue with handling annotations. I use the hover provided by I am currently just using a regex to parse the parameters and return them. It will probably require parsing the function part of the hover (definition) to determine the correct order of the parameters and reordering them after I grab them from the definition. I am busy with other projects and it might be some time before I am able to work on this. If you wanted to work on this and provide a pull request I would get that merged and published. Or you can workaround it by providing annotations for all the variables (in the correct order) or not using annotations at all, though in this case that is probably not ideal. |
Description:

Method Definition:

Extension settings (default overriden):
"inline-parameters.php.suppressWhenArgumentMatchesName": false
Inlay settings:
"editor.inlayHints.enabled": "offUnlessPressed"
If there is some additional info, feel free to ask.
The text was updated successfully, but these errors were encountered: