sendgrid-php icon indicating copy to clipboard operation
sendgrid-php copied to clipboard

PHPDoc method prediction considerations

Open kampalex opened this issue 6 years ago • 3 comments

Currently I try to improve PHPDoc on this library (branch master) - due to the missing @throws TypeException parts.

In SendGrid.php some parameters don't have the proper PHPDoc types, which make it hard to calculate methods (using PhpStorm) in tests. Is there a reason the next changes aren't allowed?

use SendGrid\Client;
use SendGrid\Mail\Mail;
use SendGrid\Response;

and

    /** @var string Namespace */
    protected $namespace = 'SendGrid';

    /** @var Client Client */
    public $client;
    /** @var string Version */
    public $version = self::VERSION;

(next question)

According to this issue and absence of DynamicTemplateData class, I think type hints for DynamicTemplateData may be changed. Can these be replaced safely by Substitution?

That's it for now!

kampalex avatar Dec 04 '19 16:12 kampalex

I've no issue with reviewing a PR to add the proper PHP docs.

Not sure I understand the second question. Dynamic template data is used for dynamic templates and substitutions are used for legacy templates. Could you clarify?

childish-sambino avatar Mar 06 '20 23:03 childish-sambino

Second issue is about type hints of (legacy) class DynamicTemplateData which may be found by https://github.com/sendgrid/sendgrid-php/search?q=DynamicTemplateData&type=Code .

No big issue after all and will provide PR soon.

kampalex avatar Mar 07 '20 07:03 kampalex

Ah, I see what you mean. Those docs are actually correct, although confusing.

If a dynamic template is used, all substitutions and dynamic template data will go in the dynamic_template_data of the personalizations.

If a dynamic template is not used (i.e., a legacy template), all substitutions and dynamic template data will go in the substitutions of the personalizations.

Some of the logic here: https://github.com/sendgrid/sendgrid-php/blob/master/lib/mail/Personalization.php#L287-L293

childish-sambino avatar Mar 12 '20 15:03 childish-sambino