Skip to content

Commit acef6f9

Browse files
authored
Fix method signature parameter names to match source code (#8181)
* Fix method signature parameter names to match source code - Log methods: $scope → $context (write, emergency, alert, critical, error, warning, notice, info, debug) - Security::hash(): $type → $algorithm - Configure methods: $key → $var/$config (write, read, readOrFail, check, delete, consume, consumeOrFail) - Hash::check(): remove incorrect = null default from required $path parameter - Hash::filter(): change callback default from ['Hash', 'filter'] to null * Add type annotations to method signatures Updates signatures to include full type annotations matching CakePHP 5.x source: - Log: setConfig, drop, write, emergency, alert, critical, error, warning, notice, info, debug - Security: encrypt, decrypt, hash, randomBytes, randomString - Configure: write, read, readOrFail, check, delete, consume, consumeOrFail, config, drop, load, dump, store, restore - Hash: get, extract, insert, remove, combine, format, filter, map, reduce, apply, sort, normalize
1 parent 8166643 commit acef6f9

4 files changed

Lines changed: 43 additions & 43 deletions

File tree

docs/en/core-libraries/hash.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ elements, you can use attribute matching with certain methods. They are `extract
4949

5050
### Hash::get()
5151

52-
`static` Cake\\Utility\\Hash::**get**(array|ArrayAccess $data, $path, $default = null): mixed
52+
`static` Cake\\Utility\\Hash::**get**(ArrayAccess|array $data, array|string|int|null $path, mixed $default = null): mixed
5353

5454
`get()` is a simplified version of `extract()`, it only supports direct
5555
path expressions. Paths with `{n}`, `{s}`, `{*}` or matchers are not
@@ -58,7 +58,7 @@ a matching path is not found the default value will be returned.
5858

5959
### Hash::extract()
6060

61-
`static` Cake\\Utility\\Hash::**extract**(array|ArrayAccess $data, $path): ArrayAccess|array
61+
`static` Cake\\Utility\\Hash::**extract**(ArrayAccess|array $data, string $path): ArrayAccess|array
6262

6363
`Hash::extract()` supports all expression, and matcher components of
6464
[Hash Path Syntax](#hash-path-syntax). You can use extract to retrieve data from arrays
@@ -79,7 +79,7 @@ $results = Hash::extract($users, '{n}.id');
7979
// [1,2,3,4];
8080
```
8181

82-
`static` Hash::**insert**(array $data, $path, $values = null): ArrayAccess|array
82+
`static` Cake\\Utility\\Hash::**insert**(ArrayAccess|array $data, string $path, mixed $values = null): ArrayAccess|array
8383

8484
Inserts `$values` into an array as defined by `$path`:
8585

@@ -130,7 +130,7 @@ $result = Hash::insert($data, '{n}[up].Item[id=4].new', 9);
130130

131131
### Hash::remove()
132132

133-
`static` Cake\\Utility\\Hash::**remove**(array $data, $path): ArrayAccess|array
133+
`static` Cake\\Utility\\Hash::**remove**(ArrayAccess|array $data, string $path): ArrayAccess|array
134134

135135
Removes all elements from an array that match `$path`:
136136

@@ -175,7 +175,7 @@ $result = Hash::remove($data, '{n}[clear].Item[id=4]');
175175

176176
### Hash::combine()
177177

178-
`static` Cake\\Utility\\Hash::**combine**(array $data, $keyPath, $valuePath = null, $groupPath = null): array
178+
`static` Cake\\Utility\\Hash::**combine**(array $data, array|string|null $keyPath, array|string|null $valuePath = null, ?string $groupPath = null): array
179179

180180
Creates an associative array using a `$keyPath` as the path to build its keys,
181181
and optionally `$valuePath` as path to get the values. If `$valuePath` is not
@@ -322,7 +322,7 @@ $result = Hash::combine(
322322

323323
### Hash::format()
324324

325-
`static` Cake\\Utility\\Hash::**format**(array $data, array $paths, $format): array|null
325+
`static` Cake\\Utility\\Hash::**format**(array $data, array $paths, string $format): ?array
326326

327327
Returns a series of values extracted from an array, formatted with a
328328
format string:
@@ -406,7 +406,7 @@ $result = Hash::contains($b, $a);
406406

407407
### Hash::check()
408408

409-
`static` Cake\\Utility\\Hash::**check**(array $data, string $path = null): bool
409+
`static` Cake\\Utility\\Hash::**check**(array $data, string $path): bool
410410

411411
Checks if a particular path is set in an array:
412412

@@ -446,7 +446,7 @@ $result = Hash::check($set, 'My Index 1.First.Seconds.Third.Fourth');
446446

447447
### Hash::filter()
448448

449-
`static` Cake\\Utility\\Hash::**filter**(array $data, $callback = ['Hash', 'filter']): array
449+
`static` Cake\\Utility\\Hash::**filter**(array $data, ?callable $callback = null): array
450450

451451
Filters empty elements out of array, excluding '0'. You can also supply a
452452
custom `$callback` to filter the array elements. The callback should
@@ -658,7 +658,7 @@ $result = Hash::maxDimensions($data);
658658

659659
### Hash::map()
660660

661-
`static` Cake\\Utility\\Hash::**map**(array $data, $path, $function): array
661+
`static` Cake\\Utility\\Hash::**map**(array $data, string $path, callable $function): array
662662

663663
Creates a new array, by extracting `$path`, and mapping `$function`
664664
across the results. You can use both expression and matching elements with
@@ -677,15 +677,15 @@ public function noop(array $array)
677677

678678
### Hash::reduce()
679679

680-
`static` Cake\\Utility\\Hash::**reduce**(array $data, $path, $function): mixed
680+
`static` Cake\\Utility\\Hash::**reduce**(array $data, string $path, callable $function): mixed
681681

682682
Creates a single value, by extracting `$path`, and reducing the extracted
683683
results with `$function`. You can use both expression and matching elements
684684
with this method.
685685

686686
### Hash::apply()
687687

688-
`static` Cake\\Utility\\Hash::**apply**(array $data, $path, $function): mixed
688+
`static` Cake\\Utility\\Hash::**apply**(array $data, string $path, callable $function): mixed
689689

690690
Apply a callback to a set of extracted values using `$function`. The function
691691
will get the extracted values as the first argument:
@@ -707,7 +707,7 @@ $result = Hash::apply($data, '{n}[booked=true].date', 'array_count_values');
707707

708708
### Hash::sort()
709709

710-
`static` Cake\\Utility\\Hash::**sort**(array $data, $path, $dir, $type = 'regular'): array
710+
`static` Cake\\Utility\\Hash::**sort**(array $data, string $path, string|int $dir = 'asc', array|string $type = 'regular'): array
711711

712712
Sorts an array by any value, determined by a [Hash Path Syntax](#hash-path-syntax)
713713
Only expression elements are supported by this method:
@@ -820,7 +820,7 @@ $res = Hash::mergeDiff($array1, $array2);
820820

821821
### Hash::normalize()
822822

823-
`static` Cake\\Utility\\Hash::**normalize**(array $data, $assoc = true, $default = null): array
823+
`static` Cake\\Utility\\Hash::**normalize**(array $data, bool $assoc = true, mixed $default = null): array
824824

825825
Normalizes an array. If `$assoc` is `true`, the resulting array will be
826826
normalized to be an associative array. Numeric keys with values, will be

docs/en/core-libraries/logging.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ configured.
450450

451451
### Log::setConfig()
452452

453-
`static` Cake\\Log\\Log::**setConfig**($key, $config): void
453+
`static` Cake\\Log\\Log::**setConfig**(array|string $key, $config = null): void
454454

455455
param string \$name
456456
Name for the logger being connected, used
@@ -474,20 +474,20 @@ Get the names of the configured loggers.
474474

475475
### Log::drop()
476476

477-
`static` Cake\\Log\\Log::**drop**($name): bool
477+
`static` Cake\\Log\\Log::**drop**(string $name): bool
478478

479479
param string \$name
480480
Name of the logger you wish to no longer receive
481481
messages.
482482

483483
### Log::write()
484484

485-
`static` Cake\\Log\\Log::**write**($level, $message, $scope = []): bool
485+
`static` Cake\\Log\\Log::**write**(string|int $level, Stringable|string $message, array|string $context = []): bool
486486

487487
Write a message into all the configured loggers.
488488
`$level` indicates the level of log message being created.
489489
`$message` is the message of the log entry being written to.
490-
`$scope` is the scope(s) a log message is being created in.
490+
`$context` is the scope(s) a log message is being created in.
491491

492492
### Log::levels()
493493

@@ -503,35 +503,35 @@ appropriate log level.
503503

504504
#### Log::emergency()
505505

506-
`static` Cake\\Log\\Log::**emergency**($message, $scope = []): bool
506+
`static` Cake\\Log\\Log::**emergency**(Stringable|string $message, array|string $context = []): bool
507507

508508
#### Log::alert()
509509

510-
`static` Cake\\Log\\Log::**alert**($message, $scope = []): bool
510+
`static` Cake\\Log\\Log::**alert**(Stringable|string $message, array|string $context = []): bool
511511

512512
#### Log::critical()
513513

514-
`static` Cake\\Log\\Log::**critical**($message, $scope = []): bool
514+
`static` Cake\\Log\\Log::**critical**(Stringable|string $message, array|string $context = []): bool
515515

516516
#### Log::error()
517517

518-
`static` Cake\\Log\\Log::**error**($message, $scope = []): bool
518+
`static` Cake\\Log\\Log::**error**(Stringable|string $message, array|string $context = []): bool
519519

520520
#### Log::warning()
521521

522-
`static` Cake\\Log\\Log::**warning**($message, $scope = []): bool
522+
`static` Cake\\Log\\Log::**warning**(Stringable|string $message, array|string $context = []): bool
523523

524524
#### Log::notice()
525525

526-
`static` Cake\\Log\\Log::**notice**($message, $scope = []): bool
526+
`static` Cake\\Log\\Log::**notice**(Stringable|string $message, array|string $context = []): bool
527527

528528
#### Log::info()
529529

530-
`static` Cake\\Log\\Log::**info**($message, $scope = []): bool
530+
`static` Cake\\Log\\Log::**info**(Stringable|string $message, array|string $context = []): bool
531531

532532
#### Log::debug()
533533

534-
`static` Cake\\Log\\Log::**debug**($message, $scope = []): bool
534+
`static` Cake\\Log\\Log::**debug**(Stringable|string $message, array|string $context = []): bool
535535

536536
## Logging Trait
537537

docs/en/core-libraries/security.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ hashing and encrypting data.
1010

1111
### Security::encrypt()
1212

13-
`static` Cake\\Utility\\Security::**encrypt**($text, $key, $hmacSalt = null): string
13+
`static` Cake\\Utility\\Security::**encrypt**(string $plain, string $key, ?string $hmacSalt = null): string
1414

1515
### Security::decrypt()
1616

17-
`static` Cake\\Utility\\Security::**decrypt**($cipher, $key, $hmacSalt = null): string|null
17+
`static` Cake\\Utility\\Security::**decrypt**(string $cipher, string $key, ?string $hmacSalt = null): ?string
1818

1919
Encrypt `$text` using AES-256. The `$key` should be a value with a
2020
lots of variance in the data much like a good password. The returned result
@@ -57,7 +57,7 @@ If the value cannot be decrypted due to changes in the key or HMAC salt
5757

5858
### Security::hash()
5959

60-
`static` Cake\\Utility\\Security::**hash**( $string, $type = NULL, $salt = false ): string
60+
`static` Cake\\Utility\\Security::**hash**(string $string, ?string $algorithm = null, string|bool $salt = false): string
6161

6262
Create a hash from string using given method. Fallback on next
6363
available method. If `$salt` is set to `true`, the application's salt
@@ -91,7 +91,7 @@ And any other hash algorithm that PHP's `hash()` function supports.
9191

9292
### Security::randomBytes()
9393

94-
`static` Cake\\Utility\\Security::**randomBytes**($length): string
94+
`static` Cake\\Utility\\Security::**randomBytes**(int $length): string
9595

9696
Get `$length` number of bytes from a secure random source. This function draws
9797
data from one of the following sources:
@@ -104,7 +104,7 @@ will be used for backwards compatibility reasons.
104104

105105
### Security::randomString()
106106

107-
`static` Cake\\Utility\\Security::**randomString**($length): string
107+
`static` Cake\\Utility\\Security::**randomString**(int $length = 64): string
108108

109109
Get a random string `$length` long from a secure random source. This method
110110
draws from the same random source as `randomBytes()` and will encode the data

docs/en/development/configuration.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ won't end up breaking the MVC structure CakePHP provides.
319319

320320
### Writing Configuration data
321321

322-
`static` Cake\\Core\\Configure::**write**($key, $value): void
322+
`static` Cake\\Core\\Configure::**write**(array|string $config, mixed $value = null): void
323323

324324
Use `write()` to store data in the application's configuration:
325325

@@ -350,7 +350,7 @@ production modes on the fly.
350350
351351
### Reading Configuration Data
352352

353-
`static` Cake\\Core\\Configure::**read**($key = null, $default = null): mixed
353+
`static` Cake\\Core\\Configure::**read**(?string $var = null, mixed $default = null): mixed
354354

355355
Used to read configuration data from the application. If a key is supplied, the
356356
data is returned. Using our examples from write() above, we can read that data
@@ -373,7 +373,7 @@ Configure::read('Company.nope', 'fallback');
373373

374374
If `$key` is left null, all values in Configure will be returned.
375375

376-
`static` Cake\\Core\\Configure::**readOrFail**($key): mixed
376+
`static` Cake\\Core\\Configure::**readOrFail**(string $var): mixed
377377

378378
Reads configuration data just like `Cake\Core\Configure::read()`
379379
but expects to find a key/value pair. In case the requested pair does not
@@ -391,7 +391,7 @@ Configure::readOrFail('Company');
391391

392392
### Checking to see if Configuration Data is Defined
393393

394-
`static` Cake\\Core\\Configure::**check**($key): bool
394+
`static` Cake\\Core\\Configure::**check**(string $var): bool
395395

396396
Used to check if a key/path exists and has non-null value:
397397

@@ -401,7 +401,7 @@ $exists = Configure::check('Company.name');
401401

402402
### Deleting Configuration Data
403403

404-
`static` Cake\\Core\\Configure::**delete**($key): void
404+
`static` Cake\\Core\\Configure::**delete**(string $var): void
405405

406406
Used to delete information from the application's configuration:
407407

@@ -411,12 +411,12 @@ Configure::delete('Company.name');
411411

412412
### Reading & Deleting Configuration Data
413413

414-
`static` Cake\\Core\\Configure::**consume**($key): mixed
414+
`static` Cake\\Core\\Configure::**consume**(string $var): mixed
415415

416416
Read and delete a key from Configure. This is useful when you want to
417417
combine reading and deleting values in a single operation.
418418

419-
`static` Cake\\Core\\Configure::**consumeOrFail**($key): mixed
419+
`static` Cake\\Core\\Configure::**consumeOrFail**(string $var): mixed
420420

421421
Consumes configuration data just like `Cake\Core\Configure::consume()`
422422
but expects to find a key/value pair. In case the requested pair does not
@@ -434,7 +434,7 @@ Configure::consumeOrFail('Company');
434434

435435
## Reading and writing configuration files
436436

437-
`static` Cake\\Core\\Configure::**setConfig**($name, $engine)
437+
`static` Cake\\Core\\Configure::**config**(string $name, ConfigEngineInterface $engine): void
438438

439439
CakePHP comes with two built-in configuration file engines.
440440
`Cake\Core\Configure\Engine\PhpConfig` is able to read PHP config
@@ -467,7 +467,7 @@ Configure::configured();
467467
Configure::configured('default');
468468
```
469469

470-
`static` Cake\\Core\\Configure::**drop**($name): bool
470+
`static` Cake\\Core\\Configure::**drop**(string $name): bool
471471

472472
You can also remove attached engines. `Configure::drop('default')`
473473
would remove the default engine alias. Any future attempts to load configuration
@@ -481,7 +481,7 @@ Configure::drop('default');
481481

482482
### Loading Configuration Files
483483

484-
`static` Cake\\Core\\Configure::**load**($key, $config = 'default', $merge = true): bool
484+
`static` Cake\\Core\\Configure::**load**(string $key, string $config = 'default', bool $merge = true): bool
485485

486486
Once you've attached a config engine to Configure you can load configuration
487487
files:
@@ -522,7 +522,7 @@ will not ever overwrite the existing configuration.
522522
523523
### Creating or Modifying Configuration Files
524524
525-
`static` Cake\\Core\\Configure::**dump**($key, $config = 'default', $keys = []): bool
525+
`static` Cake\\Core\\Configure::**dump**(string $key, string $config = 'default', array $keys = []): bool
526526
527527
Dumps all or some of the data in Configure into a file or storage system
528528
supported by a config engine. The serialization format is decided by the config
@@ -549,7 +549,7 @@ configuration files that are readable with `Configure::load()`
549549

550550
### Storing Runtime Configuration
551551

552-
`static` Cake\\Core\\Configure::**store**($name, $cacheConfig = 'default', $data = null): bool
552+
`static` Cake\\Core\\Configure::**store**(string $name, string $cacheConfig = 'default', ?array $data = null): bool
553553

554554
You can also store runtime configuration values for use in a future request.
555555
Since configure only remembers values for the current request, you will
@@ -566,7 +566,7 @@ Stored configuration data is persisted in the named cache configuration. See the
566566

567567
### Restoring Runtime Configuration
568568

569-
`static` Cake\\Core\\Configure::**restore**($name, $cacheConfig = 'default'): bool
569+
`static` Cake\\Core\\Configure::**restore**(string $name, string $cacheConfig = 'default'): bool
570570

571571
Once you've stored runtime configuration, you'll probably need to restore it
572572
so you can access it again. `Configure::restore()` does exactly that:

0 commit comments

Comments
 (0)