Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.23.1 into 2.24.x #107

Merged
merged 4 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
[![Build Status](https://github.com/laminas/laminas-i18n/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-i18n/actions?query=workflow%3A"Continuous+Integration")

> ## 🇷🇺 Русским гражданам
>
>
> Мы, участники Laminas, родились и живем в разных странах. У многих из нас есть друзья, родственники и коллеги как в России, так и в Украине. Некоторые из нас родились в России. Некоторые из нас живут в России. У некоторых бабушки и дедушки сражались с фашистами во Второй мировой войне. Здесь никто не поддерживает фашизм.
>
>
> У одного из нас есть украинская родственница, которая спаслась из дома вместе с сыном. Поезд задержался из-за бомбежки на дороге впереди. У нас есть друзья, которые прячутся в бомбоубежищах. Мы с тревогой ждем весточки от них после воздушных налетов, которые беспорядочно наносят удары и попадают по больницам, школам, детским садам и домам. Мы не берем это из каких-либо СМИ. Мы наблюдаем это напрямую.
>
>
> Вы доверяете нам достаточно, чтоб использовать наши программы, и мы просим вас довериться нам вновь. Мы нуждаемся в помощи. Выходите и протестуйте против этой бесполезной войны. Остановите кровопролитие. Скажите "Нет войне!"
>
>
> ## 🇺🇸 To Citizens of Russia
>
>
> We at Laminas come from all over the world. Many of us have friends, family and colleagues in both Russia and Ukraine. Some of us were born in Russia. Some of us currently live in Russia. Some have grandparents who fought Nazis in World War II. Nobody here supports fascism.
>
>
> One team member has a Ukrainian relative who fled her home with her son. The train was delayed due to bombing on the road ahead. We have friends who are hiding in bomb shelters. We anxiously follow up on them after the air raids, which indiscriminately fire at hospitals, schools, kindergartens and houses. We're not taking this from any media. These are our actual experiences.
>
>
> You trust us enough to use our software. We ask that you trust us to say the truth on this. We need your help. Go out and protest this unnecessary war. Stop the bloodshed. Say "stop the war!"

`Laminas\I18n` comes with a complete translation suite which supports all major
Expand Down
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
</MoreSpecificImplementedParamType>
</file>
<file src="src/Filter/NumberParse.php">
<MixedArgument>
<code>$value</code>
</MixedArgument>
<RedundantCastGivenDocblockType>
<code>(int) $style</code>
<code>(int) $type</code>
Expand Down Expand Up @@ -773,6 +770,7 @@
<file src="test/Filter/NumberParseTest.php">
<PossiblyUnusedMethod>
<code>formattedToNumberProvider</code>
<code>formatNonNumberProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="test/TestAsset/ModuleEventInterface.php">
Expand Down
6 changes: 6 additions & 0 deletions src/Filter/NumberParse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

use function intl_get_error_message;
use function is_array;
use function is_bool;
use function is_float;
use function is_int;
use function is_scalar;
use function iterator_to_array;

/**
Expand Down Expand Up @@ -149,6 +151,10 @@ public function getFormatter()
*/
public function filter($value)
{
if (! is_scalar($value) || is_bool($value)) {
return $value;
}

if (
! is_int($value)
&& ! is_float($value)
Expand Down
33 changes: 33 additions & 0 deletions test/Filter/NumberParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use LaminasTest\I18n\TestCase;
use NumberFormatter;
use PHPUnit\Framework\Attributes\DataProvider;
use stdClass;

class NumberParseTest extends TestCase
{
Expand Down Expand Up @@ -68,6 +69,38 @@ public static function formattedToNumberProvider(): array
];
}

#[DataProvider('formatNonNumberProvider')]
public function testFormattedWithNonNumbers(
mixed $value,
mixed $expected
): void {
$filter = new NumberParseFilter('en_US', NumberFormatter::DEFAULT_STYLE, NumberFormatter::TYPE_DOUBLE);
self::assertEquals($expected, $filter->filter($value));
}

/** @return array<array-key, array{0: mixed, 1: mixed}> */
public static function formatNonNumberProvider(): array
{
return [
[
null,
null,
],
[
[],
[],
],
[
new stdClass(),
new stdClass(),
],
[
false,
false,
],
];
}

public function testTheNumberFormatterCanBeManuallyInjected(): void
{
$formatter = new NumberFormatter('en_US', NumberFormatter::DEFAULT_STYLE);
Expand Down