Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

wrong return type in Swift_Attachment::fromPath method #1164

Closed
garak opened this issue Jan 18, 2019 · 0 comments
Closed

wrong return type in Swift_Attachment::fromPath method #1164

garak opened this issue Jan 18, 2019 · 0 comments

Comments

@garak
Copy link
Contributor

garak commented Jan 18, 2019

Q A
Bug report? yes
Feature request? no
RFC? no
How used? Symfony
Swiftmailer version 6.1.3
PHP version 7.2.3

The phpdoc block in fromPath method is suggesting Swift_Mime_Attachment as a return type, while the method is returning an instance of self.
This is a problem when using a function with type-hinted parameter or return type.
Example:

<?php

function doSomethingWithAttachment(Swift_Attachment $attachment)
{
    // ....
}

$attachment = Swift_Attachment::fromPath('/foo.png');
doSomethingWithAttachment($attachment);

This is highlighted as error in IDE (e.g. phpStorm), because $attachment type is Swift_Mime_Attachment, while function is accepting Swift_Attachment.

Solution is trivial, I can provide a PR.

garak added a commit to garak/swiftmailer that referenced this issue Jan 20, 2019
@fabpot fabpot closed this as completed Jan 20, 2019
fabpot added a commit that referenced this issue Jan 20, 2019
This PR was merged into the 6.2-dev branch.

Discussion
----------

fix fromPath return type. See issue #1164

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Doc update?   | no
| BC breaks?    | no
| Deprecations? | no
| Fixed tickets | #1164
| License       | MIT

Commits
-------

e1dd436 fix fromPath return type. See issue #1164
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants