Skip to content

Commit

Permalink
[10.x] Backport 11.x PHP 8.4 fix for str_getcsv deprecation (#54074)
Browse files Browse the repository at this point in the history
* Backport 11.x PHP 8.4 compat fix to str_getcsv

* Fix indent
  • Loading branch information
aka-tpayne authored Jan 6, 2025
1 parent 9cc32b5 commit eacb494
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/ValidationRuleParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ protected static function parseStringRule($rule)
*/
protected static function parseParameters($rule, $parameter)
{
return static::ruleIsRegex($rule) ? [$parameter] : str_getcsv($parameter);
return static::ruleIsRegex($rule) ? [$parameter] : str_getcsv($parameter, escape: '\\');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Validation/ValidationUniqueRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
$rule->ignore('Taylor, Otwell"\'..-"', 'id_column');
$rule->where('foo', 'bar');
$this->assertSame('unique:table,column,"Taylor, Otwell\"\\\'..-\"",id_column,foo,"bar"', (string) $rule);
$this->assertSame('Taylor, Otwell"\'..-"', stripslashes(str_getcsv('table,column,"Taylor, Otwell\"\\\'..-\"",id_column,foo,"bar"')[2]));
$this->assertSame('id_column', stripslashes(str_getcsv('table,column,"Taylor, Otwell\"\\\'..-\"",id_column,foo,"bar"')[3]));
$this->assertSame('Taylor, Otwell"\'..-"', stripslashes(str_getcsv('table,column,"Taylor, Otwell\"\\\'..-\"",id_column,foo,"bar"', escape: '\\')[2]));
$this->assertSame('id_column', stripslashes(str_getcsv('table,column,"Taylor, Otwell\"\\\'..-\"",id_column,foo,"bar"', escape: '\\')[3]));

$rule = new Unique('table', 'column');
$rule->ignore(null, 'id_column');
Expand Down

0 comments on commit eacb494

Please sign in to comment.