Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 782ee5d

Browse filesBrowse 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
Copy full SHA for 782ee5d

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed

‎src/Symfony/Component/Inflector/Inflector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Inflector/Inflector.php
+1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Inflector/Tests/InflectorTest.php
+12Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.