Completed
Pull Request — master (#42)
by Frederik
02:56
created

AbstractCommand::createStream()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
ccs 0
cts 0
cp 0
nc 1
1
<?php
2
3
namespace Genkgo\Mail\Protocol\Imap\Request;
4
5
use Genkgo\Mail\Protocol\Imap\RequestInterface;
6
use Genkgo\Mail\Stream\ConcatenatedStream;
7
use Genkgo\Mail\Stream\StringStream;
8
use Genkgo\Mail\StreamInterface;
9
10
/**
11
 * Class AbstractCommand
12
 * @package Genkgo\Mail\Protocol\Imap\Request
13
 */
14
abstract class AbstractCommand implements RequestInterface
15
{
16
    /**
17
     * @return StreamInterface
18
     */
19
    abstract protected function createStream(): StreamInterface;
20
21
    /**
22
     * @return StreamInterface
23
     */
24
    final public function toStream(): StreamInterface
25
    {
26
        return new ConcatenatedStream([
0 ignored issues
show
Documentation introduced by
array(new \Genkgo\Mail\S... $this->createStream()) is of type array<integer,object<Gen...il\\StreamInterface>"}>, but the function expects a object<Genkgo\Mail\Stream\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
            new StringStream((string)$this->getTag() . ' '),
28
            $this->createStream()
29
        ]);
30
    }
31
}
32