8000 bug #39270 [Inflector] Fix Notice when argument is empty string (mold… · symfony/symfony@782ee5d · GitHub
[go: up one dir, main page]

Skip to content

Commit 782ee5d

Browse files
committed
bug #39270 [Inflector] Fix Notice when argument is empty string (moldman)
This PR was merged into the 4.4 branch. Discussion ---------- [Inflector] Fix Notice when argument is empty string | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | License | MIT Fixing issue when we call `Inflector` with empty string: ``` \Symfony\Component\Inflector\Inflector::singularize(''); ``` ``` Notice: Uninitialized string offset: 0 in src/Symfony/Component/Inflector/Inflector.php on line 363 PHP Notice: Uninitialized string offset: 0 in src/Symfony/Component/Inflector/Inflector.php on line 363 ... Notice: Uninitialized string offset: 0 in src/Symfony/Component/Inflector/Inflector.php on line 363 PHP Notice: Uninitialized string offset: 0 in src/Symfony/Component/Inflector/Inflector.php on line 363 ``` Fix for 5.1 #39244 Commits ------- 2dfe342 [Inflector] Fix Notice when argument is empty string
2 parents 27127a4 + 2dfe342 commit 782ee5d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Symfony/Component/Inflector/Inflector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ final class Inflector
310310
* A list of words which should not be inflected, reversed.
311311
*/
312312
private static $uninflected = [
313+
'',
313314
'atad',
314315
'reed',
315316
'kcabdeef',

src/Symfony/Component/Inflector/Tests/InflectorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,16 @@ public function testPluralize($singular, $expectedPlural)
320320

321321
$this->assertEquals($expectedPlural, $plural);
322322
}
323+
324+
public function testPluralizeEmptyString()
325+
{
326+
$plural = Inflector::pluralize('');
327+
$this->assertSame('', $plural);
328+
}
329+
330+
public function testSingularizeEmptyString()
331+
{
332+
$singular = Inflector::singularize('');
333+
$this->assertSame('', $singular);
334+
}
323335
}

0 commit comments

Comments
 (0)
0