Merge branch '5.1' into 5.2

* 5.1:
  Fix merge.
  fix lexing mapping values with trailing whitespaces
  [String] Fix Notice when argument is empty string
  [Inflector] Fix Notice when argument is empty string
  Fix small typos
This commit is contained in:
Alexander M. Turek 2020-12-02 09:39:23 +01:00
commit 56e79395c4
7 changed files with 39 additions and 6 deletions

View File

@ -10,8 +10,8 @@ CHANGELOG
5.0.0
-----
* Added argument `$selector` to ``Crawler::children()`
* Added argument `$default` to ``Crawler::text()` and `html()`
* Added argument `$selector` to `Crawler::children()`
* Added argument `$default` to `Crawler::text()` and `html()`
4.4.0
-----

View File

@ -323,4 +323,16 @@ class InflectorTest extends TestCase
$this->assertEquals($expectedPlural, $plural);
}
public function testPluralizeEmptyString()
{
$plural = Inflector::pluralize('');
$this->assertSame('', $plural);
}
public function testSingularizeEmptyString()
{
$singular = Inflector::singularize('');
$this->assertSame('', $singular);
}
}

View File

@ -25,7 +25,7 @@
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1",
"symfony/string": "^5.1"
"symfony/string": "~5.1.10|^5.2.1"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Inflector\\": "" },

View File

@ -305,6 +305,7 @@ final class EnglishInflector implements InflectorInterface
* A list of words which should not be inflected, reversed.
*/
private static $uninflected = [
'',
'atad',
'reed',
'kcabdeef',

View File

@ -306,4 +306,16 @@ class EnglishInflectorTest extends TestCase
{
$this->assertSame(\is_array($plural) ? $plural : [$plural], (new EnglishInflector())->pluralize($singular));
}
public function testPluralizeEmptyString()
{
$plural = (new EnglishInflector())->pluralize('');
$this->assertSame([''], $plural);
}
public function testSingularizeEmptyString()
{
$singular = (new EnglishInflector())->singularize('');
$this->assertSame([''], $singular);
}
}

View File

@ -761,10 +761,10 @@ class Parser
switch ($value[0] ?? '') {
case '"':
case "'":
$cursor = \strlen($this->currentLine) - \strlen($value);
$cursor = \strlen(rtrim($this->currentLine)) - \strlen(rtrim($value));
$parsedValue = Inline::parse($this->lexInlineQuotedString($cursor), $flags, $this->refs);
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*#.*$/A', '', substr($this->currentLine, $cursor))) {
if (isset($this->currentLine[$cursor]) && preg_replace('/\s*(#.*)?$/A', '', substr($this->currentLine, $cursor))) {
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($this->currentLine, $cursor)));
}

View File

@ -2670,7 +2670,7 @@ YAML;
);
}
public function testMultipleWhitespaceAtEndOfLine()
public function testWhitespaceAtEndOfLine()
{
$yaml = "\nfoo:\n arguments: [ '@bar' ] \n";
$this->assertSame(
@ -2691,6 +2691,14 @@ YAML;
],
$this->parser->parse($yaml)
);
$this->assertSame(
[
'foo' => 'bar',
'foobar' => 'baz',
],
$this->parser->parse("foo: 'bar' \nfoobar: baz")
);
}
/**