Type of returning for functions of the prepareSubject and the prepare…#241
Type of returning for functions of the prepareSubject and the prepare…#241artemii-karkusha wants to merge 770 commits intolaminas:2.23.xfrom
Conversation
Updates the CHANGELOG.md to set the release date.
Updates the CHANGELOG.md file to add a changelog entry for a new 2.14.0 version.
Updates the CHANGELOG.md file to add a changelog entry for a new 2.13.1 version.
- Removes `.travis.yml` - Adds continuous-integration GHA workflow - Updates badges in `README.md` - Removes `CHANGELOG.md`; changelogs will be kept in milestone descriptions and propagated to tag and release notes Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Related to glpi-project/glpi#8495 Signed-off-by: Edgard <edgardmessias@gmail.com>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Line lengths Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
….x_6026c1d0016d83.30821085 Merge release 2.13.1 into 2.14.x
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: AdrienClairembault <aclairembault@teclib.com>
[2.14]: QA: Add specific type hints for $params
[2.14]: QA: Fix markdown lint errors
…mpty-continuation-lines Fix laminas#25; Skip empty continuation lines
Keep original ZF references refs: - 4665599 Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
[2.14]: Tests: Fix references to ZF issue tracker
To deal with the 998/78 character limitations per line, long lines can be split into a multiple-line representation separated by CRLF + WSP; this is called "folding". Correct folding is particularly important for long header fields. Signed-off-by: Vlad Safronov <vladislav.safronov@oracle.com>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
This isolates the logic of handling incomplete reads to own unit. Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
As the buffer max size is known, can check last byte with isset Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Elan Ruusamäe <glen@pld-linux.org>
Signed-off-by: Filippo Tessarotto <zoeslam@gmail.com>
Update to PHPUnit 10
…Parameters have been fixed Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Ocramius
left a comment
There was a problem hiding this comment.
We'd need a test to verify this change: I suppose you expect getSubject() to always return a string?
|
dockblock and usage checks out, it is expected to always return string. Return values are passed to |
|
Yes, I mean a test case (additions to our PHPUnit test suite :D ) The test should fail before this change, and pass after this change. |
I will add for this case |
|
@Ocramius |
Ocramius
left a comment
There was a problem hiding this comment.
@artemii-karkusha looking much better now, thanks!
What's missing now is some cleanup around the test case.
| $this->transport->setCallable([$this->transport, 'mailHandler']); | ||
| try { | ||
| $this->transport->send($message); | ||
| } catch (\RuntimeException $runtimeException) { |
There was a problem hiding this comment.
Is a RuntimeException expected to be thrown at all times?
If so, PHPUnit can help you here:
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Something different from a warning');The try-catch can then be removed :)
There was a problem hiding this comment.
@Ocramius No. It is not expected to throw all time. It was added to be sure logic will not be broken for mailHandler in future.
There was a problem hiding this comment.
Ok, but then this test has no assertions, and is a risky test 🤔
Can we somehow verify the outcome with a valid assertion?
/cc @Slamdunk for ideas
There was a problem hiding this comment.
It is not real to cover outcome. Function doesn't return nothing. What we can cover is exception which is thrown when someone will change behaviour for subject and it will influence on function the mail(..., #subject).
prepareSubject which can be better place for test case is protected.
I don't have any ideas how can we cover it in another way. If you have let it will share with me, please.
There was a problem hiding this comment.
Yep, that's why I poked @Slamdunk to get some more brains :)
There was a problem hiding this comment.
IMHO we don't need tests here, it's a type mismatch so getting rid of PSalm suppressions should be enough:
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 88d83696..0140e43e 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -1737,18 +1737,12 @@
<InvalidArgument>
<code><![CDATA[[$this, 'handleMailErrors']]]></code>
</InvalidArgument>
- <InvalidNullableReturnType>
- <code>string</code>
- </InvalidNullableReturnType>
<MissingReturnType>
<code>mailHandler</code>
</MissingReturnType>
<MixedAssignment>
<code>$param</code>
</MixedAssignment>
- <MixedInferredReturnType>
- <code>string</code>
- </MixedInferredReturnType>
<MixedOperand>
<code>$param</code>
</MixedOperand>
diff --git a/src/Transport/Sendmail.php b/src/Transport/Sendmail.php
index aae76f49..58868dda 100644
--- a/src/Transport/Sendmail.php
+++ b/src/Transport/Sendmail.php
@@ -9,6 +9,7 @@ use Laminas\Mail\Transport\Exception\InvalidArgumentException;
use Laminas\Mail\Transport\Exception\RuntimeException;
use Traversable;
+use function assert;
use function count;
use function escapeshellarg;
use function gettype;
@@ -200,10 +201,12 @@ class Sendmail implements TransportInterface
{
$headers = $message->getHeaders();
if (! $headers->has('subject')) {
- return;
+ return '';
}
- $header = $headers->get('subject');
- return $header->getFieldValue(HeaderInterface::FORMAT_ENCODED);
+ $header = $headers->get('subject');
+ $fieldValue = $header->getFieldValue(HeaderInterface::FORMAT_ENCODED);
+ assert(is_string($fieldValue));
+ return $fieldValue;
}
/**
@@ -259,7 +262,7 @@ class Sendmail implements TransportInterface
protected function prepareParameters(Mail\Message $message)
{
if ($this->isWindowsOs()) {
- return;
+ return '';
}
$parameters = (string) $this->parameters;There was a problem hiding this comment.
I'm happy with this outcome too 👍
695288c to
7faa761
Compare
…mail has been added. Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
|
@Ocramius Please let me know if something is needed to changing. It is ready for merging |
This reverts commit 7c2afd0.
This reverts commit f9f43a3.
This reverts commit f07d863.
…sending mail has been added." This reverts commit fab234c.
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
…ng' for Laminas\Mail\Transport\Envelope::getFrom is not nullable, but 'null|string' contains null (see https://psalm.dev/144)" has been fixed Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
Signed-off-by: Artemii Karkusha <artemii.karkusha@alshaya.com>
fac3277 to
bab9ae9
Compare
|
See #242 |

Type of returning for functions of the prepareSubject and the prepareParameters have been fixed
#240