From 94bf37546f9b5c8baf8908fd213625e00ef45e57 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 29 Jan 2026 03:55:35 +0100 Subject: [PATCH 1/3] Fix PHP coding standards in documentation code snippets - Add missing trailing commas in multi-line arrays (399 fixes) - Fix 2-space and 3-space indentation to 4-space in PHP code blocks - Manual fixes for edge cases (string keys containing '#', odd indent) Blocks inside /* */ comments showing print_r output and non-PHP content are intentionally left untouched. --- docs/en/appendices/glossary.md | 2 +- docs/en/appendices/phpunit-upgrade.md | 2 +- docs/en/console-commands/commands.md | 10 +- docs/en/console-commands/option-parsers.md | 4 +- .../cakephp-coding-conventions.md | 2 +- docs/en/controllers.md | 8 +- docs/en/controllers/components.md | 2 +- docs/en/controllers/middleware.md | 10 +- docs/en/controllers/pagination.md | 12 +- docs/en/controllers/request-response.md | 28 ++--- docs/en/core-libraries/caching.md | 10 +- docs/en/core-libraries/collections.md | 88 ++++++------- docs/en/core-libraries/email.md | 2 +- docs/en/core-libraries/events.md | 12 +- docs/en/core-libraries/form.md | 2 +- docs/en/core-libraries/hash.md | 38 +++--- docs/en/core-libraries/httpclient.md | 52 ++++---- .../internationalization-and-localization.md | 14 +-- docs/en/core-libraries/logging.md | 6 +- docs/en/core-libraries/number.md | 18 +-- docs/en/core-libraries/text.md | 24 ++-- docs/en/core-libraries/time.md | 10 +- docs/en/core-libraries/validation.md | 16 +-- docs/en/core-libraries/xml.md | 4 +- docs/en/development/application.md | 2 +- docs/en/development/configuration.md | 2 +- docs/en/development/debugging.md | 2 +- docs/en/development/dependency-injection.md | 6 +- docs/en/development/errors.md | 4 +- docs/en/development/routing.md | 92 +++++++------- docs/en/development/sessions.md | 14 +-- docs/en/development/testing.md | 116 +++++++++--------- docs/en/intro/conventions.md | 2 +- docs/en/orm/associations.md | 26 ++-- docs/en/orm/behaviors.md | 2 +- docs/en/orm/behaviors/counter-cache.md | 2 +- docs/en/orm/behaviors/timestamp.md | 2 +- docs/en/orm/behaviors/translate.md | 6 +- docs/en/orm/behaviors/tree.md | 6 +- docs/en/orm/database-basics.md | 20 +-- docs/en/orm/entities.md | 12 +- docs/en/orm/query-builder.md | 42 +++---- docs/en/orm/retrieving-data-and-resultsets.md | 20 +-- docs/en/orm/saving-data.md | 46 +++---- docs/en/orm/schema-system.md | 60 ++++----- docs/en/orm/table-objects.md | 6 +- docs/en/orm/validation.md | 66 +++++----- docs/en/security/csrf.md | 2 +- .../cms/authorization.md | 2 +- .../cms/tags-and-users.md | 14 +-- docs/en/views.md | 12 +- docs/en/views/cells.md | 2 +- docs/en/views/helpers.md | 4 +- docs/en/views/helpers/breadcrumbs.md | 16 +-- docs/en/views/helpers/flash.md | 6 +- docs/en/views/helpers/form.md | 52 ++++---- docs/en/views/helpers/html.md | 44 +++---- docs/en/views/helpers/paginator.md | 16 +-- docs/en/views/helpers/time.md | 8 +- docs/en/views/helpers/url.md | 2 +- docs/en/views/json-and-xml-views.md | 4 +- 61 files changed, 558 insertions(+), 558 deletions(-) diff --git a/docs/en/appendices/glossary.md b/docs/en/appendices/glossary.md index 9257399104..f64c29b068 100644 --- a/docs/en/appendices/glossary.md +++ b/docs/en/appendices/glossary.md @@ -37,7 +37,7 @@ Would point to the following value: [ 'Cache' => [ 'default' => [ - 'engine' => 'File' + 'engine' => 'File', ] ] ] diff --git a/docs/en/appendices/phpunit-upgrade.md b/docs/en/appendices/phpunit-upgrade.md index e4670e2cde..3a1035749b 100644 --- a/docs/en/appendices/phpunit-upgrade.md +++ b/docs/en/appendices/phpunit-upgrade.md @@ -58,7 +58,7 @@ should be converted to: ``` php ->with( - ...self::withConsecutive(['firstCallArg'], ['secondCallArg']) + ...self::withConsecutive(['firstCallArg'], ['secondCallArg']), ) ``` diff --git a/docs/en/console-commands/commands.md b/docs/en/console-commands/commands.md index cb7236b48d..b71ec8d6fe 100644 --- a/docs/en/console-commands/commands.md +++ b/docs/en/console-commands/commands.md @@ -173,7 +173,7 @@ class UserCommand extends Command { $parser ->addArgument('name', [ - 'help' => 'What is your name' + 'help' => 'What is your name', ]); return $parser; @@ -392,7 +392,7 @@ class UpdateTableCommand extends Command ->setDescription('My cool console app') ->addArgument('table', [ 'help' => 'Table to update', - 'required' => true + 'required' => true, ]); return $parser; @@ -403,7 +403,7 @@ class UpdateTableCommand extends Command $table = $args->getArgument('table'); $this->fetchTable($table)->updateQuery() ->set([ - 'modified' => new DateTime() + 'modified' => new DateTime(), ]) ->execute(); @@ -492,7 +492,7 @@ class UpdateTableCommand extends Command ->setDescription('My cool console app') ->addArgument('table', [ 'help' => 'Table to update', - 'required' => true + 'required' => true, ]); return $parser; @@ -507,7 +507,7 @@ class UpdateTableCommand extends Command } $this->fetchTable($table)->updateQuery() ->set([ - 'modified' => new DateTime() + 'modified' => new DateTime(), ]) ->execute(); diff --git a/docs/en/console-commands/option-parsers.md b/docs/en/console-commands/option-parsers.md index a3fc362370..2d508a8e90 100644 --- a/docs/en/console-commands/option-parsers.md +++ b/docs/en/console-commands/option-parsers.md @@ -202,7 +202,7 @@ are set to `true`, when they are absent they are set to `false`: ``` php $parser->addOption('verbose', [ 'help' => 'Enable verbose output.', - 'boolean' => true + 'boolean' => true, ]); ``` @@ -228,7 +228,7 @@ public function getOptionParser() 'description' => [ __("Use this command to grant ACL permissions. Once executed, the "), __("ARO specified (and its children, if any) will have ALLOW access "), - __("to the specified ACO action (and the ACO's children, if any).") + __("to the specified ACO action (and the ACO's children, if any)."), ], 'arguments' => [ 'aro' => ['help' => __('ARO to check.'), 'required' => true], diff --git a/docs/en/contributing/cakephp-coding-conventions.md b/docs/en/contributing/cakephp-coding-conventions.md index e3ab8576a5..a325cbdce6 100644 --- a/docs/en/contributing/cakephp-coding-conventions.md +++ b/docs/en/contributing/cakephp-coding-conventions.md @@ -75,7 +75,7 @@ Use this instead: $matches = array_intersect_key( $this->_listeners, array_flip( - preg_grep($matchPattern, array_keys($this->_listeners), 0) + preg_grep($matchPattern, array_keys($this->_listeners), 0), ) ); ``` diff --git a/docs/en/controllers.md b/docs/en/controllers.md index 5a1d6e735b..a62d2a192a 100644 --- a/docs/en/controllers.md +++ b/docs/en/controllers.md @@ -427,9 +427,9 @@ return $this->redirect([ $order->id, '?' => [ 'product' => 'pizza', - 'quantity' => 5 + 'quantity' => 5, ], - '#' => 'top' + '#' => 'top', ]); ``` @@ -438,7 +438,7 @@ Or using a relative or absolute URL: ``` php return $this->redirect('/orders/confirm'); -return $this->redirect('http://www.example.com'); +return $this->redirect('https://www.example.com'); ``` Or to the referer page: @@ -471,7 +471,7 @@ the controller's default one: // In a controller method. $recentArticles = $this->fetchTable('Articles')->find('all', limit: 5, - order: 'Articles.created DESC' + order: 'Articles.created DESC', ) ->all(); ``` diff --git a/docs/en/controllers/components.md b/docs/en/controllers/components.md index 8baeb532c4..379e14a85b 100644 --- a/docs/en/controllers/components.md +++ b/docs/en/controllers/components.md @@ -198,7 +198,7 @@ class SsoComponent extends Component public function __construct( ComponentRegistry $registry, array $config = [], - UserService $users + UserService $users, ) { parent::__construct($registry, $config); $this->users = $users; diff --git a/docs/en/controllers/middleware.md b/docs/en/controllers/middleware.md index 939022c328..5075efa357 100644 --- a/docs/en/controllers/middleware.md +++ b/docs/en/controllers/middleware.md @@ -118,7 +118,7 @@ $middlewareQueue->insertAt(2, $layer); // an exception will be raised. $middlewareQueue->insertBefore( 'Cake\Error\Middleware\ErrorHandlerMiddleware', - $layer + $layer, ); // Insert after another middleware. @@ -126,7 +126,7 @@ $middlewareQueue->insertBefore( // middleware will added to the end. $middlewareQueue->insertAfter( 'Cake\Error\Middleware\ErrorHandlerMiddleware', - $layer + $layer, ); ``` @@ -189,7 +189,7 @@ class TrackingCookieMiddleware implements MiddlewareInterface { public function process( ServerRequestInterface $request, - RequestHandlerInterface $handler + RequestHandlerInterface $handler, ): ResponseInterface { // Calling $handler->handle() delegates control to the *next* middleware @@ -201,7 +201,7 @@ class TrackingCookieMiddleware implements MiddlewareInterface $response = $response->withCookie(new Cookie( 'landing_page', $request->getRequestTarget(), - $expiry + $expiry, )); } @@ -265,7 +265,7 @@ use Cake\Http\Middleware\EncryptedCookieMiddleware; $cookies = new EncryptedCookieMiddleware( // Names of cookies to protect ['secrets', 'protected'], - Configure::read('Security.cookieKey') + Configure::read('Security.cookieKey'), ); $middlewareQueue->add($cookies); diff --git a/docs/en/controllers/pagination.md b/docs/en/controllers/pagination.md index 20c44a1c14..15d7e24bb0 100644 --- a/docs/en/controllers/pagination.md +++ b/docs/en/controllers/pagination.md @@ -79,7 +79,7 @@ class ArticlesController extends AppController $tags = $this->request->getParam('pass'); $customFinderOptions = [ - 'tags' => $tags + 'tags' => $tags, ]; // We're using the $settings argument to paginate() here. // But the same structure could be used in $this->paginate @@ -90,7 +90,7 @@ class ArticlesController extends AppController // public function findTagged(Query $query, array $tagged = []) $settings = [ 'finder' => [ - 'tagged' => $customFinderOptions + 'tagged' => $customFinderOptions, ] ]; $articles = $this->paginate($this->Articles, $settings); @@ -153,7 +153,7 @@ call to the `paginate()` method: // Paginate property protected array $paginate = [ 'Articles' => ['scope' => 'article'], - 'Tags' => ['scope' => 'tag'] + 'Tags' => ['scope' => 'tag'], ]; // In a controller action @@ -197,7 +197,7 @@ $this->paginate = [ $publishedArticles = $this->paginate( $this->Articles->find('all', scope: 'published_articles') - ->where(['published' => true]) + ->where(['published' => true]), ); // Load an additional table object to allow differentiating in the paginator @@ -209,7 +209,7 @@ $unpublishedArticlesTable = $this->fetchTable('UnpublishedArticles', [ $unpublishedArticles = $this->paginate( $unpublishedArticlesTable->find('all', scope: 'unpublished_articles') - ->where(['published' => false]) + ->where(['published' => false]), ); ``` @@ -355,7 +355,7 @@ example reducing it to `10`: ``` php protected array $paginate = [ // Other keys here. - 'maxLimit' => 10 + 'maxLimit' => 10, ]; ``` diff --git a/docs/en/controllers/request-response.md b/docs/en/controllers/request-response.md index 4c0d6b51e3..8122423dcf 100644 --- a/docs/en/controllers/request-response.md +++ b/docs/en/controllers/request-response.md @@ -238,9 +238,9 @@ Returns all uploaded files in a normalized array structure. For the above exampl ``` php [ - 'attachment' => object(Laminas\Diactoros\UploadedFile) { - // ... - } + 'attachment' => object(Laminas\Diactoros\UploadedFile) { + // ... + } ] ``` @@ -258,14 +258,14 @@ $files = [ $size, $errorStatus, $clientFilename, - $clientMediaType + $clientMediaType, ), 'anotherAttachment' => new \Laminas\Diactoros\UploadedFile( '/tmp/hfz6dbn.tmp', 123, \UPLOAD_ERR_OK, 'attachment.txt', - 'text/plain' + 'text/plain', ), ], ]; @@ -411,26 +411,26 @@ Some examples would be: // Add an environment detector. $this->request->addDetector( 'post', - ['env' => 'REQUEST_METHOD', 'value' => 'POST'] + ['env' => 'REQUEST_METHOD', 'value' => 'POST'], ); // Add a pattern value detector. $this->request->addDetector( 'iphone', - ['env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'] + ['env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'], ); // Add an option detector $this->request->addDetector('internalIp', [ 'env' => 'CLIENT_IP', - 'options' => ['192.168.0.101', '192.168.0.100'] + 'options' => ['192.168.0.101', '192.168.0.100'], ]); // Add a header detector with value comparison $this->request->addDetector('fancy', [ 'env' => 'CLIENT_IP', - 'header' => ['X-Fancy' => 1] + 'header' => ['X-Fancy' => 1], ]); // Add a header detector with callable comparison @@ -438,7 +438,7 @@ $this->request->addDetector('fancy', [ 'env' => 'CLIENT_IP', 'header' => ['X-Fancy' => function ($value, $header) { return in_array($value, ['1', '0', 'yes', 'no'], true); - }] + }], ]); // Add a callback detector. Must be a valid callable. @@ -782,7 +782,7 @@ the browser by specifying the options: ``` php $response = $this->response->withFile( $file['path'], - ['download' => true, 'name' => 'foo'] + ['download' => true, 'name' => 'foo'], ); ``` @@ -1149,7 +1149,7 @@ $this->response = $this->response->withCookie(Cookie::create( 'domain' => '', 'secure' => false, 'httponly' => false, - 'samesite' => null // Or one of CookieInterface::SAMESITE_* constants + 'samesite' => null, // Or one of CookieInterface::SAMESITE_* constants ] )); ``` @@ -1273,7 +1273,7 @@ class CorsMiddleware implements MiddlewareInterface { public function process( ServerRequestInterface $request, - RequestHandlerInterface $handler + RequestHandlerInterface $handler, ): ResponseInterface { // Handle preflight requests if ($request->getMethod() === 'OPTIONS') { @@ -1385,7 +1385,7 @@ $cookie = new Cookie( '/', // path, if applicable 'example.com', // domain, if applicable false, // secure only? - true // http only ? + true, // http only ? ); // Using the builder methods diff --git a/docs/en/core-libraries/caching.md b/docs/en/core-libraries/caching.md index 05d331b3fe..0b927b6b00 100644 --- a/docs/en/core-libraries/caching.md +++ b/docs/en/core-libraries/caching.md @@ -97,7 +97,7 @@ Cache::setConfig('short', [ 'className' => 'File', 'duration' => '+1 hours', 'path' => CACHE, - 'prefix' => 'cake_short_' + 'prefix' => 'cake_short_', ]); // Using a fully namespaced name. @@ -261,7 +261,7 @@ Cache::setConfig('redis', [ 'prefix' => 'cake_redis_', 'host' => '127.0.0.1', 'port' => 6379, - 'fallback' => false + 'fallback' => false, ]); ``` @@ -317,7 +317,7 @@ save multiple network connections when using Memcached: ``` php $result = Cache::writeMany([ 'article-' . $slug => $article, - 'article-' . $slug . '-comments' => $comments + 'article-' . $slug . '-comments' => $comments, ]); // $result will contain @@ -429,7 +429,7 @@ CakePHP to use more efficient storage APIs where available. For example using ``` php $result = Cache::readMany([ 'article-' . $slug, - 'article-' . $slug . '-comments' + 'article-' . $slug . '-comments', ]); // $result will contain ['article-first-post' => '...', 'article-first-post-comments' => '...'] @@ -468,7 +468,7 @@ save multiple network connections when using Memcached: ``` php $result = Cache::deleteMany([ 'article-' . $slug, - 'article-' . $slug . '-comments' + 'article-' . $slug . '-comments', ]); // $result will contain ['article-first-post' => true, 'article-first-post-comments' => true] diff --git a/docs/en/core-libraries/collections.md b/docs/en/core-libraries/collections.md index 4876dee2ea..5939ea8cc4 100644 --- a/docs/en/core-libraries/collections.md +++ b/docs/en/core-libraries/collections.md @@ -220,7 +220,7 @@ $result = $combined->toArray(); // $result contains [ 'a' => [1 => 'foo', 3 => 'baz'], - 'b' => [2 => 'bar'] + 'b' => [2 => 'bar'], ]; ``` @@ -232,14 +232,14 @@ instances by the ORM) you may want to group results by date: $combined = (new Collection($entities))->combine( 'id', function ($entity) { return $entity; }, - function ($entity) { return $entity->date->toDateString(); } + function ($entity) { return $entity->date->toDateString(); }, ); - $result = $combined->toArray(); +$result = $combined->toArray(); // $result contains [ 'date string like 2015-05-01' => ['entity1->id' => entity1, 'entity2->id' => entity2, ..., 'entityN->id' => entityN] - 'date string like 2015-06-01' => ['entity1->id' => entity1, 'entity2->id' => entity2, ..., 'entityN->id' => entityN] + 'date string like 2015-06-01' => ['entity1->id' => entity1, 'entity2->id' => entity2, ..., 'entityN->id' => entityN], ] ``` @@ -356,7 +356,7 @@ $collection = new Collection([ 'a' => 1, 'b' => 2, 'c' => 3, - 'd' => [4, 5] + 'd' => [4, 5], ]); $chunked = $collection->chunkWithKeys(2); $result = $chunked->toList(); @@ -364,7 +364,7 @@ $result = $chunked->toList(); // $result contains [ ['a' => 1, 'b' => 2], - ['c' => 3, 'd' => [4, 5]] + ['c' => 3, 'd' => [4, 5]], ] ``` @@ -461,7 +461,7 @@ matching element from a collection, you can use `firstMatch()`: $collection = new Collection($comments); $comment = $collection->firstMatch([ 'user.name' => 'Mark', - 'active' => true + 'active' => true, ]); ``` @@ -570,8 +570,8 @@ for: ``` php $items = [ - ['invoice' => ['total' => 100]], - ['invoice' => ['total' => 200]], + ['invoice' => ['total' => 100]], + ['invoice' => ['total' => 200]], ]; // $average contains 150 @@ -587,11 +587,11 @@ path, or function to extract values to generate the median for: ``` php $items = [ - ['invoice' => ['total' => 400]], - ['invoice' => ['total' => 500]], - ['invoice' => ['total' => 100]], - ['invoice' => ['total' => 333]], - ['invoice' => ['total' => 200]], + ['invoice' => ['total' => 400]], + ['invoice' => ['total' => 500]], + ['invoice' => ['total' => 100]], + ['invoice' => ['total' => 333]], + ['invoice' => ['total' => 200]], ]; // $median contains 333 @@ -612,7 +612,7 @@ $students = [ ['name' => 'Mark', 'grade' => 9], ['name' => 'Andrew', 'grade' => 10], ['name' => 'Stacy', 'grade' => 10], - ['name' => 'Barbara', 'grade' => 9] + ['name' => 'Barbara', 'grade' => 9], ]; $collection = new Collection($students); $studentsByGrade = $collection->groupBy('grade'); @@ -620,14 +620,14 @@ $result = $studentsByGrade->toArray(); // $result contains [ - 10 => [ + 10 => [ ['name' => 'Andrew', 'grade' => 10], - ['name' => 'Stacy', 'grade' => 10] - ], - 9 => [ + ['name' => 'Stacy', 'grade' => 10], + ], + 9 => [ ['name' => 'Mark', 'grade' => 9], - ['name' => 'Barbara', 'grade' => 9] - ] + ['name' => 'Barbara', 'grade' => 9], + ] ] ``` @@ -674,7 +674,7 @@ $usersById = $users->indexBy('id'); [ 1 => 'markstory', 3 => 'jose_zap', - 4 => 'jrbasso' + 4 => 'jrbasso', ] ``` @@ -718,7 +718,7 @@ $result = $rows->toList(); [2013, 1000, 0], [2014, 1500, 500], [2015, 2000, 500], - [2016, 2300, 300] + [2016, 2300, 300], ] ``` @@ -742,7 +742,7 @@ $result = $firstYear->zip($data[0], $data[1])->toList(); // $result contains [ [100, 300, 400], - [200, 500, 600] + [200, 500, 600], ] ``` @@ -891,7 +891,7 @@ $result = $nested->listNested()->toList(); ['id' => 3, 'parent_id' => 1, 'name' => 'Eagle'], ['id' => 4, 'parent_id' => 1, 'name' => 'Seagull'], ['id' => 6, 'parent_id' => null, 'name' => 'Fish', 'children' => [...]], - ['id' => 5, 'parent_id' => 6, 'name' => 'Clown Fish'] + ['id' => 5, 'parent_id' => 6, 'name' => 'Clown Fish'], ] ``` @@ -1180,13 +1180,13 @@ another collection: $users = [ ['username' => 'mark'], ['username' => 'juan'], - ['username' => 'jose'] + ['username' => 'jose'], ]; $languages = [ ['PHP', 'Python', 'Ruby'], ['Bash', 'PHP', 'Javascript'], - ['Javascript', 'Prolog'] + ['Javascript', 'Prolog'], ]; $merged = (new Collection($users))->insert('skills', $languages); @@ -1196,7 +1196,7 @@ $result = $merged->toArray(); [ ['username' => 'mark', 'skills' => ['PHP', 'Python', 'Ruby']], ['username' => 'juan', 'skills' => ['Bash', 'PHP', 'Javascript']], - ['username' => 'jose', 'skills' => ['Javascript', 'Prolog']] + ['username' => 'jose', 'skills' => ['Javascript', 'Prolog']], ]; ``` @@ -1214,7 +1214,7 @@ first one, then the target property will not be present: ``` php $languages = [ ['PHP', 'Python', 'Ruby'], - ['Bash', 'PHP', 'Javascript'] + ['Bash', 'PHP', 'Javascript'], ]; $merged = (new Collection($users))->insert('skills', $languages); @@ -1224,7 +1224,7 @@ $result = $merged->toArray(); [ ['username' => 'mark', 'skills' => ['PHP', 'Python', 'Ruby']], ['username' => 'juan', 'skills' => ['Bash', 'PHP', 'Javascript']], - ['username' => 'jose'] + ['username' => 'jose'], ]; ``` @@ -1296,11 +1296,11 @@ those cases you can use `through()` in combination with a class implementing ``` php $collection - ->map(new ShippingCostCalculator) - ->map(new TotalOrderCalculator) - ->map(new GiftCardPriceReducer) - ->buffered() - ... + ->map(new ShippingCostCalculator) + ->map(new TotalOrderCalculator) + ->map(new GiftCardPriceReducer) + ->buffered() + ... ``` The above method calls can be extracted into a new class so they don't need to @@ -1309,15 +1309,15 @@ be repeated every time: ``` php class FinalCheckOutRowProcessor { - public function __invoke($collection) - { - return $collection - ->map(new ShippingCostCalculator) - ->map(new TotalOrderCalculator) - ->map(new GiftCardPriceReducer) - ->buffered() - ... - } + public function __invoke($collection) + { + return $collection + ->map(new ShippingCostCalculator) + ->map(new TotalOrderCalculator) + ->map(new GiftCardPriceReducer) + ->buffered() + ... + } } // Now you can use the through() method to call all methods at once diff --git a/docs/en/core-libraries/email.md b/docs/en/core-libraries/email.md index 54c7df8a27..4d1e0df7c9 100644 --- a/docs/en/core-libraries/email.md +++ b/docs/en/core-libraries/email.md @@ -501,7 +501,7 @@ TransportFactory::setConfig('gmail', [ 'username' => 'my@gmail.com', 'password' => 'secret', 'className' => 'Smtp', - 'tls' => true + 'tls' => true, ]); ``` diff --git a/docs/en/core-libraries/events.md b/docs/en/core-libraries/events.md index 6c1b953553..e52fa37205 100644 --- a/docs/en/core-libraries/events.md +++ b/docs/en/core-libraries/events.md @@ -61,7 +61,7 @@ class OrdersTable extends Table if ($this->save($order)) { $this->Cart->remove($order); $event = new Event('Order.afterPlace', $this, [ - 'order' => $order + 'order' => $order, ]); $this->getEventManager()->dispatch($event); @@ -107,7 +107,7 @@ use Cake\Event\EventManager; EventManager::instance()->on( 'Order.afterPlace', - $aCallback + $aCallback, ); ``` @@ -331,7 +331,7 @@ use Cake\Log\Log; $this->Orders->getEventManager()->on('Order.afterPlace', function ($event) { Log::write( 'info', - 'A new order was placed with id: ' . $event->getSubject()->id + 'A new order was placed with id: ' . $event->getSubject()->id, ); }); ``` @@ -432,7 +432,7 @@ $callback = [$this, 'doSomething']; $this->getEventManager()->on( 'Order.afterPlace', ['priority' => 2], - $callback + $callback, ); // Setting priority for a listener @@ -443,7 +443,7 @@ class UserStatistic implements EventListenerInterface return [ 'Order.afterPlace' => [ 'callable' => 'updateBuyStatistic', - 'priority' => 100 + 'priority' => 100, ], ]; } @@ -493,7 +493,7 @@ an event: // An event listener has to be instantiated before dispatching an event. // Create a new event and dispatch it. $event = new Event('Order.afterPlace', $this, [ - 'order' => $order + 'order' => $order, ]); $this->getEventManager()->dispatch($event); ``` diff --git a/docs/en/core-libraries/form.md b/docs/en/core-libraries/form.md index 7c1e740fbc..f8286e8c06 100644 --- a/docs/en/core-libraries/form.md +++ b/docs/en/core-libraries/form.md @@ -145,7 +145,7 @@ class ContactController extends AppController if ($this->request->is('get')) { $contact->setData([ 'name' => 'John Doe', - 'email' => 'john.doe@example.com' + 'email' => 'john.doe@example.com', ]); } diff --git a/docs/en/core-libraries/hash.md b/docs/en/core-libraries/hash.md index e94c7d994f..bc17f2e9d1 100644 --- a/docs/en/core-libraries/hash.md +++ b/docs/en/core-libraries/hash.md @@ -85,7 +85,7 @@ Inserts `$values` into an array as defined by `$path`: ``` php $a = [ - 'pages' => ['name' => 'page'] + 'pages' => ['name' => 'page'], ]; $result = Hash::insert($a, 'files', ['name' => 'files']); // $result now looks like: @@ -137,7 +137,7 @@ Removes all elements from an array that match `$path`: ``` php $a = [ 'pages' => ['name' => 'page'], - 'files' => ['name' => 'files'] + 'files' => ['name' => 'files'], ]; $result = Hash::remove($a, 'files'); /* $result now looks like: @@ -191,7 +191,7 @@ $a = [ 'group_id' => 1, 'Data' => [ 'user' => 'mariano.iglesias', - 'name' => 'Mariano Iglesias' + 'name' => 'Mariano Iglesias', ] ] ], @@ -201,7 +201,7 @@ $a = [ 'group_id' => 2, 'Data' => [ 'user' => 'phpnut', - 'name' => 'Larry E. Masters' + 'name' => 'Larry E. Masters', ] ] ], @@ -294,7 +294,7 @@ $result = Hash::combine( $a, '{n}.User.id', ['%s: %s', '{n}.User.Data.user', '{n}.User.Data.name'], - '{n}.User.group_id' + '{n}.User.group_id', ); /* $result now looks like: [ @@ -310,7 +310,7 @@ $result = Hash::combine( $result = Hash::combine( $a, ['%s: %s', '{n}.User.Data.user', '{n}.User.Data.name'], - '{n}.User.id' + '{n}.User.id', ); /* $result now looks like: [ @@ -335,7 +335,7 @@ $data = [ 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', - 'something' => '42' + 'something' => '42', ] ], [ @@ -344,7 +344,7 @@ $data = [ 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', - 'something' => '{0}' + 'something' => '{0}', ] ], [ @@ -353,7 +353,7 @@ $data = [ 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', - 'something' => '{1}' + 'something' => '{1}', ] ] ]; @@ -387,7 +387,7 @@ of another: ``` php $a = [ 0 => ['name' => 'main'], - 1 => ['name' => 'about'] + 1 => ['name' => 'about'], ]; $b = [ 0 => ['name' => 'main'], @@ -412,7 +412,7 @@ Checks if a particular path is set in an array: ``` php $set = [ - 'My Index 1' => ['First' => 'The first item'] + 'My Index 1' => ['First' => 'The first item'], ]; $result = Hash::check($set, 'My Index 1.First'); // $result == true @@ -425,7 +425,7 @@ $set = [ 'First' => [ 'Second' => [ 'Third' => [ - 'Fourth' => 'Heavy. Nesting.' + 'Fourth' => 'Heavy. Nesting.', ] ] ] @@ -458,7 +458,7 @@ $data = [ false, true, 0, - ['one thing', 'I can tell you', 'is you got to be', false] + ['one thing', 'I can tell you', 'is you got to be', false], ]; $res = Hash::filter($data); @@ -694,7 +694,7 @@ will get the extracted values as the first argument: $data = [ ['date' => '01-01-2016', 'booked' => true], ['date' => '01-01-2016', 'booked' => false], - ['date' => '02-01-2016', 'booked' => true] + ['date' => '02-01-2016', 'booked' => true], ]; $result = Hash::apply($data, '{n}[booked=true].date', 'array_count_values'); /* $result now looks like: @@ -715,7 +715,7 @@ Only expression elements are supported by this method: ``` php $a = [ 0 => ['Person' => ['name' => 'Jeff']], - 1 => ['Shirt' => ['color' => 'black']] + 1 => ['Shirt' => ['color' => 'black']], ]; $result = Hash::sort($a, '{n}.Person.name', 'asc'); /* $result now looks like: @@ -752,12 +752,12 @@ Computes the difference between two arrays: ``` php $a = [ 0 => ['name' => 'main'], - 1 => ['name' => 'about'] + 1 => ['name' => 'about'], ]; $b = [ 0 => ['name' => 'main'], 1 => ['name' => 'about'], - 2 => ['name' => 'contact'] + 2 => ['name' => 'contact'], ]; $result = Hash::diff($a, $b); @@ -831,7 +831,7 @@ makes using the results with `Hash::merge()` easier: $a = ['Tree', 'CounterCache', 'Upload' => [ 'folder' => 'products', - 'fields' => ['image_1_id', 'image_2_id'] + 'fields' => ['image_1_id', 'image_2_id'], ] ]; $result = Hash::normalize($a); @@ -904,7 +904,7 @@ $data = [ ['ThreadPost' => ['id' => 7, 'parent_id' => 6]], ['ThreadPost' => ['id' => 8, 'parent_id' => 6]], ['ThreadPost' => ['id' => 9, 'parent_id' => 6]], - ['ThreadPost' => ['id' => 10, 'parent_id' => 6]] + ['ThreadPost' => ['id' => 10, 'parent_id' => 6]], ]; $result = Hash::nest($data, ['root' => 6]); diff --git a/docs/en/core-libraries/httpclient.md b/docs/en/core-libraries/httpclient.md index 85536682e7..3b57c40e7e 100644 --- a/docs/en/core-libraries/httpclient.md +++ b/docs/en/core-libraries/httpclient.md @@ -16,14 +16,14 @@ use Cake\Http\Client; $http = new Client(); // Simple get -$response = $http->get('http://example.com/test.html'); +$response = $http->get('https://example.com/test.html'); // Simple get with querystring -$response = $http->get('http://example.com/search', ['q' => 'widget']); +$response = $http->get('https://example.com/search', ['q' => 'widget']); // Simple get with querystring & additional headers -$response = $http->get('http://example.com/search', ['q' => 'widget'], [ - 'headers' => ['X-Requested-With' => 'XMLHttpRequest'], +$response = $http->get('https://example.com/search', ['q' => 'widget'], [ + 'headers' => ['X-Requested-With' => 'XMLHttpRequest'], ]); ``` @@ -32,15 +32,15 @@ Doing POST and PUT requests is equally simple: ``` php // Send a POST request with application/x-www-form-urlencoded encoded data $http = new Client(); -$response = $http->post('http://example.com/posts/add', [ - 'title' => 'testing', - 'body' => 'content in the post', +$response = $http->post('https://example.com/posts/add', [ + 'title' => 'testing', + 'body' => 'content in the post', ]); // Send a PUT request with application/x-www-form-urlencoded encoded data -$response = $http->put('http://example.com/posts/add', [ - 'title' => 'testing', - 'body' => 'content in the post', +$response = $http->put('https://example.com/posts/add', [ + 'title' => 'testing', + 'body' => 'content in the post', ]); // Other methods as well. @@ -57,8 +57,8 @@ use Cake\Http\Client; use Cake\Http\Client\Request as ClientRequest; $request = new ClientRequest( - 'http://example.com/search', - ClientRequest::METHOD_GET + 'https://example.com/search', + ClientRequest::METHOD_GET, ); $http = new Client(); $response = $http->sendRequest($request); @@ -71,7 +71,7 @@ You can include files in request bodies by including a filehandle in the array: ``` php $http = new Client(); $response = $http->post('http://example.com/api', [ - 'image' => fopen('/path/to/a/file', 'r'), + 'image' => fopen('/path/to/a/file', 'r'), ]); ``` @@ -104,7 +104,7 @@ $file->disposition('attachment'); $response = $http->post( 'http://example.com/api', (string)$data, - ['headers' => ['Content-Type' => $data->contentType()]] + ['headers' => ['Content-Type' => $data->contentType()]], ); ``` @@ -117,9 +117,9 @@ form encoded. Http\Client exposes this through the type option: // Send a JSON request body. $http = new Client(); $response = $http->post( - 'http://example.com/tasks', - json_encode($data), - ['type' => 'json'] + 'http://example.com/tasks', + json_encode($data), + ['type' => 'json'], ); ``` @@ -132,9 +132,9 @@ you can do the following: // Send a JSON body in a GET request with query string parameters. $http = new Client(); $response = $http->get( - 'http://example.com/tasks', - ['q' => 'test', '_content' => json_encode($data)], - ['type' => 'json'] + 'http://example.com/tasks', + ['q' => 'test', '_content' => json_encode($data)], + ['type' => 'json'], ); ``` @@ -183,7 +183,7 @@ An example of basic authentication: ``` php $http = new Client(); $response = $http->get('http://example.com/profile/1', [], [ - 'auth' => ['username' => 'mark', 'password' => 'secret'], + 'auth' => ['username' => 'mark', 'password' => 'secret'], ]); ``` @@ -344,7 +344,7 @@ match: ``` php $http = new Client([ - 'host' => 'cakephp.org' + 'host' => 'cakephp.org', ]); // Do a request that sets some cookies @@ -372,7 +372,7 @@ method: use Cake\Http\Cookie\Cookie; $http = new Client([ - 'host' => 'cakephp.org' + 'host' => 'cakephp.org', ]); $http->addCookie(new Cookie('session', 'abc123')); ``` @@ -517,7 +517,7 @@ $http->getEventManager()->on( \Cake\Http\Client\ClientEvent $event, \Cake\Http\Client\Request $request, array $adapterOptions, - int $redirects + int $redirects, ) { // Modify the request $event->setRequest(....); @@ -543,7 +543,7 @@ $http->getEventManager()->on( array $adapterOptions, int $redirects, bool $requestSent // Indicates whether the request was actually sent - // or response returned from ``beforeSend`` event + // or response returned from ``beforeSend`` event ) { // Get the response $response = $event->getResponse(); @@ -576,7 +576,7 @@ class CartControllerTests extends TestCase // Mock a POST request that will be made. $this->mockClientPost( 'https://example.com/process-payment', - $this->newClientResponse(200, [], json_encode(['ok' => true])) + $this->newClientResponse(200, [], json_encode(['ok' => true])), ); $this->post("/cart/checkout"); // Do assertions. diff --git a/docs/en/core-libraries/internationalization-and-localization.md b/docs/en/core-libraries/internationalization-and-localization.md index 83fbfe82bb..8dca5b92c6 100644 --- a/docs/en/core-libraries/internationalization-and-localization.md +++ b/docs/en/core-libraries/internationalization-and-localization.md @@ -233,7 +233,7 @@ same time: ``` php echo __( 'Hi {0}, your balance on the {1,date} is {2,number,currency}', - ['Charles', new DateTime('2014-01-13 11:12:00'), 1354.37] + ['Charles', new DateTime('2014-01-13 11:12:00'), 1354.37], ); // Returns @@ -246,7 +246,7 @@ output: ``` php echo __( 'You have traveled {0,number} kilometers in {1,number,integer} weeks', - [5423.344, 5.1] + [5423.344, 5.1], ); // Returns @@ -434,7 +434,7 @@ use Cake\I18n\Package; I18n::setTranslator('animals', function () { $package = new Package( 'default', // The formatting strategy (ICU) - 'default' // The fallback domain + 'default', // The fallback domain ); $package->setMessages([ 'Dog' => 'Chien', @@ -471,7 +471,7 @@ use Cake\I18n\MessagesFileLoader as Loader; I18n::setTranslator( 'animals', new Loader('filename', 'folder/sub_folder', 'po'), - 'fr_FR' + 'fr_FR', ); ``` @@ -512,7 +512,7 @@ use Cake\I18n\MessagesFileLoader as Loader; I18n::setTranslator( 'animals', new Loader('animals', 'fr_FR', 'yaml'), - 'fr_FR' + 'fr_FR', ); ``` @@ -540,7 +540,7 @@ I18n::config('default', function ($domain, $locale) { return new Package( 'default', // Formatter null, // Fallback (none for default domain) - json_decode($messages, true) + json_decode($messages, true), ) }); ``` @@ -707,7 +707,7 @@ class DatetimeMiddleware implements MiddlewareInterface { public function process( ServerRequestInterface $request, - RequestHandlerInterface $handler + RequestHandlerInterface $handler, ): ResponseInterface { // Get the user from the request. // This example assumes your user entity has a timezone attribute. diff --git a/docs/en/core-libraries/logging.md b/docs/en/core-libraries/logging.md index 3ad6b69fdf..babd305447 100644 --- a/docs/en/core-libraries/logging.md +++ b/docs/en/core-libraries/logging.md @@ -251,7 +251,7 @@ custom paths to be used: ``` php Log::setConfig('custom_path', [ 'className' => 'File', - 'path' => '/path/to/custom/place/' + 'path' => '/path/to/custom/place/', ]); ``` @@ -287,7 +287,7 @@ be done in the **config/bootstrap.php** file: ``` php Log::setConfig('default', [ - 'engine' => 'Syslog' + 'engine' => 'Syslog', ]); ``` @@ -419,7 +419,7 @@ class UsersControllerTest extends TestCase { parent::setUp(); $this->setupLog([ - 'error' => ['scopes' => ['app.security']] + 'error' => ['scopes' => ['app.security']], ]); } diff --git a/docs/en/core-libraries/number.md b/docs/en/core-libraries/number.md index 3663a58ba4..efd5ec606b 100644 --- a/docs/en/core-libraries/number.md +++ b/docs/en/core-libraries/number.md @@ -153,7 +153,7 @@ echo Number::toPercentage(45.691873645); // Called with multiply. Output: 45.7% echo Number::toPercentage(0.45691, 1, [ - 'multiply' => true + 'multiply' => true, ]); ``` @@ -230,12 +230,12 @@ Example: echo $this->Number->format('123456.7890', [ 'places' => 2, 'before' => '¥ ', - 'after' => ' !' + 'after' => ' !', ]); // Output '¥ 123,456.79 !' echo $this->Number->format('123456.7890', [ - 'locale' => 'fr_FR' + 'locale' => 'fr_FR', ]); // Output '123 456,79 !' @@ -243,12 +243,12 @@ echo $this->Number->format('123456.7890', [ echo Number::format('123456.7890', [ 'places' => 2, 'before' => '¥ ', - 'after' => ' !' + 'after' => ' !', ]); // Output '¥ 123,456.79 !' echo Number::format('123456.7890', [ - 'locale' => 'fr_FR' + 'locale' => 'fr_FR', ]); // Output '123 456,79 !' ``` @@ -269,7 +269,7 @@ echo Number::ordinal(2); // Output '2nd' echo Number::ordinal(2, [ - 'locale' => 'fr_FR' + 'locale' => 'fr_FR', ]); // Output '2e' @@ -315,7 +315,7 @@ Example: echo $this->Number->formatDelta('123456.7890', [ 'places' => 2, 'before' => '[', - 'after' => ']' + 'after' => ']', ]); // Output '[+123,456.79]' @@ -323,7 +323,7 @@ echo $this->Number->formatDelta('123456.7890', [ echo Number::formatDelta('123456.7890', [ 'places' => 2, 'before' => '[', - 'after' => ']' + 'after' => ']', ]); // Output '[+123,456.79]' ``` @@ -343,6 +343,6 @@ Example: ``` php Number::config('en_IN', \NumberFormatter::CURRENCY, [ - 'pattern' => '#,##,##0' + 'pattern' => '#,##,##0', ]); ``` diff --git a/docs/en/core-libraries/text.md b/docs/en/core-libraries/text.md index 9b92149ba5..c1ff516f79 100644 --- a/docs/en/core-libraries/text.md +++ b/docs/en/core-libraries/text.md @@ -29,7 +29,7 @@ class UsersController extends AppController // Notify user of new message $this->Flash->success(__( 'You have a new message: {0}', - Text::truncate($message['Message']['body'], 255, ['html' => true]) + Text::truncate($message['Message']['body'], 255, ['html' => true]), )); } } @@ -170,7 +170,7 @@ replacements: ``` php Text::insert( 'My name is :name and I am :age years old.', - ['name' => 'Bob', 'age' => '65'] + ['name' => 'Bob', 'age' => '65'], ); // Returns: "My name is Bob and I am 65 years old." ``` @@ -193,7 +193,7 @@ $options = [ 'method' => 'text', // or html ], 'before' => '', - 'after' => '' + 'after' => '', ]; ``` @@ -237,7 +237,7 @@ $text = 'This is the song that never ends. This is the song that never ends.'; $result = Text::wrapBlock($text, [ 'width' => 22, 'indent' => ' → ', - 'indentAt' => 1 + 'indentAt' => 1, ]); // Returns @@ -272,7 +272,7 @@ Example: echo $this->Text->highlight( $lastSentence, 'using', - ['format' => '\1'] + ['format' => '\1'], ); // Called as Text @@ -281,7 +281,7 @@ use Cake\Utility\Text; echo Text::highlight( $lastSentence, 'using', - ['format' => '\1'] + ['format' => '\1'], ); ``` @@ -309,7 +309,7 @@ possible keys by default, all of which are optional: [ 'ellipsis' => '...', 'exact' => true, - 'html' => false + 'html' => false, ] ``` @@ -322,7 +322,7 @@ echo $this->Text->truncate( 22, [ 'ellipsis' => '...', - 'exact' => false + 'exact' => false, ] ); @@ -334,7 +334,7 @@ echo Text::truncate( 22, [ 'ellipsis' => '...', - 'exact' => false + 'exact' => false, ] ); ``` @@ -361,7 +361,7 @@ possible keys by default, all of which are optional: ``` php [ 'ellipsis' => '...', - 'exact' => true + 'exact' => true, ] ``` @@ -377,7 +377,7 @@ echo $this->Text->tail( 70, [ 'ellipsis' => '...', - 'exact' => false + 'exact' => false, ] ); @@ -389,7 +389,7 @@ echo Text::tail( 70, [ 'ellipsis' => '...', - 'exact' => false + 'exact' => false, ] ); ``` diff --git a/docs/en/core-libraries/time.md b/docs/en/core-libraries/time.md index 8034568de6..4254cd583e 100644 --- a/docs/en/core-libraries/time.md +++ b/docs/en/core-libraries/time.md @@ -50,7 +50,7 @@ use Cake\I18n\DateTime; $time = DateTime::createFromFormat( 'Y-m-d H:i:s', '2021-01-31 22:11:30', - 'America/New_York' + 'America/New_York', ); // Create from a timestamp and set timezone @@ -318,7 +318,7 @@ Date::setToStringFormat(\IntlDateFormatter::SHORT); // For any Date // The same method exists on Date, and DateTime DateTime::setToStringFormat([ \IntlDateFormatter::FULL, - \IntlDateFormatter::SHORT + \IntlDateFormatter::SHORT, ]); // Outputs 'Sunday, January 31, 2021 at 10:11 PM' echo $time; @@ -349,7 +349,7 @@ Often it is useful to print times relative to the present: $time = new DateTime('Jan 31, 2021'); // On June 12, 2021, this would output '4 months, 1 week, 6 days ago' echo $time->timeAgoInWords( - ['format' => 'MMM d, YYY', 'end' => '+1 year'] + ['format' => 'MMM d, YYY', 'end' => '+1 year'], ); ``` @@ -361,7 +361,7 @@ us control what level of detail should be used for each interval range: // Outputs '4 months ago' echo $time->timeAgoInWords([ 'accuracy' => ['month' => 'month'], - 'end' => '1 year' + 'end' => '1 year', ]); ``` @@ -372,7 +372,7 @@ of detail you want output: $time = new DateTime('+23 hours'); // Outputs 'in about a day' echo $time->timeAgoInWords([ - 'accuracy' => 'day' + 'accuracy' => 'day', ]); ``` diff --git a/docs/en/core-libraries/validation.md b/docs/en/core-libraries/validation.md index 97cbcfcb3d..a38ac4bc20 100644 --- a/docs/en/core-libraries/validation.md +++ b/docs/en/core-libraries/validation.md @@ -163,13 +163,13 @@ can also use any callable, including anonymous functions, as validation rules: // Use a global function $validator->add('title', 'custom', [ 'rule' => 'validate_title', - 'message' => 'The title is not valid' + 'message' => 'The title is not valid', ]); // Use an array callable that is not in a provider $validator->add('title', 'custom', [ 'rule' => [$this, 'method'], - 'message' => 'The title is not valid' + 'message' => 'The title is not valid', ]); // Use a closure @@ -178,14 +178,14 @@ $validator->add('title', 'custom', [ 'rule' => function ($value, $context) use ($extra) { // Custom logic that returns true/false }, - 'message' => 'The title is not valid' + 'message' => 'The title is not valid', ]); // Use a rule from a custom provider $validator->add('title', 'custom', [ 'rule' => 'customRule', 'provider' => 'custom', - 'message' => 'The title is not unique enough' + 'message' => 'The title is not unique enough', ]); ``` @@ -240,7 +240,7 @@ $validator->add('length', 'custom', [ return true; }, - 'message' => 'Generic error message used when `false` is returned' + 'message' => 'Generic error message used when `false` is returned', ]); ``` @@ -406,7 +406,7 @@ the `provider` key in your rule: // Use a rule from the table provider $validator->add('title', 'custom', [ 'rule' => 'customTableMethod', - 'provider' => 'table' + 'provider' => 'table', ]); ``` @@ -447,7 +447,7 @@ class PostsTable extends Table // use the provider in a field validation rule $validator->add('phoneField', 'myCustomRuleNameForPhone', [ 'rule' => 'phone', - 'provider' => 'fr' + 'provider' => 'fr', ]); return $validator; @@ -511,7 +511,7 @@ $validator->addNestedMany( 'comments', $commentValidator, 'Invalid comment', - 'create' + 'create', ); ``` diff --git a/docs/en/core-libraries/xml.md b/docs/en/core-libraries/xml.md index e25acbdb20..c97f68bbd2 100644 --- a/docs/en/core-libraries/xml.md +++ b/docs/en/core-libraries/xml.md @@ -107,7 +107,7 @@ Examples of invalid arrays: ``` php // Top level with numeric key [ - ['key' => 'value'] + ['key' => 'value'], ]; // Multiple keys in top level @@ -161,7 +161,7 @@ $xmlArray( 'xmlns:pref' => 'https://cakephp.org', 'pref:item' => [ 'item 1', - 'item 2' + 'item 2', ] ] ] diff --git a/docs/en/development/application.md b/docs/en/development/application.md index 4d05a51899..8afaffc99c 100644 --- a/docs/en/development/application.md +++ b/docs/en/development/application.md @@ -69,7 +69,7 @@ class Application extends BaseApplication if (PHP_SAPI !== 'cli') { FactoryLocator::add( 'Table', - (new TableLocator())->allowFallbackClass(false) + (new TableLocator())->allowFallbackClass(false), ); } diff --git a/docs/en/development/configuration.md b/docs/en/development/configuration.md index b73b1185d6..a897c00cff 100644 --- a/docs/en/development/configuration.md +++ b/docs/en/development/configuration.md @@ -337,7 +337,7 @@ The above example could also be written in a single call: ``` php Configure::write('Company', [ 'name' => 'Pizza, Inc.', - 'slogan' => 'Pizza for your body and soul' + 'slogan' => 'Pizza for your body and soul', ]); ``` diff --git a/docs/en/development/debugging.md b/docs/en/development/debugging.md index c74aed9574..da8e3cc8a2 100644 --- a/docs/en/development/debugging.md +++ b/docs/en/development/debugging.md @@ -83,7 +83,7 @@ Debugger::dump($foo); array( 1, 2, - 3 + 3, ) // Simple object diff --git a/docs/en/development/dependency-injection.md b/docs/en/development/dependency-injection.md index 33e6867b07..7a6c9824c2 100644 --- a/docs/en/development/dependency-injection.md +++ b/docs/en/development/dependency-injection.md @@ -93,7 +93,7 @@ class SearchComponent extends Component public function __construct( ComponentRegistry $registry, private UserService $users, - array $config = [] + array $config = [], ) { parent::__construct($registry, $config); } @@ -379,7 +379,7 @@ Auto Wiring is turned off by default. To enable it: public function services(ContainerInterface $container): void { $container->delegate( - new \League\Container\ReflectionContainer() + new \League\Container\ReflectionContainer(), ); } ``` @@ -391,7 +391,7 @@ caching: ``` php $container->delegate( // or consider using the value of Configure::read('debug') - new \League\Container\ReflectionContainer(true) + new \League\Container\ReflectionContainer(true), ); ``` diff --git a/docs/en/development/errors.md b/docs/en/development/errors.md index 0e1dd8f01b..c402633be7 100644 --- a/docs/en/development/errors.md +++ b/docs/en/development/errors.md @@ -640,7 +640,7 @@ class ErrorLogger implements ErrorLoggerInterface public function logError( PhpError $error, ?ServerRequestInterface $request, - bool $includeTrace = false + bool $includeTrace = false, ): void { // Log PHP Errors } @@ -650,7 +650,7 @@ class ErrorLogger implements ErrorLoggerInterface */ public function logException( ?ServerRequestInterface $request, - bool $includeTrace = false + bool $includeTrace = false, ): void { // Log exceptions. } diff --git a/docs/en/development/routing.md b/docs/en/development/routing.md index 31c9afb10e..61e94f52d4 100644 --- a/docs/en/development/routing.md +++ b/docs/en/development/routing.md @@ -55,7 +55,7 @@ $routes->connect( $routes->connect( '/articles/{id}', ['controller' => 'Articles', 'action' => 'view'], - ['id' => '\d+', 'pass' => ['id']] + ['id' => '\d+', 'pass' => ['id']], ); ``` @@ -86,7 +86,7 @@ parameters: $routes->connect( '/upgrade', ['controller' => 'Subscriptions', 'action' => 'create'], - ['_name' => 'upgrade'] + ['_name' => 'upgrade'], ); use Cake\Routing\Router; @@ -156,7 +156,7 @@ The basic format for a route definition is: $routes->connect( '/url/template', ['targetKey' => 'targetValue'], - ['option' => 'matchingRegex'] + ['option' => 'matchingRegex'], ); ``` @@ -237,7 +237,7 @@ compose the default route parameters: ``` php $routes->connect( '/government', - ['controller' => 'Pages', 'action' => 'display', 5] + ['controller' => 'Pages', 'action' => 'display', 5], ); ``` @@ -280,14 +280,14 @@ specific HTTP verbs simpler: $routes->get( '/cooks/{id}', ['controller' => 'Users', 'action' => 'view'], - 'users:view' + 'users:view', ); // Create a route that only responds to PUT requests $routes->put( '/cooks/{id}', ['controller' => 'Users', 'action' => 'update'], - 'users:update' + 'users:update', ); ``` @@ -322,13 +322,13 @@ will be treated as part of the parameter: ``` php $routes->connect( '/{controller}/{id}', - ['action' => 'view'] + ['action' => 'view'], )->setPatterns(['id' => '[0-9]+']); $routes->connect( '/{controller}/{id}', ['action' => 'view'], - ['id' => '[0-9]+'] + ['id' => '[0-9]+'], ); ``` @@ -357,7 +357,7 @@ $routes->scope('/', function (RouteBuilder $routes) { $routes->connect( '/{controller}/{id}', ['action' => 'view'], - ['id' => '[0-9]+'] + ['id' => '[0-9]+'], ); }); ``` @@ -398,11 +398,11 @@ One more example, and you'll be a routing pro: ``` php $routes->connect( '/{controller}/{year}/{month}/{day}', - ['action' => 'index'] + ['action' => 'index'], )->setPatterns([ 'year' => '[12][0-9]{3}', 'month' => '0[1-9]|1[012]', - 'day' => '0[1-9]|[12][0-9]|3[01]' + 'day' => '0[1-9]|[12][0-9]|3[01]', ]); ``` @@ -498,7 +498,7 @@ $routes->scope('/api', function (RouteBuilder $routes) { // Set default options for all routes in this scope $routes->setOptions([ '_host' => 'api.example.com', - '_https' => true + '_https' => true, ]); // These routes will automatically have _host and _https set @@ -526,7 +526,7 @@ $routes->scope('/api', function (RouteBuilder $routes) { $routes->get('/internal', [ 'controller' => 'Internal', 'action' => 'index', - '_host' => 'internal.example.com' + '_host' => 'internal.example.com', ]); // Nested scope inherits the default host @@ -561,7 +561,7 @@ public function view($articleId = null, $slug = null) $routes->scope('/', function (RouteBuilder $routes) { $routes->connect( '/blog/{id}-{slug}', // For example, /blog/3-CakePHP_Rocks - ['controller' => 'Blogs', 'action' => 'view'] + ['controller' => 'Blogs', 'action' => 'view'], ) // Define the route elements in the route template // to prepend as function arguments. Order matters as this @@ -586,7 +586,7 @@ echo $this->Html->link('CakePHP Rocks', [ 'controller' => 'Blog', 'action' => 'view', 'id' => 3, - 'slug' => 'CakePHP_Rocks' + 'slug' => 'CakePHP_Rocks', ]); // You can also used numerically indexed parameters. @@ -594,7 +594,7 @@ echo $this->Html->link('CakePHP Rocks', [ 'controller' => 'Blog', 'action' => 'view', 3, - 'CakePHP_Rocks' + 'CakePHP_Rocks', ]); ``` @@ -630,14 +630,14 @@ option can be used in reverse routing to identify the route you want to use: $routes->connect( '/login', ['controller' => 'Users', 'action' => 'login'], - ['_name' => 'login'] + ['_name' => 'login'], ); // Name a verb specific route $routes->post( '/logout', ['controller' => 'Users', 'action' => 'logout'], - 'logout' + 'logout', ); // Generate a URL using a named route. @@ -810,13 +810,13 @@ how to build this link using the HTML helper: // Go into a prefixed route. echo $this->Html->link( 'Manage articles', - ['prefix' => 'Manager/Admin', 'controller' => 'Articles', 'action' => 'add'] + ['prefix' => 'Manager/Admin', 'controller' => 'Articles', 'action' => 'add'], ); // Leave a prefix echo $this->Html->link( 'View Post', - ['prefix' => false, 'controller' => 'Articles', 'action' => 'view', 5] + ['prefix' => false, 'controller' => 'Articles', 'action' => 'view', 5], ); ``` @@ -834,7 +834,7 @@ URL array: ``` php echo $this->Html->link( 'New admin todo', - ['prefix' => 'Admin', 'controller' => 'TodoItems', 'action' => 'create'] + ['prefix' => 'Admin', 'controller' => 'TodoItems', 'action' => 'create'], ); ``` @@ -843,7 +843,7 @@ When using nesting, you need to chain them together: ``` php echo $this->Html->link( 'New todo', - ['prefix' => 'Admin/MyPrefix', 'controller' => 'TodoItems', 'action' => 'create'] + ['prefix' => 'Admin/MyPrefix', 'controller' => 'TodoItems', 'action' => 'create'], ); ``` @@ -902,7 +902,7 @@ URL array: ``` php echo $this->Html->link( 'New todo', - ['plugin' => 'Todo', 'controller' => 'TodoItems', 'action' => 'create'] + ['plugin' => 'Todo', 'controller' => 'TodoItems', 'action' => 'create'], ); ``` @@ -912,7 +912,7 @@ a link that has no plugin you can do the following: ``` php echo $this->Html->link( 'New todo', - ['plugin' => null, 'controller' => 'Users', 'action' => 'profile'] + ['plugin' => null, 'controller' => 'Users', 'action' => 'profile'], ); ``` @@ -947,7 +947,7 @@ $routes->scope('/', function (RouteBuilder $routes) { // This route only matches on POST requests. $routes->post( '/reviews/start', - ['controller' => 'Reviews', 'action' => 'start'] + ['controller' => 'Reviews', 'action' => 'start'], ); // Match multiple verbs @@ -984,7 +984,7 @@ $routes->scope('/', function (RouteBuilder $routes) { // This route only matches on http://images.example.com $routes->connect( '/images/default-logo.png', - ['controller' => 'Images', 'action' => 'default'] + ['controller' => 'Images', 'action' => 'default'], )->setHost('images.example.com'); // This route only matches on http://*.example.com @@ -1004,7 +1004,7 @@ parameter when generating URLs: // If you have this route $routes->connect( '/images/old-logo.png', - ['controller' => 'Images', 'action' => 'oldLogo'] + ['controller' => 'Images', 'action' => 'oldLogo'], )->setHost('images.example.com'); // You need this to generate a url @@ -1057,7 +1057,7 @@ $routes->scope('/page', function (RouteBuilder $routes) { $routes->setExtensions(['json', 'xml', 'html']); $routes->connect( '/{title}', - ['controller' => 'Pages', 'action' => 'view'] + ['controller' => 'Pages', 'action' => 'view'], )->setPass(['title']); }); ``` @@ -1067,7 +1067,7 @@ Then to create links which map back to the routes simply use: ``` php $this->Html->link( 'Link title', - ['controller' => 'Pages', 'action' => 'view', 'title' => 'super-article', '_ext' => 'html'] + ['controller' => 'Pages', 'action' => 'view', 'title' => 'super-article', '_ext' => 'html'], ); ``` @@ -1257,7 +1257,7 @@ only connect specific resource routes you can use the `only` option: ``` php $routes->resources('Articles', [ - 'only' => ['index', 'view'] + 'only' => ['index', 'view'], ]); ``` @@ -1282,7 +1282,7 @@ use the `actions` key to rename the actions used: ``` php $routes->resources('Articles', [ - 'actions' => ['update' => 'put', 'create' => 'add'] + 'actions' => ['update' => 'put', 'create' => 'add'], ]); ``` @@ -1295,12 +1295,12 @@ You can map additional resource methods using the `map` option: ``` php $routes->resources('Articles', [ - 'map' => [ - 'deleteAll' => [ - 'action' => 'deleteAll', - 'method' => 'DELETE' - ] - ] + 'map' => [ + 'deleteAll' => [ + 'action' => 'deleteAll', + 'method' => 'DELETE', + ], + ], ]); // This would connect /articles/deleteAll ``` @@ -1365,7 +1365,7 @@ You can specify an alternative inflection type using the `inflect` option: ``` php $routes->scope('/', function (RouteBuilder $routes) { $routes->resources('BlogPosts', [ - 'inflect' => 'underscore' // Will use ``Inflector::underscore()`` + 'inflect' => 'underscore', // Will use ``Inflector::underscore()`` ]); }); ``` @@ -1480,7 +1480,7 @@ application renaming URLs. However, if you defined your link like: $this->Html->link( 'View', - ['controller' => 'Articles', 'action' => 'view', $id] + ['controller' => 'Articles', 'action' => 'view', $id], ); ``` @@ -1511,7 +1511,7 @@ It will provide reverse routing when the destination url is well defined: ``` php $this->Html->link( 'View', - ['controller' => 'Articles', 'action' => 'view', $id] + ['controller' => 'Articles', 'action' => 'view', $id], ); ``` @@ -1521,7 +1521,7 @@ defined pattern: ``` php $this->Html->link( 'View', - ['controller' => $controller, 'action' => 'view', $id] + ['controller' => $controller, 'action' => 'view', $id], ); ``` @@ -1535,7 +1535,7 @@ $routes->url([ 'controller' => 'Articles', 'action' => 'index', '?' => ['page' => 1], - '#' => 'top' + '#' => 'top', ]); // Will generate a URL like. @@ -1739,7 +1739,7 @@ off with a route that looks like: $routes->get( '/view/{id}', ['controller' => 'Articles', 'action' => 'view'], - 'articles:view' + 'articles:view', ); ``` @@ -1766,7 +1766,7 @@ $routes->setRouteClass(EntityRoute::class); $routes->get( '/view/{id}/{slug}', ['controller' => 'Articles', 'action' => 'view'], - 'articles:view' + 'articles:view', ); ``` @@ -1806,7 +1806,7 @@ option: $routes->connect( '/{slug}', ['controller' => 'Articles', 'action' => 'view'], - ['routeClass' => 'SlugRoute'] + ['routeClass' => 'SlugRoute'], ); // Or by setting the routeClass in your scope. @@ -1814,7 +1814,7 @@ $routes->scope('/', function (RouteBuilder $routes) { $routes->setRouteClass('SlugRoute'); $routes->connect( '/{slug}', - ['controller' => 'Articles', 'action' => 'view'] + ['controller' => 'Articles', 'action' => 'view'], ); }); ``` diff --git a/docs/en/development/sessions.md b/docs/en/development/sessions.md index 91d0761d4d..852803ccbe 100644 --- a/docs/en/development/sessions.md +++ b/docs/en/development/sessions.md @@ -41,7 +41,7 @@ this: Configure::write('Session', [ 'defaults' => 'php', 'ini' => [ - 'session.cookie_secure' => false + 'session.cookie_secure' => false, ] ]); ``` @@ -83,7 +83,7 @@ Configure::write('Session', [ 'defaults' => 'php', 'ini' => [ // Invalidate the cookie after 30 minutes - 'session.cookie_lifetime' => 1800 + 'session.cookie_lifetime' => 1800, ] ]); ``` @@ -108,7 +108,7 @@ it in your Session config: ``` php Configure::write('Session', [ - 'defaults' => 'php' + 'defaults' => 'php', ]); ``` @@ -119,7 +119,7 @@ part or all of it by doing the following: Configure::write('Session', [ 'defaults' => 'php', 'cookie' => 'my_app', - 'timeout' => 4320 // 3 days + 'timeout' => 4320, // 3 days ]); ``` @@ -269,7 +269,7 @@ Configure::write('Session', [ 'session.cookie_name' => 'MyCookie', 'session.cookie_lifetime' => 1800, // Valid for 30 minutes 'session.gc_divisor' => 1000, - 'session.cookie_httponly' => true + 'session.cookie_httponly' => true, ] ]); ``` @@ -424,8 +424,8 @@ You may also specify one or multiple hashes like so: ``` php $session->write([ - 'Config.theme' => 'blue', - 'Config.language' => 'en', + 'Config.theme' => 'blue', + 'Config.language' => 'en', ]); ``` diff --git a/docs/en/development/testing.md b/docs/en/development/testing.md index 19485451bd..9570f28cbc 100644 --- a/docs/en/development/testing.md +++ b/docs/en/development/testing.md @@ -450,7 +450,7 @@ $migrator->runMany([ // Run Contacts migrations on test connection. ['plugin' => 'Contacts'], // Run Documents migrations on test_docs connection. - ['plugin' => 'Documents', 'connection' => 'test_docs'] + ['plugin' => 'Documents', 'connection' => 'test_docs'], ]); ``` @@ -548,44 +548,44 @@ use Cake\TestSuite\Fixture\TestFixture; class ArticlesFixture extends TestFixture { - // Optional. Set this property to load fixtures - // to a different test datasource - public $connection = 'test'; - - // Optional. Lets you define which table alias is used when - // reflecting schema and inserting rows. Inferred from the - // class name by default. Added in 5.3.0 - public $tableAlias = 'Articles'; - - // Optional. Lets you define the table name for a fixture. - // If defined, this table name will be camelized to create - // $tableAlias. - public $table = 'articles'; - - public $records = [ - [ - 'title' => 'First Article', - 'body' => 'First Article Body', - 'published' => '1', - 'created' => '2007-03-18 10:39:23', - 'modified' => '2007-03-18 10:41:31' - ], - [ - 'title' => 'Second Article', - 'body' => 'Second Article Body', - 'published' => '1', - 'created' => '2007-03-18 10:41:23', - 'modified' => '2007-03-18 10:43:31' - ], - [ - 'title' => 'Third Article', - 'body' => 'Third Article Body', - 'published' => '1', - 'created' => '2007-03-18 10:43:23', - 'modified' => '2007-03-18 10:45:31' - ] - ]; - } + // Optional. Set this property to load fixtures + // to a different test datasource + public $connection = 'test'; + + // Optional. Lets you define which table alias is used when + // reflecting schema and inserting rows. Inferred from the + // class name by default. Added in 5.3.0 + public $tableAlias = 'Articles'; + + // Optional. Lets you define the table name for a fixture. + // If defined, this table name will be camelized to create + // $tableAlias. + public $table = 'articles'; + + public $records = [ + [ + 'title' => 'First Article', + 'body' => 'First Article Body', + 'published' => '1', + 'created' => '2007-03-18 10:39:23', + 'modified' => '2007-03-18 10:41:31', + ], + [ + 'title' => 'Second Article', + 'body' => 'Second Article Body', + 'published' => '1', + 'created' => '2007-03-18 10:41:23', + 'modified' => '2007-03-18 10:43:31', + ], + [ + 'title' => 'Third Article', + 'body' => 'Third Article Body', + 'published' => '1', + 'created' => '2007-03-18 10:43:23', + 'modified' => '2007-03-18 10:45:31', + ], + ]; +} ``` > [!NOTE] @@ -865,7 +865,7 @@ class PluginHelperTest extends TestCase $routes->setRouteClass(DashedRoute::class); $routes->get( '/test/view/{id}', - ['controller' => 'Tests', 'action' => 'view'] + ['controller' => 'Tests', 'action' => 'view'], ); // ... }); @@ -908,7 +908,7 @@ class ArticlesTable extends Table public function findPublished(SelectQuery $query): SelectQuery { $query->where([ - $this->getAlias() . '.published' => 1 + $this->getAlias() . '.published' => 1, ]); return $query; @@ -966,7 +966,7 @@ class ArticlesTableTest extends TestCase $expected = [ ['id' => 1, 'title' => 'First Article'], ['id' => 2, 'title' => 'Second Article'], - ['id' => 3, 'title' => 'Third Article'] + ['id' => 3, 'title' => 'Third Article'], ]; $this->assertEquals($expected, $result); @@ -1083,7 +1083,7 @@ class ArticlesController extends AppController $this->set([ 'title' => 'Articles', - 'articles' => $result + 'articles' => $result, ]); } } @@ -1136,7 +1136,7 @@ class ArticlesControllerTest extends TestCase 'published' => 1, 'slug' => 'new-article', 'title' => 'New Article', - 'body' => 'New Body' + 'body' => 'New Body', ]; $this->post('/articles', $data); @@ -1180,12 +1180,12 @@ $this->session(['Auth.User.id' => 1]); // Configure headers and merge with the existing request $this->configRequest([ - 'headers' => ['Accept' => 'application/json'] + 'headers' => ['Accept' => 'application/json'], ]); // Replace the existing request. Added in 5.1.0 $this->replaceRequest([ - 'headers' => ['Accept' => 'application/json'] + 'headers' => ['Accept' => 'application/json'], ]); ``` @@ -1218,7 +1218,7 @@ can use `configRequest()` to set the correct environment variables: ``` php // Fake out SSL connections. $this->configRequest([ - 'environment' => ['HTTPS' => 'on'] + 'environment' => ['HTTPS' => 'on'], ]); ``` @@ -1342,7 +1342,7 @@ class MarkersControllerTest extends TestCase public function testGet(): void { $this->configRequest([ - 'headers' => ['Accept' => 'application/json'] + 'headers' => ['Accept' => 'application/json'], ]); $this->get('/markers/view/1.json'); @@ -1406,7 +1406,7 @@ public function testAddWithUploads(): void 12345, // the filesize in bytes \UPLOAD_ERR_OK, // the upload/error status 'teaser.jpg', // the filename as sent by the client - 'image/jpeg' // the mimetype as sent by the client + 'image/jpeg', // the mimetype as sent by the client ); $textAttachment = new \Laminas\Diactoros\UploadedFile( @@ -1414,7 +1414,7 @@ public function testAddWithUploads(): void 12345, \UPLOAD_ERR_OK, 'attachment.txt', - 'text/plain' + 'text/plain', ); $pdfAttachment = new \Laminas\Diactoros\UploadedFile( @@ -1422,7 +1422,7 @@ public function testAddWithUploads(): void 12345, \UPLOAD_ERR_OK, 'attachment.pdf', - 'application/pdf' + 'application/pdf', ); // This is the data accessible via `$this->request->getUploadedFile()` @@ -1481,7 +1481,7 @@ public function testAddWithInvalidUploads(): void 0, \UPLOAD_ERR_NO_FILE, '', - '' + '', ); $uploadFailureAttachment = new \Laminas\Diactoros\UploadedFile( @@ -1489,7 +1489,7 @@ public function testAddWithInvalidUploads(): void 1234567890, \UPLOAD_ERR_INI_SIZE, 'attachment.txt', - 'text/plain' + 'text/plain', ); $invalidTypeAttachment = new \Laminas\Diactoros\UploadedFile( @@ -1497,7 +1497,7 @@ public function testAddWithInvalidUploads(): void 12345, \UPLOAD_ERR_OK, 'attachment.exe', - 'application/vnd.microsoft.portable-executable' + 'application/vnd.microsoft.portable-executable', ); $this->configRequest([ @@ -1895,8 +1895,8 @@ class CurrencyRendererHelperTest extends TestCase // Testing the thousands separator $this->assertEquals( - 'USD 12,000.70', - $this->helper->usd(12000.70) + 'USD 12,000.70', + $this->helper->usd(12000.70), ); } } @@ -1931,7 +1931,7 @@ class OrdersTable extends Table if ($this->save($order)) { // moved cart removal to CartsTable $event = new Event('Model.Order.afterPlace', $this, [ - 'order' => $order + 'order' => $order, ]); $this->getEventManager()->dispatch($event); @@ -1951,7 +1951,7 @@ class CartsTable extends Table // events from other models \Cake\Event\EventManager::instance()->on( 'Model.Order.afterPlace', - callable: [$this, 'removeFromCart'] + callable: [$this, 'removeFromCart'], ); } diff --git a/docs/en/intro/conventions.md b/docs/en/intro/conventions.md index 03eaf0974f..3ffb1e2d3e 100644 --- a/docs/en/intro/conventions.md +++ b/docs/en/intro/conventions.md @@ -38,7 +38,7 @@ $this->Html->link('link-title', [ 'prefix' => 'MyPrefix' // CamelCased 'plugin' => 'MyPlugin', // CamelCased 'controller' => 'ControllerName', // CamelCased - 'action' => 'actionName' // camelBacked + 'action' => 'actionName', // camelBacked ] ``` diff --git a/docs/en/orm/associations.md b/docs/en/orm/associations.md index c4b712a038..bea716231d 100644 --- a/docs/en/orm/associations.md +++ b/docs/en/orm/associations.md @@ -42,7 +42,7 @@ class ArticlesTable extends Table public function initialize(array $config): void { $this->belongsTo('Authors', [ - 'className' => 'Publishing.Authors' + 'className' => 'Publishing.Authors', ]) ->setForeignKey('author_id') ->setProperty('author'); @@ -62,7 +62,7 @@ You can also use arrays to customize your associations: $this->belongsTo('Authors', [ 'className' => 'Publishing.Authors', 'foreignKey' => 'author_id', - 'propertyName' => 'author' + 'propertyName' => 'author', ]); ``` @@ -81,7 +81,7 @@ class ArticlesTable extends Table ->setFinder('approved'); $this->hasMany('UnapprovedComments', [ - 'className' => 'Comments' + 'className' => 'Comments', ]) ->setFinder('unapproved') ->setProperty('unapproved_comments'); @@ -118,13 +118,13 @@ class PostsTable extends Table { public function initialize(array $config): void { - $this->addAssociations([ - 'belongsTo' => [ - 'Users' => ['className' => 'App\Model\Table\UsersTable'], - ], - 'hasMany' => ['Comments'], - 'belongsToMany' => ['Tags'], - ]); + $this->addAssociations([ + 'belongsTo' => [ + 'Users' => ['className' => 'App\Model\Table\UsersTable'], + ], + 'hasMany' => ['Comments'], + 'belongsToMany' => ['Tags'], + ]); } } ``` @@ -195,14 +195,14 @@ class UsersTable extends Table public function initialize(array $config): void { $this->hasOne('HomeAddresses', [ - 'className' => 'Addresses' + 'className' => 'Addresses', ]) ->setProperty('home_address') ->setConditions(['HomeAddresses.label' => 'Home']) ->setDependent(true); $this->hasOne('WorkAddresses', [ - 'className' => 'Addresses' + 'className' => 'Addresses', ]) ->setProperty('work_address') ->setConditions(['WorkAddresses.label' => 'Work']) @@ -729,7 +729,7 @@ you are filtering on: ``` php $query = $this->find( 'list', - valueField: 'studentFirstName', order: 'students.id' + valueField: 'studentFirstName', order: 'students.id', ) ->contain(['Courses']) ->matching('Courses') diff --git a/docs/en/orm/behaviors.md b/docs/en/orm/behaviors.md index c3c140ccaa..362b449c00 100644 --- a/docs/en/orm/behaviors.md +++ b/docs/en/orm/behaviors.md @@ -342,7 +342,7 @@ class UsersTable extends AppTable $this->behaviors()->get('Timestamp')->setConfig([ 'events' => [ 'Users.login' => [ - 'last_login' => 'always' + 'last_login' => 'always', ], ], ]); diff --git a/docs/en/orm/behaviors/counter-cache.md b/docs/en/orm/behaviors/counter-cache.md index 33e589d04c..5cff407f0a 100644 --- a/docs/en/orm/behaviors/counter-cache.md +++ b/docs/en/orm/behaviors/counter-cache.md @@ -23,7 +23,7 @@ class CommentsTable extends Table public function initialize(array $config): void { $this->addBehavior('CounterCache', [ - 'Articles' => ['comment_count'] + 'Articles' => ['comment_count'], ]); } } diff --git a/docs/en/orm/behaviors/timestamp.md b/docs/en/orm/behaviors/timestamp.md index eb00530d5f..4e4fa993dd 100644 --- a/docs/en/orm/behaviors/timestamp.md +++ b/docs/en/orm/behaviors/timestamp.md @@ -45,7 +45,7 @@ class OrdersTable extends Table 'updated_at' => 'always', ], 'Orders.completed' => [ - 'completed_at' => 'always' + 'completed_at' => 'always', ] ] ]); diff --git a/docs/en/orm/behaviors/translate.md b/docs/en/orm/behaviors/translate.md index ba9382f490..5693628576 100644 --- a/docs/en/orm/behaviors/translate.md +++ b/docs/en/orm/behaviors/translate.md @@ -330,7 +330,7 @@ class ArticlesTable extends Table { $this->addBehavior('Translate', [ 'fields' => ['title', 'body'], - 'allowEmptyTranslations' => false + 'allowEmptyTranslations' => false, ]); } } @@ -399,7 +399,7 @@ TranslateBehavior does not substitute find conditions by default. You need to us ``` php $this->Articles->getBehavior('Translate')->setLocale('es'); $query = $this->Articles->find()->where([ - $this->Articles->getBehavior('Translate')->translationField('title') => 'Otro Título' + $this->Articles->getBehavior('Translate')->translationField('title') => 'Otro Título', ]); ``` @@ -430,7 +430,7 @@ class Article extends Entity $article = new Article([ 'title' => 'My First Article', 'body' => 'This is the content', - 'footnote' => 'Some afterwords' + 'footnote' => 'Some afterwords', ]); $this->Articles->save($article); diff --git a/docs/en/orm/behaviors/tree.md b/docs/en/orm/behaviors/tree.md index 177ec2d962..3c32ef1544 100644 --- a/docs/en/orm/behaviors/tree.md +++ b/docs/en/orm/behaviors/tree.md @@ -162,7 +162,7 @@ An example of all options in use is: $query = $categories->find('treeList', keyPath: 'url', valuePath: 'id', - spacer: ' ' + spacer: ' ', ); ``` @@ -220,7 +220,7 @@ public function initialize(array $config): void $this->addBehavior('Tree', [ 'parent' => 'ancestor_id', // Use this instead of parent_id 'left' => 'tree_left', // Use this instead of lft - 'right' => 'tree_right' // Use this instead of rght + 'right' => 'tree_right', // Use this instead of rght ]); } ``` @@ -252,7 +252,7 @@ class LocationsTable extends Table public function initialize(array $config): void { $this->addBehavior('Tree', [ - 'scope' => ['country_name' => 'Brazil'] + 'scope' => ['country_name' => 'Brazil'], ]); } } diff --git a/docs/en/orm/database-basics.md b/docs/en/orm/database-basics.md index 18821e55e2..45a8937eff 100644 --- a/docs/en/orm/database-basics.md +++ b/docs/en/orm/database-basics.md @@ -62,7 +62,7 @@ $results = $connection ->execute( 'SELECT * FROM articles WHERE created >= :created', ['created' => new DateTime('1 day ago')], - ['created' => 'datetime'] + ['created' => 'datetime'], ) ->fetchAll('assoc'); ``` @@ -90,7 +90,7 @@ use DateTime; $connection = ConnectionManager::get('default'); $connection->insert('articles', [ 'title' => 'A New Article', - 'created' => new DateTime('now') + 'created' => new DateTime('now'), ], ['created' => 'datetime']); ``` @@ -709,7 +709,7 @@ class PointMutationType extends BaseType return [ 'position' => (int) $matches[1], 'from' => $matches[2], - 'to' => $matches[3] + 'to' => $matches[3], ]; } @@ -786,7 +786,7 @@ class PointMutationType extends BaseType public function getColumnSql( TableSchemaInterface $schema, string $column, - Driver $driver + Driver $driver, ): ?string { $data = $schema->getColumn($column); $sql = $driver->quoteIdentifier($column); @@ -806,7 +806,7 @@ class PointMutationType extends BaseType */ public function convertColumnDefinition( array $definition, - Driver $driver + Driver $driver, ): ?array { return [ 'type' => $this->_name, @@ -913,7 +913,7 @@ class PointType extends BaseType implements ExpressionTypeInterface 'POINT', [ $value->lat(), - $value->long() + $value->long(), ] ); } @@ -974,7 +974,7 @@ For parameterized queries use the 2nd argument: ``` php $statement = $connection->execute( 'UPDATE articles SET published = ? WHERE id = ?', - [1, 2] + [1, 2], ); ``` @@ -986,7 +986,7 @@ abstract type names when creating a query: $statement = $connection->execute( 'UPDATE articles SET published_date = ? WHERE id = ?', [new DateTime('now'), 2], - ['date', 'integer'] + ['date', 'integer'], ); ``` @@ -1147,7 +1147,7 @@ use Cake\Log\Log; Log::setConfig('queries', [ 'className' => 'Console', 'stream' => 'php://stderr', - 'scopes' => ['queriesLog'] + 'scopes' => ['queriesLog'], ]); // File logging @@ -1155,7 +1155,7 @@ Log::setConfig('queries', [ 'className' => 'File', 'path' => LOGS, 'file' => 'queries.log', - 'scopes' => ['queriesLog'] + 'scopes' => ['queriesLog'], ]); ``` diff --git a/docs/en/orm/entities.md b/docs/en/orm/entities.md index bde3bcdf56..3aeb0681b6 100644 --- a/docs/en/orm/entities.md +++ b/docs/en/orm/entities.md @@ -54,7 +54,7 @@ use App\Model\Entity\Article; $article = new Article([ 'id' => 1, 'title' => 'New Article', - 'created' => new DateTime('now') + 'created' => new DateTime('now'), ]); ``` @@ -69,7 +69,7 @@ $article = $this->fetchTable('Articles')->newEmptyEntity(); $article = $this->fetchTable('Articles')->newEntity([ 'id' => 1, 'title' => 'New Article', - 'created' => new DateTime('now') + 'created' => new DateTime('now'), ]); ``` @@ -119,7 +119,7 @@ Using `patch()` you can mass assign multiple fields at once: ``` php $article->patch([ 'title' => 'My first post', - 'body' => 'It is the best ever!' + 'body' => 'It is the best ever!', ]); ``` @@ -136,7 +136,7 @@ You can check if fields are defined in your entities with `has()`: ``` php $article = new Article([ 'title' => 'First post', - 'user_id' => null + 'user_id' => null, ]); $article->has('title'); // true $article->has('user_id'); // true @@ -383,7 +383,7 @@ on an entity, making it easier to test code that works with error messages: $user->setError('password', ['Password is required']); $user->setErrors([ 'password' => ['Password is required'], - 'username' => ['Username is required'] + 'username' => ['Username is required'], ]); ``` @@ -410,7 +410,7 @@ class Article extends Entity { protected array $_accessible = [ 'title' => true, - 'body' => true + 'body' => true, ]; } ``` diff --git a/docs/en/orm/query-builder.md b/docs/en/orm/query-builder.md index 106850d86a..b9087ada68 100644 --- a/docs/en/orm/query-builder.md +++ b/docs/en/orm/query-builder.md @@ -410,7 +410,7 @@ $concat = $query->func()->concat([ $query->func()->dateDiff([ 'NOW()' => 'literal', 'Articles.created' => 'identifier', - ]) + ]), ]); $query->select(['link_title' => $concat]); ``` @@ -445,15 +445,15 @@ functions or they will be treated as bound parameters: ``` php $query = $articles->find(); $year = $query->func()->year([ - 'created' => 'identifier' + 'created' => 'identifier', ]); $time = $query->func()->date_format([ 'created' => 'identifier', - "'%H:%i'" => 'literal' + "'%H:%i'" => 'literal', ]); $query->select([ 'yearCreated' => $year, - 'timeCreated' => $time + 'timeCreated' => $time, ]); ``` @@ -497,7 +497,7 @@ complex expressions: $query = $articles->find(); $concat = $query->func()->concat([ 'title' => 'identifier', - 'synopsis' => 'identifier' + 'synopsis' => 'identifier', ]); $query->orderByAsc($concat); ``` @@ -535,7 +535,7 @@ When using aggregate functions like `count` and `sum` you may want to use $query = $articles->find(); $query->select([ 'count' => $query->func()->count('view_count'), - 'published_date' => 'DATE(created)' + 'published_date' => 'DATE(created)', ]) ->groupBy('published_date') ->having(['count >' => 3]); @@ -572,7 +572,7 @@ $unpublishedCase = $query->expr() $query->select([ 'number_published' => $query->func()->count($publishedCase), - 'number_unpublished' => $query->func()->count($unpublishedCase) + 'number_unpublished' => $query->func()->count($unpublishedCase), ]); ``` @@ -672,7 +672,7 @@ $query = $cities->find() $q->expr()->gte('population', 999001), ], ['SMALL', 'MEDIUM', 'LARGE'], # values matching conditions - ['string', 'string', 'string'] # type of each value + ['string', 'string', 'string'], # type of each value ); }); # WHERE CASE @@ -693,7 +693,7 @@ $query = $cities->find() $q->expr()->eq('population', 0), ], ['DESERTED', 'INHABITED'], # values matching conditions - ['string', 'string'] # type of each value + ['string', 'string'], # type of each value ); }); # WHERE CASE @@ -793,7 +793,7 @@ class ArticleDto public static function createFromArray( array $data, - bool $ignoreMissing = false + bool $ignoreMissing = false, ): self { $dto = new self(); $dto->id = $data['id']; @@ -873,7 +873,7 @@ readonly class ArticleApiResponse public static function createFromArray( array $data, - bool $ignoreMissing = false + bool $ignoreMissing = false, ): self { return new self( id: $data['id'], @@ -1024,7 +1024,7 @@ $query = $articles->find()->where(function (QueryExpression $exp, SelectQuery $q return $exp->or([ 'promoted' => true, - $query->expr()->and([$author, $published]) + $query->expr()->and([$author, $published]), ]); }); ``` @@ -1162,7 +1162,7 @@ It is also possible to build expressions using SQL functions: $query = $articles->find() ->where(function (QueryExpression $exp, SelectQuery $q) { $year = $q->func()->year([ - 'created' => 'identifier' + 'created' => 'identifier', ]); return $exp @@ -1385,7 +1385,7 @@ use the `identifier()` method: ``` php $query = $countries->find(); $query->select([ - 'year' => $query->func()->year([$query->identifier('created')]) + 'year' => $query->func()->year([$query->identifier('created')]), ]) ->where(function ($exp, $query) { return $exp->gt('population', 100000); @@ -1535,14 +1535,14 @@ $query->select(function ($query) { $stockQuantity = $query->func()->sum('Stocks.quantity'); $totalStockValue = $query->func()->sum( $query->expr(['Stocks.quantity', 'Products.unit_price']) - ->setConjunction('*') + ->setConjunction('*'), ); return [ 'Products.name', 'stock_quantity' => $stockQuantity, 'Products.unit_price', - 'total_stock_value' => $totalStockValue + 'total_stock_value' => $totalStockValue, ]; }) ->innerJoinWith('Stocks') @@ -1577,7 +1577,7 @@ $products->find() ['unit_price', 'tax_percentage'], [20, 5], ['integer', 'integer'], # type of each value - '<=' + '<=', ) ); @@ -1594,7 +1594,7 @@ $articles->find() ['articles.id', 'articles.author_id'], [[10, 10], [30, 10]], ['integer', 'integer'], - 'IN' + 'IN', ), ); @@ -1832,7 +1832,7 @@ $query = $articles->find() 'conditions' => [ 'c.created >' => new DateTime('-5 days'), 'c.moderated' => true, - 'c.article_id = articles.id' + 'c.article_id = articles.id', ] ], ], ['c.created' => 'datetime', 'c.moderated' => 'boolean']); @@ -1993,7 +1993,7 @@ $query->where([ // safe to use with user data in any form $userData, "MATCH (comment) AGAINST ($userData)", - 'created < NOW() - ' . $userData + 'created < NOW() - ' . $userData, ]); ``` @@ -2134,7 +2134,7 @@ $query = $articles->find(); $query->from(['matches' => $matchingComment]) ->innerJoin( ['Articles' => 'articles'], - ['Articles.id' => $query->identifier('matches.id') ] + ['Articles.id' => $query->identifier('matches.id') ], ); ``` diff --git a/docs/en/orm/retrieving-data-and-resultsets.md b/docs/en/orm/retrieving-data-and-resultsets.md index ca72491912..050e1bcbfc 100644 --- a/docs/en/orm/retrieving-data-and-resultsets.md +++ b/docs/en/orm/retrieving-data-and-resultsets.md @@ -136,7 +136,7 @@ You can also provide many commonly used options to `find()`: $query = $articles->find('all', conditions: ['Articles.created >' => new DateTime('-10 days')], contain: ['Authors', 'Comments'], - limit: 10 + limit: 10, ); ``` @@ -309,7 +309,7 @@ list finds. : protected function _getLabel() { return $this->_fields['first_name'] . ' ' . $this->_fields['last_name'] - . ' / ' . __('User ID %s', $this->_fields['user_id']); + . ' / ' . __('User ID %s', $this->_fields['user_id']); } ``` @@ -353,7 +353,7 @@ $query = $comments->find('threaded'); // Expanded default values $query = $comments->find('threaded', keyField: $comments->primaryKey(), - parentField: 'parent_id' + parentField: 'parent_id', ); $results = $query->toArray(); @@ -518,7 +518,7 @@ associations to be loaded: ``` php $query = $articles->find()->contain([ - 'Authors' => ['Addresses'], 'Comments' => ['Authors'] + 'Authors' => ['Addresses'], 'Comments' => ['Authors'], ]); ``` @@ -527,7 +527,7 @@ Alternatively, you can express nested associations using the dot notation: ``` php $query = $articles->find()->contain([ 'Authors.Addresses', - 'Comments.Authors' + 'Comments.Authors', ]); ``` @@ -536,7 +536,7 @@ You can eager load associations as deep as you like: ``` php $query = $products->find()->contain([ 'Shops.Cities.Countries', - 'Shops.Managers' + 'Shops.Managers', ]); ``` @@ -544,7 +544,7 @@ Which is equivalent to calling: ``` php $query = $products->find()->contain([ - 'Shops' => ['Cities.Countries', 'Managers'] + 'Shops' => ['Cities.Countries', 'Managers'], ]); ``` @@ -555,7 +555,7 @@ statements: $query = $this->find()->select([ 'Realestates.id', 'Realestates.title', - 'Realestates.description' + 'Realestates.description', ]) ->contain([ 'RealestateAttributes' => [ @@ -703,7 +703,7 @@ option to sort the data in those associations: ``` php $query->contain([ 'Comments' => [ - 'sort' => ['Comments.created' => 'DESC'] + 'sort' => ['Comments.created' => 'DESC'], ] ]); ``` @@ -1263,7 +1263,7 @@ look something like this: 'awesome' => 39, 'impressive' => 57, 'outstanding' => 10, - 'mind-blowing' => 83 + 'mind-blowing' => 83, ] ``` diff --git a/docs/en/orm/saving-data.md b/docs/en/orm/saving-data.md index 2fa5cc1930..f533be5c33 100644 --- a/docs/en/orm/saving-data.md +++ b/docs/en/orm/saving-data.md @@ -463,7 +463,7 @@ associations: ``` php $articles->patchEntity($article, $this->request->getData(), [ 'validate' => 'custom', - 'associated' => ['Tags', 'Comments.Users' => ['validate' => 'signup']] + 'associated' => ['Tags', 'Comments.Users' => ['validate' => 'signup']], ]); ``` @@ -524,7 +524,7 @@ If a Product belongsToMany Tag: // in the Product Entity protected array $_accessible = [ // .. other properties - 'tags' => true, + 'tags' => true, ]; ``` @@ -627,7 +627,7 @@ array: $patched = $articles->patchEntities( $list, $this->request->getData(), - ['associated' => ['Tags', 'Comments.Users']] + ['associated' => ['Tags', 'Comments.Users']], ); ``` @@ -708,7 +708,7 @@ public function afterMarshal( EventInterface $event, EntityInterface $entity, ArrayObject $data, - ArrayObject $options + ArrayObject $options, ): void { // Don't accept people who have a name starting with J on the 20th // of each month. @@ -750,7 +750,7 @@ $data = $this->request->getData(); // Only allow title to be changed $entity = $this->patchEntity($entity, $data, [ - 'fields' => ['title'] + 'fields' => ['title'], ]); $this->save($entity); ``` @@ -762,7 +762,7 @@ You can also control which properties can be assigned for associations: // and the tag name is the only column that can be set $entity = $this->patchEntity($entity, $data, [ 'fields' => ['title', 'tags'], - 'associated' => ['Tags' => ['fields' => ['name']]] + 'associated' => ['Tags' => ['fields' => ['name']]], ]); $this->save($entity); ``` @@ -916,10 +916,10 @@ array: ``` php $companies->save($entity, [ - 'associated' => [ + 'associated' => [ 'Employees', - 'Employees.Addresses' - ] + 'Employees.Addresses', + ] ]); ``` @@ -952,7 +952,7 @@ $data = [ $articles = $this->fetchTable('Articles'); $article = $articles->newEntity($data, [ - 'associated' => ['Users'] + 'associated' => ['Users'], ]); $articles->save($article); @@ -975,7 +975,7 @@ $data = [ $users = $this->fetchTable('Users'); $user = $users->newEntity($data, [ - 'associated' => ['Profiles'] + 'associated' => ['Profiles'], ]); $users->save($user); ``` @@ -991,13 +991,13 @@ $data = [ 'title' => 'First Post', 'comments' => [ ['body' => 'Best post ever'], - ['body' => 'I really like this.'] + ['body' => 'I really like this.'], ] ]; $articles = $this->fetchTable('Articles'); $article = $articles->newEntity($data, [ - 'associated' => ['Comments'] + 'associated' => ['Comments'], ]); $articles->save($article); ``` @@ -1049,13 +1049,13 @@ $data = [ 'title' => 'First Post', 'tags' => [ ['tag' => 'CakePHP'], - ['tag' => 'Framework'] + ['tag' => 'Framework'], ] ]; $articles = $this->fetchTable('Articles'); $article = $articles->newEntity($data, [ - 'associated' => ['Tags'] + 'associated' => ['Tags'], ]); $articles->save($article); ``` @@ -1151,7 +1151,7 @@ entity, you can create one using `newEntity()`: $coursesMembershipsTable = $this->fetchTable('CoursesMemberships'); $student->courses[0]->_joinData = $coursesMembershipsTable->newEntity([ 'grade' => 80.12, - 'days_attended' => 30 + 'days_attended' => 30, ]); $studentsTable->save($student); @@ -1170,14 +1170,14 @@ $data = [ 'id' => 10, '_joinData' => [ 'grade' => 80.12, - 'days_attended' => 30 + 'days_attended' => 30, ] ], // Other courses. ] ]; $student = $this->Students->newEntity($data, [ - 'associated' => ['Courses._joinData'] + 'associated' => ['Courses._joinData'], ]); ``` @@ -1240,7 +1240,7 @@ representation: $user = new User([ 'preferences' => [ 'sports' => ['football', 'baseball'], - 'books' => ['Mastering PHP', 'Hamlet'] + 'books' => ['Mastering PHP', 'Hamlet'], ] ]); $usersTable->save($user); @@ -1354,11 +1354,11 @@ be an array of entities created using `newEntities()` / `patchEntities()`. $data = [ [ 'title' => 'First post', - 'published' => 1 + 'published' => 1, ], [ 'title' => 'Second post', - 'published' => 1 + 'published' => 1, ], ]; @@ -1384,10 +1384,10 @@ function publishAllUnpublished() $this->updateAll( [ // fields 'published' => true, - 'publish_date' => DateTime::now() + 'publish_date' => DateTime::now(), ], [ // conditions - 'published' => false + 'published' => false, ] ); } diff --git a/docs/en/orm/schema-system.md b/docs/en/orm/schema-system.md index ee9cd4aa8c..91524343a3 100644 --- a/docs/en/orm/schema-system.md +++ b/docs/en/orm/schema-system.md @@ -25,18 +25,18 @@ use Cake\Database\Schema\TableSchema; // Create a table one column at a time. $schema = new TableSchema('posts'); $schema->addColumn('id', [ - 'type' => 'integer', - 'length' => 11, - 'null' => false, - 'default' => null, + 'type' => 'integer', + 'length' => 11, + 'null' => false, + 'default' => null, ])->addColumn('title', [ - 'type' => 'string', - 'length' => 255, - // Create a fixed length (char field) - 'fixed' => true + 'type' => 'string', + 'length' => 255, + // Create a fixed length (char field) + 'fixed' => true, ])->addConstraint('primary', [ - 'type' => 'primary', - 'columns' => ['id'] + 'type' => 'primary', + 'columns' => ['id'], ]); // Schema\TableSchema classes could also be created with array data @@ -51,7 +51,7 @@ following two forms are equivalent: $schema->addColumn('title', 'string'); // and $schema->addColumn('title', [ - 'type' => 'string' + 'type' => 'string', ]); ``` @@ -82,32 +82,32 @@ methods. An example of both methods is: ``` php $schema = new TableSchema('posts'); $schema->addColumn('id', 'integer') - ->addColumn('author_id', 'integer') - ->addColumn('title', 'string') - ->addColumn('slug', 'string'); + ->addColumn('author_id', 'integer') + ->addColumn('title', 'string') + ->addColumn('slug', 'string'); // Add a primary key. $schema->addConstraint('primary', [ - 'type' => 'primary', - 'columns' => ['id'] + 'type' => 'primary', + 'columns' => ['id'], ]); // Add a unique key $schema->addConstraint('slug_idx', [ - 'columns' => ['slug'], - 'type' => 'unique', + 'columns' => ['slug'], + 'type' => 'unique', ]); // Add index $schema->addIndex('slug_title', [ - 'columns' => ['slug', 'title'], - 'type' => 'index' + 'columns' => ['slug', 'title'], + 'type' => 'index', ]); // Add a foreign key $schema->addConstraint('author_id_idx', [ - 'columns' => ['author_id'], - 'type' => 'foreign', - 'references' => ['authors', 'id'], - 'update' => 'cascade', - 'delete' => 'cascade' + 'columns' => ['author_id'], + 'type' => 'foreign', + 'references' => ['authors', 'id'], + 'update' => 'cascade', + 'delete' => 'cascade', ]); ``` @@ -120,7 +120,7 @@ $schema = new TableSchema('posts'); $schema->addColumn('id', 'integer') ->addConstraint('primary', [ 'type' => 'primary', - 'columns' => ['id'] + 'columns' => ['id'], ]); ``` @@ -148,7 +148,7 @@ $schema->addColumn('id', [ ->addColumn('account_id', 'integer') ->addConstraint('primary', [ 'type' => 'primary', - 'columns' => ['id', 'account_id'] + 'columns' => ['id', 'account_id'], ]); ``` @@ -186,8 +186,8 @@ used to add table options: ``` php $schema->options([ - 'engine' => 'InnoDB', - 'collate' => 'utf8_unicode_ci', + 'engine' => 'InnoDB', + 'collate' => 'utf8_unicode_ci', ]); ``` @@ -206,7 +206,7 @@ $schema = new TableSchema('posts', $fields, $indexes); // Create a table $queries = $schema->createSql($db); foreach ($queries as $sql) { - $db->execute($sql); + $db->execute($sql); } // Drop a table diff --git a/docs/en/orm/table-objects.md b/docs/en/orm/table-objects.md index 8c6ef190d2..a21c16ceb1 100644 --- a/docs/en/orm/table-objects.md +++ b/docs/en/orm/table-objects.md @@ -399,7 +399,7 @@ You can manage event priorities in one of a few ways: $events = parent::implementedEvents(); $events['Model.beforeDelete'] = [ 'callable' => 'beforeDelete', - 'priority' => 3 + 'priority' => 3, ]; return $events; @@ -450,7 +450,7 @@ class ArticlesTable extends Table 'events' => [ 'Model.beforeSave' => [ 'created_at' => 'new', - 'modified_at' => 'always' + 'modified_at' => 'always', ] ] ]); @@ -512,7 +512,7 @@ $articles = FactoryLocator::get('Table')->get('Articles', [ 'schema' => $schemaObject, 'entityClass' => 'Custom\EntityClass', 'eventManager' => $eventManager, - 'behaviors' => $behaviorRegistry + 'behaviors' => $behaviorRegistry, ]); ``` diff --git a/docs/en/orm/validation.md b/docs/en/orm/validation.md index 0d263486b1..23a0b164ee 100644 --- a/docs/en/orm/validation.md +++ b/docs/en/orm/validation.md @@ -44,7 +44,7 @@ If you'd like to disable validation when converting request data, set the ``` php $article = $articles->newEntity( $this->request->getData(), - ['validate' => false] + ['validate' => false], ); ``` @@ -52,7 +52,7 @@ The same can be said about the `patchEntity()` method: ``` php $article = $articles->patchEntity($article, $newData, [ - 'validate' => false + 'validate' => false, ]); ``` @@ -102,7 +102,7 @@ want applied: ``` php $article = $articles->newEntity( $this->request->getData(), - ['validate' => 'update'] + ['validate' => 'update'], ); ``` @@ -138,25 +138,25 @@ of the associations to be converted: ``` php $data = [ - 'title' => 'My title', - 'body' => 'The text', - 'user_id' => 1, - 'user' => [ - 'username' => 'mark', - ], - 'comments' => [ - ['body' => 'First comment'], - ['body' => 'Second comment'], - ], - ]; - - $article = $articles->patchEntity($article, $data, [ - 'validate' => 'update', - 'associated' => [ - 'Users' => ['validate' => 'signup'], - 'Comments' => ['validate' => 'custom'], - ], - ]); + 'title' => 'My title', + 'body' => 'The text', + 'user_id' => 1, + 'user' => [ + 'username' => 'mark', + ], + 'comments' => [ + ['body' => 'First comment'], + ['body' => 'Second comment'], + ], +]; + +$article = $articles->patchEntity($article, $data, [ + 'validate' => 'update', + 'associated' => [ + 'Users' => ['validate' => 'signup'], + 'Comments' => ['validate' => 'custom'], + ], +]); ``` ## Combining Validators @@ -356,7 +356,7 @@ message as options: ``` php $rules->add([$this, 'isValidState'], 'validState', [ 'errorField' => 'status', - 'message' => 'This invoice cannot be moved to that status.' + 'message' => 'This invoice cannot be moved to that status.', ]); ``` @@ -380,7 +380,7 @@ $rules->add($rules->isUnique(['email'])); // A list of fields $rules->add($rules->isUnique( ['username', 'account_id'], - 'This username & account_id combination has already been used.' + 'This username & account_id combination has already been used.', )); ``` @@ -395,7 +395,7 @@ To simulate this, set the `allowMultipleNulls` options to true: ``` php $rules->add($rules->isUnique( ['username', 'account_id'], - ['allowMultipleNulls' => true] + ['allowMultipleNulls' => true], )); ``` @@ -426,7 +426,7 @@ are null: $rules->add($rules->existsIn( ['parent_id', 'site_id'], // Schema: parent_id NULL, site_id NOT NULL 'ParentNodes', - ['allowNullableNulls' => true] + ['allowNullableNulls' => true], )); // A Node however should in addition also always reference a Site. @@ -443,7 +443,7 @@ unique checks using `allowMultipleNulls`: $rules->add($rules->existsIn( ['parent_id', 'site_id'], 'ParentNodes', - ['allowMultipleNulls' => false] + ['allowMultipleNulls' => false], )); ``` @@ -489,14 +489,14 @@ have related records depending on the mode used: $rules->addUpdate($rules->isLinkedTo( 'Articles', 'article', - 'Requires an article' + 'Requires an article', )); // Ensure that an article has no linked comments during delete. $rules->addDelete($rules->isNotLinkedTo( 'Comments', 'comments', - 'Must have zero comments before deletion.' + 'Must have zero comments before deletion.', )); ``` @@ -563,7 +563,7 @@ $rules->add( 'errorField' => 'length', 'message' => 'Generic error message used when `false` is returned', ] - ); +); ``` As of 5.2.0, you can also provide a `Closure` for the `message` key. When @@ -578,7 +578,7 @@ $rules->add( 'message' => function ($entity, $options) { return sprintf( 'Article with ID %s does not exist', - $entity->article_id + $entity->article_id, ); } ] @@ -669,12 +669,12 @@ objects when calling `newEntity()` or `patchEntity()`: ``` php $validatedEntity = $articlesTable->newEntity( $unsafeData, - ['validate' => 'customName'] + ['validate' => 'customName'], ); $validatedEntity = $articlesTable->patchEntity( $entity, $unsafeData, - ['validate' => 'customName'] + ['validate' => 'customName'], ); ``` diff --git a/docs/en/security/csrf.md b/docs/en/security/csrf.md index 066d45ebdc..ff44256b47 100644 --- a/docs/en/security/csrf.md +++ b/docs/en/security/csrf.md @@ -181,7 +181,7 @@ defining a script block like this: ``` php echo $this->Html->scriptBlock(sprintf( 'var csrfToken = %s;', - json_encode($this->request->getAttribute('csrfToken')) + json_encode($this->request->getAttribute('csrfToken')), )); ``` diff --git a/docs/en/tutorials-and-examples/cms/authorization.md b/docs/en/tutorials-and-examples/cms/authorization.md index b041871a11..236fc13073 100644 --- a/docs/en/tutorials-and-examples/cms/authorization.md +++ b/docs/en/tutorials-and-examples/cms/authorization.md @@ -242,7 +242,7 @@ public function edit($slug) if ($this->request->is(['post', 'put'])) { $this->Articles->patchEntity($article, $this->request->getData(), [ // Added: Disable modification of user_id. - 'accessibleFields' => ['user_id' => false] + 'accessibleFields' => ['user_id' => false], ]); if ($this->Articles->save($article)) { $this->Flash->success(__('Your article has been updated.')); diff --git a/docs/en/tutorials-and-examples/cms/tags-and-users.md b/docs/en/tutorials-and-examples/cms/tags-and-users.md index 91db727055..7d1826c5d1 100644 --- a/docs/en/tutorials-and-examples/cms/tags-and-users.md +++ b/docs/en/tutorials-and-examples/cms/tags-and-users.md @@ -206,7 +206,7 @@ public function tags() // Pass variables into the view template context. $this->set([ 'articles' => $articles, - 'tags' => $tags + 'tags' => $tags, ]); } ``` @@ -227,7 +227,7 @@ public function tags(...$tags) // Pass variables into the view template context. $this->set([ 'articles' => $articles, - 'tags' => $tags + 'tags' => $tags, ]); } ``` @@ -302,7 +302,7 @@ view file for our `tags()` action:

Html->link( $article->title, - ['controller' => 'Articles', 'action' => 'view', $article->slug] + ['controller' => 'Articles', 'action' => 'view', $article->slug], ) ?>

created) ?> @@ -349,7 +349,7 @@ use Cake\Collection\Collection; // Update the accessible property to contain `tag_string` protected array $_accessible = [ //other fields... - 'tag_string' => true + 'tag_string' => true, ]; protected function _getTagString() @@ -401,8 +401,8 @@ You should also update the view method to allow retrieving existing tags: public function view($slug = null) { - // Update retrieving tags with contain() - $article = $this->Articles + // Update retrieving tags with contain() + $article = $this->Articles ->findBySlug($slug) ->contain('Tags') ->firstOrFail(); @@ -485,7 +485,7 @@ public function initialize(array $config): void // Change this line $this->belongsToMany('Tags', [ 'joinTable' => 'articles_tags', - 'dependent' => true + 'dependent' => true, ]); } ``` diff --git a/docs/en/views.md b/docs/en/views.md index 556916e814..6152ee07cc 100644 --- a/docs/en/views.md +++ b/docs/en/views.md @@ -96,7 +96,7 @@ The following is an example using `foreach`: ``` php ``` @@ -105,11 +105,11 @@ Another example, using if/elseif/else. Notice the colons: ``` php -

Hi Sally

+

Hi Sally

-

Hi Joe

+

Hi Joe

-

Hi unknown user

+

Hi unknown user

``` @@ -637,13 +637,13 @@ cached result. For example: echo $this->element( 'helpbox', ['var' => $var], - ['cache' => ['key' => 'first_use', 'config' => 'view_long']] + ['cache' => ['key' => 'first_use', 'config' => 'view_long']], ); echo $this->element( 'helpbox', ['var' => $differenVar], - ['cache' => ['key' => 'second_use', 'config' => 'view_long']] + ['cache' => ['key' => 'second_use', 'config' => 'view_long']], ); ``` diff --git a/docs/en/views/cells.md b/docs/en/views/cells.md index 2e3154e984..406647325c 100644 --- a/docs/en/views/cells.md +++ b/docs/en/views/cells.md @@ -198,7 +198,7 @@ $cell = $this->cell('Inbox', [], ['cache' => ['config' => 'cell_cache']]); // Specify the key and config to use. $cell = $this->cell('Inbox', [], [ - 'cache' => ['config' => 'cell_cache', 'key' => 'inbox_' . $user->id] + 'cache' => ['config' => 'cell_cache', 'key' => 'inbox_' . $user->id], ]); ``` diff --git a/docs/en/views/helpers.md b/docs/en/views/helpers.md index bfa959570c..3dfdf70873 100644 --- a/docs/en/views/helpers.md +++ b/docs/en/views/helpers.md @@ -338,7 +338,7 @@ class AwesomeHelper extends Helper { // set meta description return $this->Html->meta( - 'description', $this->getView()->get('metaDescription'), ['block' => 'meta'] + 'description', $this->getView()->get('metaDescription'), ['block' => 'meta'], ); } } @@ -356,7 +356,7 @@ class AwesomeHelper extends Helper { return $this->getView()->element( '/path/to/element', - ['foo'=>'bar','bar'=>'foo'] + ['foo'=>'bar','bar'=>'foo'], ); } } diff --git a/docs/en/views/helpers/breadcrumbs.md b/docs/en/views/helpers/breadcrumbs.md index f156068008..e5cc04c7fb 100644 --- a/docs/en/views/helpers/breadcrumbs.md +++ b/docs/en/views/helpers/breadcrumbs.md @@ -22,13 +22,13 @@ In addition to adding to the end of the trail, you can do a variety of operation // Add at the end of the trail $this->Breadcrumbs->add( 'Products', - ['controller' => 'products', 'action' => 'index'] + ['controller' => 'products', 'action' => 'index'], ); // Prepended crumbs will be put at the top of the list $this->Breadcrumbs->prepend( 'Products', - ['controller' => 'products', 'action' => 'index'] + ['controller' => 'products', 'action' => 'index'], ); // Insert in a specific slot. If the slot is out of @@ -36,7 +36,7 @@ $this->Breadcrumbs->prepend( $this->Breadcrumbs->insertAt( 2, 'Products', - ['controller' => 'products', 'action' => 'index'] + ['controller' => 'products', 'action' => 'index'], ); // Insert before another crumb, based on the title. @@ -45,7 +45,7 @@ $this->Breadcrumbs->insertAt( $this->Breadcrumbs->insertBefore( 'Products', 'A product name 1', // the title of the crumb to insert before - ['controller' => 'products', 'action' => 'index'] + ['controller' => 'products', 'action' => 'index'], ); // Insert after another crumb, based on the title. @@ -54,7 +54,7 @@ $this->Breadcrumbs->insertBefore( $this->Breadcrumbs->insertAfter( 'Products', 'A product name 2', // the title of the crumb to insert after - ['controller' => 'products', 'action' => 'index'] + ['controller' => 'products', 'action' => 'index'], ); ``` @@ -124,7 +124,7 @@ Here is an example of how to render a trail: ``` php echo $this->Breadcrumbs->render( ['class' => 'breadcrumbs-trail'], - ['separator' => ''] + ['separator' => ''], ); ``` @@ -139,7 +139,7 @@ It includes four templates, with the following default declaration: 'wrapper' => '{{content}}', 'item' => '{{title}}{{separator}}', 'itemWithoutLink' => '{{title}}{{separator}}', - 'separator' => '{{separator}}' + 'separator' => '{{separator}}', ] ``` @@ -157,7 +157,7 @@ allows you to add your own template variables in the various templates: ``` php $this->Breadcrumbs->setTemplates([ - 'item' => '{{icon}}{{title}}{{separator}}' + 'item' => '{{icon}}{{title}}{{separator}}', ]); ``` diff --git a/docs/en/views/helpers/flash.md b/docs/en/views/helpers/flash.md index 9e22bab7de..df82daee3b 100644 --- a/docs/en/views/helpers/flash.md +++ b/docs/en/views/helpers/flash.md @@ -33,17 +33,17 @@ You can also override any of the options that were set in FlashComponent: ``` php // In your Controller $this->Flash->set('The user has been saved.', [ - 'element' => 'success' + 'element' => 'success', ]); // In your template file: Will use great_success.php instead of success.php Flash->render('flash', [ - 'element' => 'great_success' + 'element' => 'great_success', ]); // In your template file: the flashy element file from the Company Plugin Flash->render('flash', [ - 'element' => 'Company.flashy' + 'element' => 'Company.flashy', ]); ``` diff --git a/docs/en/views/helpers/form.md b/docs/en/views/helpers/form.md index 6854058c2b..5ea671fa8e 100644 --- a/docs/en/views/helpers/form.md +++ b/docs/en/views/helpers/form.md @@ -620,7 +620,7 @@ as well as HTML attributes. This subsection will cover the options specific to ``` php echo $this->Form->control('name', [ - 'label' => 'The User Alias' + 'label' => 'The User Alias', ]); ``` @@ -663,7 +663,7 @@ as well as HTML attributes. This subsection will cover the options specific to echo $this->Form->control('name', [ 'label' => [ 'class' => 'thingy', - 'text' => 'The User Alias' + 'text' => 'The User Alias', ] ]); ``` @@ -701,7 +701,7 @@ as well as HTML attributes. This subsection will cover the options specific to ``` php $this->Form->control('name', [ - 'error' => ['Not long enough' => __('This is not long enough')] + 'error' => ['Not long enough' => __('This is not long enough')], ]); ``` @@ -1005,7 +1005,7 @@ methods are described in each method's own section.) [1, 2, 3, 4, 5], [ 'multiple' => true, - 'value' => [1, 3] + 'value' => [1, 3], ] ); ``` @@ -1026,7 +1026,7 @@ methods are described in each method's own section.) echo $this->Form->select( 'field', [1, 2, 3, 4, 5], - ['empty' => '(choose one)'] + ['empty' => '(choose one)'], ); ``` @@ -1141,7 +1141,7 @@ $options = $examples->map(function ($value, $key) { return [ 'value' => $value->id, 'text' => $value->name, - 'data-created' => $value->created + 'data-created' => $value->created, ]; }); ``` @@ -1420,7 +1420,7 @@ For example: echo $this->Form->select('field', [ 'Value 1' => 'Label 1', 'Value 2' => 'Label 2', - 'Value 3' => 'Label 3' + 'Value 3' => 'Label 3', ]); ``` @@ -1543,10 +1543,10 @@ certain behaviors of the `select()` method. ``` php $options = [ 'Value 1' => 'Label 1', - 'Value 2' => 'Label 2' + 'Value 2' => 'Label 2', ]; echo $this->Form->select('field', $options, [ - 'multiple' => 'checkbox' + 'multiple' => 'checkbox', ]); ``` @@ -1579,10 +1579,10 @@ certain behaviors of the `select()` method. $options = [ 'M' => 'Masculine', 'F' => 'Feminine', - 'N' => 'Neuter' + 'N' => 'Neuter', ]; echo $this->Form->select('gender', $options, [ - 'disabled' => ['M', 'N'] + 'disabled' => ['M', 'N'], ]); ``` @@ -1601,11 +1601,11 @@ certain behaviors of the `select()` method. ``` php $options = [ 'Value 1' => 'Label 1', - 'Value 2' => 'Label 2' + 'Value 2' => 'Label 2', ]; echo $this->Form->select('field', $options, [ 'multiple' => 'checkbox', - 'disabled' => ['Value 1'] + 'disabled' => ['Value 1'], ]); ``` @@ -1658,7 +1658,7 @@ to your form's view template file: ``` php echo $this->Form->control('submittedfile', [ - 'type' => 'file' + 'type' => 'file', ]); // OR @@ -1677,9 +1677,9 @@ from `$_accessible`. Alternatively, you can unset the index by using ``` php public function beforeMarshal(\Cake\Event\EventInterface $event, \ArrayObject $data, \ArrayObject $options): void { - if ($data['submittedfile'] === '') { - unset($data['submittedfile']); - } + if ($data['submittedfile'] === '') { + unset($data['submittedfile']); + } } ``` @@ -1834,7 +1834,7 @@ would do the following: ``` php echo $this->Form->year('purchased', [ 'min' => 2000, - 'max' => date('Y') + 'max' => date('Y'), ]); ``` @@ -2376,13 +2376,13 @@ For example: ``` php // Add custom radio wrapping HTML $this->Form->setTemplates([ - 'radioContainer' => '
{{content}}
' + 'radioContainer' => '
{{content}}
', ]); // Create a radio set with our custom wrapping div. echo $this->Form->control('email_notifications', [ 'options' => ['y', 'n'], - 'type' => 'radio' + 'type' => 'radio', ]); ``` @@ -2399,7 +2399,7 @@ For example: ``` php // Add custom radio form group $this->Form->setTemplates([ - 'radioFormGroup' => '
{{label}}{{input}}
' + 'radioFormGroup' => '
{{label}}{{input}}
', ]); ``` @@ -2414,7 +2414,7 @@ For example: // Add a template with the help placeholder. $this->Form->setTemplates([ 'inputContainer' => '
- {{content}} {{help}}
' + {{content}} {{help}}', ]); // Generate an input and populate the help variable @@ -2473,7 +2473,7 @@ Generates a set of controls for the given context wrapped in a ``` php echo $this->Form->controls([ 'name', - 'email' + 'email', ]); ``` @@ -2671,7 +2671,7 @@ class AutocompleteWidget implements WidgetInterface return $this->_templates->format('autocomplete', [ 'name' => $data['name'], - 'attrs' => $this->_templates->formatAttributes($data, ['name']) + 'attrs' => $this->_templates->formatAttributes($data, ['name']), ]); } @@ -2688,7 +2688,7 @@ template, such as: ``` php $this->Form->setTemplates([ - 'autocomplete' => '' + 'autocomplete' => '', ]); ``` @@ -2734,7 +2734,7 @@ widgets using the `addWidget()` method would look like: // Using a classname. $this->Form->addWidget( 'autocomplete', - ['Autocomplete', 'text', 'label'] + ['Autocomplete', 'text', 'label'], ); // Using an instance - requires you to resolve dependencies. diff --git a/docs/en/views/helpers/html.md b/docs/en/views/helpers/html.md index 06be4f6627..95d72e8cda 100644 --- a/docs/en/views/helpers/html.md +++ b/docs/en/views/helpers/html.md @@ -123,7 +123,7 @@ dynamic. : echo $this->Html->style([ 'background' => '#633', 'border-bottom' => '1px solid #000', - 'padding' => '10px' + 'padding' => '10px', ]); ``` @@ -157,7 +157,7 @@ CakePHP contains a few shortcuts: echo $this->Html->meta( 'favicon.ico', '/favicon.ico', - ['type' => 'icon'] + ['type' => 'icon'], ); // Output (line breaks added) // Note: The helper code makes two meta tags to ensure the @@ -177,7 +177,7 @@ echo $this->Html->meta( echo $this->Html->meta( 'Comments', '/comments/index.rss', - ['type' => 'rss'] + ['type' => 'rss'], ); // Output (line breaks added) Html->meta( 'keywords', - 'enter any meta keyword here' + 'enter any meta keyword here', ); // Output echo $this->Html->meta( 'description', - 'enter any meta description here' + 'enter any meta description here', ); // Output @@ -216,7 +216,7 @@ In addition to making predefined meta tags, you can create link elements: ``` php Html->meta([ 'link' => 'http://example.com/manifest', - 'rel' => 'manifest' + 'rel' => 'manifest', ]); ?> // Output @@ -253,7 +253,7 @@ To create an image link specify the link destination using the ``` php echo $this->Html->image("recipes/6.jpg", [ "alt" => "Brownies", - 'url' => ['controller' => 'Recipes', 'action' => 'view', 6] + 'url' => ['controller' => 'Recipes', 'action' => 'view', 6], ]); ``` @@ -318,7 +318,7 @@ specify attributes for the element and whether or not the echo $this->Html->link( 'Enter', '/pages/home', - ['class' => 'button', 'target' => '_blank'] + ['class' => 'button', 'target' => '_blank'], ); ``` @@ -333,7 +333,7 @@ Use `'_full'=>true` option for absolute URLs: ``` php echo $this->Html->link( 'Dashboard', - ['controller' => 'Dashboards', 'action' => 'index', '_full' => true] + ['controller' => 'Dashboards', 'action' => 'index', '_full' => true], ); ``` @@ -350,7 +350,7 @@ dialog: echo $this->Html->link( 'Delete', ['controller' => 'Recipes', 'action' => 'delete', 6], - ['confirm' => 'Are you sure you wish to delete this recipe?'] + ['confirm' => 'Are you sure you wish to delete this recipe?'], ); ``` @@ -372,7 +372,7 @@ echo $this->Html->link('View image', [ 'controller' => 'Images', 'action' => 'view', 1, - '?' => ['height' => 400, 'width' => 500] + '?' => ['height' => 400, 'width' => 500], ]); ``` @@ -390,7 +390,7 @@ entities. To disable this conversion, set the escape option to echo $this->Html->link( $this->Html->image("recipes/6.jpg", ["alt" => "Brownies"]), "recipes/view/6", - ['escape' => false] + ['escape' => false], ); ``` @@ -410,7 +410,7 @@ escaping of title and not the attributes. : echo $this->Html->link( $this->Html->image('recipes/6.jpg', ['alt' => 'Brownies']), 'recipes/view/6', - ['escapeTitle' => false, 'title' => 'hi "howdy"'] + ['escapeTitle' => false, 'title' => 'hi "howdy"'], ); ``` @@ -464,7 +464,7 @@ Returns a formatted audio/video tag: Html->media('video.mp4', [ 'fullBase' => true, - 'text' => 'Fallback text' + 'text' => 'Fallback text', ]) ?> // Output @@ -472,7 +472,7 @@ Returns a formatted audio/video tag: Html->media( ['video.mp4', ['src' => 'video.ogg', 'type' => "video/ogg; codecs='theora, vorbis'"]], - ['autoplay'] + ['autoplay'], ) ?> // Output @@ -649,7 +649,7 @@ Creates an importmap script tag for your JavaScri // In the head tag of your layout echo $this->Html->importmap([ 'jquery' => 'jquery.js', - 'wysiwyg' => '/editor/wysiwyg.js' + 'wysiwyg' => '/editor/wysiwyg.js', ]); ``` @@ -670,7 +670,7 @@ Generating maps with imports, scopes and integrity: echo $this->Html->importmap([ 'imports' => [ 'jquery' => 'jquery-3.7.1.min.js', - 'wysiwyg' => '/editor/wysiwyg.js' + 'wysiwyg' => '/editor/wysiwyg.js', ], 'scopes' => [ 'scoped/' => [ @@ -769,7 +769,7 @@ Output: echo $this->Html->tableHeaders( ['Date', 'Title','Active'], ['class' => 'status'], - ['class' => 'product_table'] + ['class' => 'product_table'], ); ``` @@ -790,7 +790,7 @@ defaults provided in the `$thOptions`: echo $this->Html->tableHeaders([ 'id', ['Name' => ['class' => 'highlight']], - ['Date' => ['class' => 'sortable']] + ['Date' => ['class' => 'sortable']], ]); ``` @@ -881,7 +881,7 @@ echo $this->Html->tableCells( ['Orange', 'Orange'], ['Yellow', 'Banana'], ], - ['class' => 'darker'] + ['class' => 'darker'], ); ``` @@ -902,7 +902,7 @@ Load an array of templates to add/replace templates: ``` php // Load specific templates. $this->Html->setTemplates([ - 'javascriptlink' => '' + 'javascriptlink' => '', ]); ``` @@ -919,7 +919,7 @@ When loading files of templates, your file should look like: ``` php '' + 'javascriptlink' => '', ]; ``` diff --git a/docs/en/views/helpers/paginator.md b/docs/en/views/helpers/paginator.md index a856dba48d..0a07f82f36 100644 --- a/docs/en/views/helpers/paginator.md +++ b/docs/en/views/helpers/paginator.md @@ -80,7 +80,7 @@ $result = $this->Paginator->getTemplates('number'); // Change a template $this->Paginator->setTemplates([ - 'number' => '{{text}}' + 'number' => '{{text}}', ]); ``` @@ -156,9 +156,9 @@ If you are using HTML like images in your links remember to set escaping off: ``` php echo $this->Paginator->sort( - 'user_id', - 'User account', - ['escape' => false] + 'user_id', + 'User account', + ['escape' => false], ); ``` @@ -328,7 +328,7 @@ available. For example: ``` php echo $this->Paginator->counter( 'Page {{page}} of {{pages}}, showing {{current}} records out of - {{count}} total, starting on record {{start}}, ending on {{end}}' + {{count}} total, starting on record {{start}}, ending on {{end}}', ); ``` @@ -356,7 +356,7 @@ echo $this->Paginator->generateUrl(['sort' => 'title'], 'Comments'); echo $this->Paginator->generateUrl( ['sort' => 'title'], null, - ['controller' => 'Comments'] + ['controller' => 'Comments'], ); ``` @@ -537,7 +537,7 @@ markers: ``` php Paginator->counter( 'Page {{page}} of {{pages}}, showing {{current}} records out of - {{count}} total, starting on record {{start}}, ending on {{end}}' + {{count}} total, starting on record {{start}}, ending on {{end}}', ) ?> ``` @@ -558,7 +558,7 @@ $this->Paginator->options([ 'url' => [ // Additional URL parameters for the 'articles' scope 'articles' => [ - '?' => ['articles' => 'yes'] + '?' => ['articles' => 'yes'], ], // Additional URL parameters for the 'comments' scope 'comments' => [ diff --git a/docs/en/views/helpers/time.md b/docs/en/views/helpers/time.md index 95e8b31bdb..52870872e8 100644 --- a/docs/en/views/helpers/time.md +++ b/docs/en/views/helpers/time.md @@ -24,10 +24,10 @@ posts using the TimeHelper: ``` php echo $this->Time->format( - $post->created, - \IntlDateFormatter::FULL, - false, - $user->time_zone + $post->created, + \IntlDateFormatter::FULL, + false, + $user->time_zone, ); // Will display 'Saturday, August 22, 2011 at 11:53:00 PM GMT' // for a user in GMT+0. While displaying, diff --git a/docs/en/views/helpers/url.md b/docs/en/views/helpers/url.md index e45cee15c4..056c1975b9 100644 --- a/docs/en/views/helpers/url.md +++ b/docs/en/views/helpers/url.md @@ -133,7 +133,7 @@ must return `true` or `'force'` for the timestamp to be appended: echo $this->Html->meta([ 'rel' => 'preload', 'href' => $this->Url->assetUrl( - '/assets/fonts/your-font-pack/your-font-name.woff2' + '/assets/fonts/your-font-pack/your-font-name.woff2', ), 'as' => 'font', ]); diff --git a/docs/en/views/json-and-xml-views.md b/docs/en/views/json-and-xml-views.md index 3ee380a693..e47ff49711 100644 --- a/docs/en/views/json-and-xml-views.md +++ b/docs/en/views/json-and-xml-views.md @@ -224,8 +224,8 @@ class VideosController extends AppController // Format to view mapping $formats = [ - 'xml' => 'Xml', - 'json' => 'Json', + 'xml' => 'Xml', + 'json' => 'Json', ]; // Error on unknown type From cbe1bf5435876bcf585a33e6ab1d68e9392813ba Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 29 Jan 2026 03:57:57 +0100 Subject: [PATCH 2/3] Fix http to https by default. --- docs/en/controllers/pages-controller.md | 2 +- docs/en/controllers/request-response.md | 6 ++-- docs/en/core-libraries/httpclient.md | 20 +++++------ .../internationalization-and-localization.md | 2 +- docs/en/development/routing.md | 2 +- docs/en/intro/conventions.md | 4 +-- docs/en/views/helpers/form.md | 36 +++++++++---------- docs/en/views/helpers/html.md | 8 ++--- docs/en/views/json-and-xml-views.md | 2 +- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/docs/en/controllers/pages-controller.md b/docs/en/controllers/pages-controller.md index ae7286c05b..2245c43416 100644 --- a/docs/en/controllers/pages-controller.md +++ b/docs/en/controllers/pages-controller.md @@ -5,7 +5,7 @@ This is a simple and optional controller for serving up static content. The home you see after installation is generated using this controller and the view file **templates/Pages/home.php**. If you make the view file **templates/Pages/about_us.php** you can access it using the URL -**http://example.com/pages/about_us**. You are free to modify the Pages +**https://example.com/pages/about_us**. You are free to modify the Pages Controller to meet your needs. When you "bake" an app using Composer the Pages Controller is created in your diff --git a/docs/en/controllers/request-response.md b/docs/en/controllers/request-response.md index 8122423dcf..03a748615d 100644 --- a/docs/en/controllers/request-response.md +++ b/docs/en/controllers/request-response.md @@ -788,11 +788,11 @@ $response = $this->response->withFile( The supported options are: -name +name The name allows you to specify an alternate file name to be sent to the user. -download +download A boolean value indicating whether headers should be set to force download. @@ -835,7 +835,7 @@ $response = $response->withHeader('X-Extra', 'My header'); // Set multiple headers $response = $response->withHeader('X-Extra', 'My header') - ->withHeader('Location', 'http://example.com'); + ->withHeader('Location', 'https://example.com'); // Append a value to an existing header $response = $response->withAddedHeader('Set-Cookie', 'remember_me=1'); diff --git a/docs/en/core-libraries/httpclient.md b/docs/en/core-libraries/httpclient.md index 3b57c40e7e..61f2641caa 100644 --- a/docs/en/core-libraries/httpclient.md +++ b/docs/en/core-libraries/httpclient.md @@ -70,7 +70,7 @@ You can include files in request bodies by including a filehandle in the array: ``` php $http = new Client(); -$response = $http->post('http://example.com/api', [ +$response = $http->post('https://example.com/api', [ 'image' => fopen('/path/to/a/file', 'r'), ]); ``` @@ -102,7 +102,7 @@ $file->disposition('attachment'); // Send the request. $response = $http->post( - 'http://example.com/api', + 'https://example.com/api', (string)$data, ['headers' => ['Content-Type' => $data->contentType()]], ); @@ -117,7 +117,7 @@ form encoded. Http\Client exposes this through the type option: // Send a JSON request body. $http = new Client(); $response = $http->post( - 'http://example.com/tasks', + 'https://example.com/tasks', json_encode($data), ['type' => 'json'], ); @@ -132,7 +132,7 @@ you can do the following: // Send a JSON body in a GET request with query string parameters. $http = new Client(); $response = $http->get( - 'http://example.com/tasks', + 'https://example.com/tasks', ['q' => 'test', '_content' => json_encode($data)], ['type' => 'json'], ); @@ -182,7 +182,7 @@ An example of basic authentication: ``` php $http = new Client(); -$response = $http->get('http://example.com/profile/1', [], [ +$response = $http->get('https://example.com/profile/1', [], [ 'auth' => ['username' => 'mark', 'password' => 'secret'], ]); ``` @@ -196,7 +196,7 @@ An example of basic authentication: ``` php $http = new Client(); -$response = $http->get('http://example.com/profile/1', [], [ +$response = $http->get('https://example.com/profile/1', [], [ 'auth' => [ 'type' => 'digest', 'username' => 'mark', @@ -230,7 +230,7 @@ key and consumer secret: ``` php $http = new Client(); -$response = $http->get('http://example.com/profile/1', [], [ +$response = $http->get('https://example.com/profile/1', [], [ 'auth' => [ 'type' => 'oauth', 'consumerKey' => 'bigkey', @@ -262,7 +262,7 @@ Http\Client will assume Basic authentication, unless the type key is set: ``` php $http = new Client(); -$response = $http->get('http://example.com/test.php', [], [ +$response = $http->get('https://example.com/test.php', [], [ 'proxy' => [ 'username' => 'mark', 'password' => 'testing', @@ -426,12 +426,12 @@ XML data is decoded into a `SimpleXMLElement` tree: ``` php // Get some XML $http = new Client(); -$response = $http->get('http://example.com/test.xml'); +$response = $http->get('https://example.com/test.xml'); $xml = $response->getXml(); // Get some JSON $http = new Client(); -$response = $http->get('http://example.com/test.json'); +$response = $http->get('https://example.com/test.json'); $json = $response->getJson(); ``` diff --git a/docs/en/core-libraries/internationalization-and-localization.md b/docs/en/core-libraries/internationalization-and-localization.md index 8dca5b92c6..31c576a605 100644 --- a/docs/en/core-libraries/internationalization-and-localization.md +++ b/docs/en/core-libraries/internationalization-and-localization.md @@ -535,7 +535,7 @@ use Cake\I18n\Package; I18n::config('default', function ($domain, $locale) { $locale = Locale::parseLocale($locale); $lang = $locale['language']; - $messages = file_get_contents("http://example.com/translations/$lang.json"); + $messages = file_get_contents("https://example.com/translations/$lang.json"); return new Package( 'default', // Formatter diff --git a/docs/en/development/routing.md b/docs/en/development/routing.md index 61e94f52d4..63b58818a3 100644 --- a/docs/en/development/routing.md +++ b/docs/en/development/routing.md @@ -1671,7 +1671,7 @@ The above methods also accept an array of options as their second parameter: regardless of debug value. ``` php -// Generates http://example.org/img/logo.png +// Generates https://example.com/img/logo.png $img = Asset::url('logo.png', ['fullBase' => true]); // Generates /img/logo.png?1568563625 diff --git a/docs/en/intro/conventions.md b/docs/en/intro/conventions.md index 3ffb1e2d3e..f845b969c0 100644 --- a/docs/en/intro/conventions.md +++ b/docs/en/intro/conventions.md @@ -23,7 +23,7 @@ For inflection of acronyms it is useful to treat them as words, so `CMS` would b As you've just seen, single word controllers map to a simple lower case URL path. For example, `UsersController` (which would be defined in the file name -**UsersController.php**) is accessed from `http://example.com/users`. +**UsersController.php**) is accessed from `https://example.com/users`. While you can route multiple word controllers in any way you like, the convention is that your URLs are lowercase and dashed using the `DashedRoute` @@ -166,7 +166,7 @@ Here's a final example that ties the conventions together: - View template, found at **templates/Articles/index.php** Using these conventions, CakePHP knows that a request to -`http://example.com/articles` maps to a call on the `index()` method of the +`https://example.com/articles` maps to a call on the `index()` method of the `ArticlesController`, where the `Articles` model is automatically available. None of these relationships have been configured by any means other than by creating classes and files that you'd need to create anyway. diff --git a/docs/en/views/helpers/form.md b/docs/en/views/helpers/form.md index 5ea671fa8e..ec401df90e 100644 --- a/docs/en/views/helpers/form.md +++ b/docs/en/views/helpers/form.md @@ -73,7 +73,7 @@ uses the `Entity` object to automatically detect whether to create an *add* or *edit* form. If the provided entity is not 'new', the form will be created as an *edit* form. -For example, if we browse to **http://example.org/articles/edit/5**, we could +For example, if we browse to **https://example.com/articles/edit/5**, we could do the following: ``` php @@ -390,55 +390,55 @@ The type of control created (when we provide no additional options to specify th generated element type) is inferred via model introspection and depends on the column datatype: -Column Type +Column Type Resulting Form Field -string, uuid (char, varchar, etc.) +string, uuid (char, varchar, etc.) text -boolean, tinyint(1) +boolean, tinyint(1) checkbox -decimal +decimal number -float +float number -integer +integer number -text +text textarea -text, with name of password, passwd +text, with name of password, passwd password -text, with name of email +text, with name of email email -text, with name of tel, telephone, or phone +text, with name of tel, telephone, or phone tel -date +date date -datetime, timestamp +datetime, timestamp datetime-local -datetimefractional, timestampfractional +datetimefractional, timestampfractional datetime-local -time +time time -month +month month -year +year select with years -binary +binary file The `$options` parameter allows you to choose a specific control type if diff --git a/docs/en/views/helpers/html.md b/docs/en/views/helpers/html.md index 95d72e8cda..12bbb7eab0 100644 --- a/docs/en/views/helpers/html.md +++ b/docs/en/views/helpers/html.md @@ -181,7 +181,7 @@ echo $this->Html->meta( ); // Output (line breaks added) Html->meta([ - 'link' => 'http://example.com/manifest', + 'link' => 'https://example.com/manifest', 'rel' => 'manifest', ]); ?> // Output - + ``` Any attributes provided to meta() when called this way will be added to the @@ -275,7 +275,7 @@ echo $this->Html->image("logo.png", ['fullBase' => true]); Will output: ``` html - + ``` You can include image files from any loaded plugin using diff --git a/docs/en/views/json-and-xml-views.md b/docs/en/views/json-and-xml-views.md index e47ff49711..6f53f1e676 100644 --- a/docs/en/views/json-and-xml-views.md +++ b/docs/en/views/json-and-xml-views.md @@ -26,7 +26,7 @@ public function viewClasses(): array You can optionally enable the json and/or xml extensions with [File Extensions](../development/routing#file-extensions). This will allow you to access the `JSON`, `XML` or any other special format views by using a custom URL ending with the name of the -response type as a file extension such as `http://example.com/articles.json`. +response type as a file extension such as `https://example.com/articles.json`. By default, when not enabling [File Extensions](../development/routing#file-extensions), the `Accept` header in the request is used for selecting which type of format should be rendered to the From 7743cfb14730fb715e46dfce243e07852cb6f902 Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 29 Jan 2026 04:18:40 +0100 Subject: [PATCH 3/3] Fix trailing whitespace in PHP code blocks --- docs/en/views/helpers/breadcrumbs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/views/helpers/breadcrumbs.md b/docs/en/views/helpers/breadcrumbs.md index e5cc04c7fb..ef2587c3f2 100644 --- a/docs/en/views/helpers/breadcrumbs.md +++ b/docs/en/views/helpers/breadcrumbs.md @@ -44,7 +44,7 @@ $this->Breadcrumbs->insertAt( // an exception will be raised. $this->Breadcrumbs->insertBefore( 'Products', - 'A product name 1', // the title of the crumb to insert before + 'A product name 1', // the title of the crumb to insert before ['controller' => 'products', 'action' => 'index'], ); @@ -53,7 +53,7 @@ $this->Breadcrumbs->insertBefore( // an exception will be raised. $this->Breadcrumbs->insertAfter( 'Products', - 'A product name 2', // the title of the crumb to insert after + 'A product name 2', // the title of the crumb to insert after ['controller' => 'products', 'action' => 'index'], ); ```