Skip to content

Commit 2d13303

Browse files
committed
fix conflicts
2 parents 93e3a68 + c666f89 commit 2d13303

20 files changed

+202
-38
lines changed

src/Illuminate/Collections/Traits/EnumeratesValues.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function value($key, $default = null)
342342
*
343343
* @template TEnsureOfType
344344
*
345-
* @param class-string<TEnsureOfType>|array<array-key, class-string<TEnsureOfType>> $type
345+
* @param class-string<TEnsureOfType>|array<array-key, class-string<TEnsureOfType>>|scalar|'array'|'null' $type
346346
* @return static<TKey, TEnsureOfType>
347347
*
348348
* @throws \UnexpectedValueException

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static function inferBasePath()
257257
isset($_ENV['APP_BASE_PATH']) => $_ENV['APP_BASE_PATH'],
258258
default => dirname(array_values(array_filter(
259259
array_keys(ClassLoader::getRegisteredLoaders()),
260-
fn ($path) => ! str_contains($path, '/vendor/'),
260+
fn ($path) => ! str_starts_with($path, 'phar://'),
261261
))[0]),
262262
};
263263
}

src/Illuminate/Validation/Validator.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ class Validator implements ValidatorContract
307307
protected $defaultNumericRules = ['Numeric', 'Integer', 'Decimal'];
308308

309309
/**
310-
* The current placeholder for dots in rule keys.
310+
* The current random hash for the validator.
311311
*
312312
* @var string
313313
*/
314-
protected $dotPlaceholder;
314+
protected static $placeholderHash;
315315

316316
/**
317317
* The exception to throw upon failure.
@@ -344,7 +344,9 @@ public function __construct(
344344
array $messages = [],
345345
array $attributes = [],
346346
) {
347-
$this->dotPlaceholder = Str::random();
347+
if (! isset(static::$placeholderHash)) {
348+
static::$placeholderHash = Str::random();
349+
}
348350

349351
$this->initialRules = $rules;
350352
$this->translator = $translator;
@@ -372,7 +374,7 @@ public function parseData(array $data)
372374

373375
$key = str_replace(
374376
['.', '*'],
375-
[$this->dotPlaceholder, '__asterisk__'],
377+
['__dot__'.static::$placeholderHash, '__asterisk__'.static::$placeholderHash],
376378
$key
377379
);
378380

@@ -410,7 +412,7 @@ protected function replacePlaceholders($data)
410412
protected function replacePlaceholderInString(string $value)
411413
{
412414
return str_replace(
413-
[$this->dotPlaceholder, '__asterisk__'],
415+
['__dot__'.static::$placeholderHash, '__asterisk__'.static::$placeholderHash],
414416
['.', '*'],
415417
$value
416418
);
@@ -425,7 +427,7 @@ protected function replacePlaceholderInString(string $value)
425427
protected function replaceDotPlaceholderInParameters(array $parameters)
426428
{
427429
return array_map(function ($field) {
428-
return str_replace($this->dotPlaceholder, '.', $field);
430+
return str_replace('__dot__'.static::$placeholderHash, '.', $field);
429431
}, $parameters);
430432
}
431433

@@ -746,7 +748,7 @@ protected function getPrimaryAttribute($attribute)
746748
protected function replaceDotInParameters(array $parameters)
747749
{
748750
return array_map(function ($field) {
749-
return str_replace('\.', $this->dotPlaceholder, $field);
751+
return str_replace('\.', '__dot__'.static::$placeholderHash, $field);
750752
}, $parameters);
751753
}
752754

@@ -872,11 +874,24 @@ protected function hasNotFailedPreviousRuleIfPresenceRule($rule, $attribute)
872874
*/
873875
protected function validateUsingCustomRule($attribute, $value, $rule)
874876
{
875-
$attribute = $this->replacePlaceholderInString($attribute);
877+
$originalAttribute = $this->replacePlaceholderInString($attribute);
878+
879+
$attribute = match (true) {
880+
$rule instanceof Rules\Email => $attribute,
881+
$rule instanceof Rules\File => $attribute,
882+
$rule instanceof Rules\Password => $attribute,
883+
default => $originalAttribute,
884+
};
876885

877886
$value = is_array($value) ? $this->replacePlaceholders($value) : $value;
878887

879888
if ($rule instanceof ValidatorAwareRule) {
889+
if ($attribute !== $originalAttribute) {
890+
$this->addCustomAttributes([
891+
$attribute => $this->customAttributes[$originalAttribute] ?? $originalAttribute,
892+
]);
893+
}
894+
880895
$rule->setValidator($this);
881896
}
882897

@@ -889,14 +904,14 @@ protected function validateUsingCustomRule($attribute, $value, $rule)
889904
get_class($rule->invokable()) :
890905
get_class($rule);
891906

892-
$this->failedRules[$attribute][$ruleClass] = [];
907+
$this->failedRules[$originalAttribute][$ruleClass] = [];
893908

894-
$messages = $this->getFromLocalArray($attribute, $ruleClass) ?? $rule->message();
909+
$messages = $this->getFromLocalArray($originalAttribute, $ruleClass) ?? $rule->message();
895910

896911
$messages = $messages ? (array) $messages : [$ruleClass];
897912

898913
foreach ($messages as $key => $message) {
899-
$key = is_string($key) ? $key : $attribute;
914+
$key = is_string($key) ? $key : $originalAttribute;
900915

901916
$this->messages->add($key, $this->makeReplacements(
902917
$message, $key, $ruleClass, []
@@ -1189,7 +1204,7 @@ public function getRulesWithoutPlaceholders()
11891204
{
11901205
return (new Collection($this->rules))
11911206
->mapWithKeys(fn ($value, $key) => [
1192-
str_replace($this->dotPlaceholder, '\\.', $key) => $value,
1207+
str_replace('__dot__'.static::$placeholderHash, '\\.', $key) => $value,
11931208
])
11941209
->all();
11951210
}
@@ -1203,7 +1218,7 @@ public function getRulesWithoutPlaceholders()
12031218
public function setRules(array $rules)
12041219
{
12051220
$rules = (new Collection($rules))->mapWithKeys(function ($value, $key) {
1206-
return [str_replace('\.', $this->dotPlaceholder, $key) => $value];
1221+
return [str_replace('\.', '__dot__'.static::$placeholderHash, $key) => $value];
12071222
})->toArray();
12081223

12091224
$this->initialRules = $rules;

tests/Integration/Cache/DynamoDbStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testLocksCanBeAcquired()
6565
* @param \Illuminate\Foundation\Application $app
6666
* @return void
6767
*/
68-
protected function getEnvironmentSetUp($app)
68+
protected function defineEnvironment($app)
6969
{
7070
if (! env('DYNAMODB_CACHE_TABLE')) {
7171
$this->markTestSkipped('DynamoDB not configured.');

tests/Integration/Cookie/CookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function test_cookie_is_sent_back_with_proper_expire_time_with_respect_to
4242
$this->assertEquals(Carbon::now()->getTimestamp() + 60, $response->headers->getCookies()[1]->getExpiresTime());
4343
}
4444

45-
protected function getEnvironmentSetUp($app)
45+
protected function defineEnvironment($app)
4646
{
4747
$app->instance(
4848
ExceptionHandler::class,

tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function setUp(): void
3232
}
3333
}
3434

35-
protected function getEnvironmentSetUp($app)
35+
protected function defineEnvironment($app)
3636
{
3737
$connection = $app->make('config')->get('database.default');
3838

tests/Integration/Database/MariaDb/DatabaseEmulatePreparesMariaDbConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#[RequiresPhpExtension('pdo_mysql')]
1111
class DatabaseEmulatePreparesMariaDbConnectionTest extends DatabaseMariaDbConnectionTest
1212
{
13-
protected function getEnvironmentSetUp($app)
13+
protected function defineEnvironment($app)
1414
{
15-
parent::getEnvironmentSetUp($app);
15+
parent::defineEnvironment($app);
1616

1717
$app['config']->set('database.connections.mariadb.options', [
1818
PDO::ATTR_EMULATE_PREPARES => true,

tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#[RequiresPhpExtension('pdo_mysql')]
1111
class DatabaseEmulatePreparesMySqlConnectionTest extends DatabaseMySqlConnectionTest
1212
{
13-
protected function getEnvironmentSetUp($app)
13+
protected function defineEnvironment($app)
1414
{
15-
parent::getEnvironmentSetUp($app);
15+
parent::defineEnvironment($app);
1616

1717
$app['config']->set('database.connections.mysql.options', [
1818
PDO::ATTR_EMULATE_PREPARES => true,

tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#[RequiresPhpExtension('pdo_pgsql')]
1414
class PostgresSchemaBuilderTest extends PostgresTestCase
1515
{
16-
protected function getEnvironmentSetUp($app)
16+
protected function defineEnvironment($app)
1717
{
18-
parent::getEnvironmentSetUp($app);
18+
parent::defineEnvironment($app);
1919

2020
$app['config']->set('database.connections.pgsql.search_path', 'public,private');
2121
}

tests/Integration/Mail/SendingMarkdownMailTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class SendingMarkdownMailTest extends TestCase
1414
{
15-
protected function getEnvironmentSetUp($app)
15+
protected function defineEnvironment($app)
1616
{
1717
$app['config']->set('mail.driver', 'array');
1818

0 commit comments

Comments
 (0)