Skip to content

Commit f2f7bdb

Browse files
committed
do not access typed property before initialization
1 parent 360e546 commit f2f7bdb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Symfony/Component/Intl/Tests/Transliterator/EmojiTransliteratorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,18 @@ public function testReverse()
177177
$this->expectException(\IntlException::class);
178178
EmojiTransliterator::create('emoji-en', EmojiTransliterator::REVERSE);
179179
}
180+
181+
public function testGetErrorCodeWithUninitializedTransliterator()
182+
{
183+
$transliterator = EmojiTransliterator::create('emoji-en');
184+
185+
$this->assertSame(0, $transliterator->getErrorCode());
186+
}
187+
188+
public function testGetErrorMessageWithUninitializedTransliterator()
189+
{
190+
$transliterator = EmojiTransliterator::create('emoji-en');
191+
192+
$this->assertFalse($transliterator->getErrorMessage());
193+
}
180194
}

src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public function createInverse(): self
7272

7373
public function getErrorCode(): int|false
7474
{
75-
return $this->transliterator?->getErrorCode() ?? 0;
75+
return isset($this->transliterator) ? $this->transliterator->getErrorCode() : 0;
7676
}
7777

7878
public function getErrorMessage(): string|false
7979
{
80-
return $this->transliterator?->getErrorMessage() ?? false;
80+
return isset($this->transliterator) ? $this->transliterator?->getErrorMessage() : false;
8181
}
8282

8383
public static function listIDs(): array

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy