- Edited
this code gives a warning in vscode (not in PHPStorm, though)
$sProduct->interval = $price->recurring->interval ?? 0;
How can I annotate this to avoid the warning as a workaround ?
this code gives a warning in vscode (not in PHPStorm, though)
$sProduct->interval = $price->recurring->interval ?? 0;
How can I annotate this to avoid the warning as a workaround ?
rabol What is the error?
After installing the latest version it is:
Property $interval accessed via magic method.
rabol I see, thanks!
We're experimenting with this. interval
is a dynamic property accessed through magic __get()
which is OK.
But there are other dynamic properties, which are defined using PHPDoc @property
annotation. So this one is suspicious because other properties are annotated but this one is not.
Adding @property $interval
above the class of recurring
will make the code analysis happy.
Still - we're open to any suggestion on how to deal with it.
well... the issue here is that recurring
is a property on price
so I cannot just add the property to the class AFIK
the phpdoc on the stripe/Price class has this:
* @property null|\Stripe\StripeObject $recurring The recurring components of a price such as <code>interval</code> and <code>usage_type</code>.
In phpstorm there is a plugin called 'Laravel Idea'
It generates helper files for phpstorm and for this specific case it generestes this:
/**
* @property _IH_StripeProduct_C|mixed $id
* @property _IH_StripeProduct_C|mixed $stripe_id
* @property _IH_StripeProduct_C|mixed $description
* @property _IH_StripeProduct_C|mixed $name
* @property _IH_StripeProduct_C|mixed $price
* @property _IH_StripeProduct_C|mixed $stripe_price_id
* @property _IH_StripeProduct_C|mixed $currency
* @property _IH_StripeProduct_C|mixed $interval
* @property _IH_StripeProduct_C|mixed $interval_count
* @property _IH_StripeProduct_C|mixed $type
* @property _IH_StripeProduct_C|mixed $active
* @property _IH_StripeProduct_C|mixed $stripe_tax_id
* @property _IH_StripeProduct_C|mixed $trial_days
* @property _IH_StripeProduct_C|mixed $created_at
* @property _IH_StripeProduct_C|mixed $updated_at
* @method _IH_StripeProduct_C uniqueIds()
* @method _IH_StripeProduct_C resolveRouteBindingQuery(Model|Relation $query, $value, null|string $field = null)
* @method _IH_StripeProduct_C getIncrementing()
* @method _IH_StripeProduct_C getKeyType()
* @method _IH_StripeProduct_C newUniqueId()
* @method _IH_StripeProduct_C refresh()
* @method _IH_StripeProduct_C update(array $attributes = [], array $options = [])
* @method _IH_StripeProduct_C save(array $options = [])
* @method _IH_StripeProduct_C increment(string $column, float|int $amount = 1, array $extra = [])
* @method _IH_StripeProduct_C decrement(string $column, float|int $amount = 1, array $extra = [])
* @method _IH_StripeProduct_C touch(null|string $attribute = null)
* @method _IH_StripeProduct_C fill(array $attributes)
* @method _IH_StripeProduct_C delete()
*/
class _IH_StripeProduct_CP {}
Not sure if it helps you or not
Any progress or any hint how I can get rid of this warning ?
rabol Thank you, that's helpful.
_IH_StripeProduct_CP
is the correct class name right?
I'll try to repro the feature and implement it.
rabol there is pre-release 1.38.13874
which works in combination with ide_helper and laravel_idea helpers;
Please let me know if it helps. Thank you!
This issue should be fixed now (1.38.13874)