Completed
Push — master ( 7ace69...caa23d )
by Mathieu
01:54 queued 10s
created

tests/Unit/XliffConverterTest.php (1 issue)

mismatching argument types.

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\SymfonyStorage\Tests\Unit;
13
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\Translation\MessageCatalogue;
16
use Translation\SymfonyStorage\XliffConverter;
17
18
/**
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
class XliffConverterTest extends TestCase
22
{
23
    public function testContentToCatalogue()
24
    {
25
        $content = file_get_contents(__DIR__.'/../Fixtures/single-file/messages.en.xlf');
26
        $catalogue = XliffConverter::contentToCatalogue($content, 'en', 'messages');
27
28
        $this->assertEquals('en', $catalogue->getLocale());
29
        $this->assertEquals(['messages'], $catalogue->getDomains());
30
        $this->assertCount(2, $catalogue->all('messages'));
0 ignored issues
show
$catalogue->all('messages') is of type array, but the function expects a object<Countable>|object...nit\Framework\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...
31
    }
32
33
    public function testCatalogueToContent()
34
    {
35
        $catalogue = new MessageCatalogue('en');
36
        $catalogue->add(['foobar' => 'bar']);
37
        $content = XliffConverter::catalogueToContent($catalogue, 'messages');
38
39
        $this->assertRegExp('|foobar|', $content);
40
    }
41
}
42