Skip to content

Commit 18e7ea4

Browse files
authored
Fix PHP code style in documentation snippets (#8191)
* 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. * Fix http to https by default. * Fix trailing whitespace in PHP code blocks
1 parent a64c5ba commit 18e7ea4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+599
-599
lines changed

docs/en/appendices/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Would point to the following value:
3737
[
3838
'Cache' => [
3939
'default' => [
40-
'engine' => 'File'
40+
'engine' => 'File',
4141
]
4242
]
4343
]

docs/en/appendices/phpunit-upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ should be converted to:
5858

5959
``` php
6060
->with(
61-
...self::withConsecutive(['firstCallArg'], ['secondCallArg'])
61+
...self::withConsecutive(['firstCallArg'], ['secondCallArg']),
6262
)
6363
```
6464

docs/en/console-commands/commands.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class UserCommand extends Command
173173
{
174174
$parser
175175
->addArgument('name', [
176-
'help' => 'What is your name'
176+
'help' => 'What is your name',
177177
]);
178178

179179
return $parser;
@@ -392,7 +392,7 @@ class UpdateTableCommand extends Command
392392
->setDescription('My cool console app')
393393
->addArgument('table', [
394394
'help' => 'Table to update',
395-
'required' => true
395+
'required' => true,
396396
]);
397397

398398
return $parser;
@@ -403,7 +403,7 @@ class UpdateTableCommand extends Command
403403
$table = $args->getArgument('table');
404404
$this->fetchTable($table)->updateQuery()
405405
->set([
406-
'modified' => new DateTime()
406+
'modified' => new DateTime(),
407407
])
408408
->execute();
409409

@@ -492,7 +492,7 @@ class UpdateTableCommand extends Command
492492
->setDescription('My cool console app')
493493
->addArgument('table', [
494494
'help' => 'Table to update',
495-
'required' => true
495+
'required' => true,
496496
]);
497497

498498
return $parser;
@@ -507,7 +507,7 @@ class UpdateTableCommand extends Command
507507
}
508508
$this->fetchTable($table)->updateQuery()
509509
->set([
510-
'modified' => new DateTime()
510+
'modified' => new DateTime(),
511511
])
512512
->execute();
513513

docs/en/console-commands/option-parsers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ are set to `true`, when they are absent they are set to `false`:
202202
``` php
203203
$parser->addOption('verbose', [
204204
'help' => 'Enable verbose output.',
205-
'boolean' => true
205+
'boolean' => true,
206206
]);
207207
```
208208

@@ -228,7 +228,7 @@ public function getOptionParser()
228228
'description' => [
229229
__("Use this command to grant ACL permissions. Once executed, the "),
230230
__("ARO specified (and its children, if any) will have ALLOW access "),
231-
__("to the specified ACO action (and the ACO's children, if any).")
231+
__("to the specified ACO action (and the ACO's children, if any)."),
232232
],
233233
'arguments' => [
234234
'aro' => ['help' => __('ARO to check.'), 'required' => true],

docs/en/contributing/cakephp-coding-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Use this instead:
7575
$matches = array_intersect_key(
7676
$this->_listeners,
7777
array_flip(
78-
preg_grep($matchPattern, array_keys($this->_listeners), 0)
78+
preg_grep($matchPattern, array_keys($this->_listeners), 0),
7979
)
8080
);
8181
```

docs/en/controllers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ return $this->redirect([
427427
$order->id,
428428
'?' => [
429429
'product' => 'pizza',
430-
'quantity' => 5
430+
'quantity' => 5,
431431
],
432-
'#' => 'top'
432+
'#' => 'top',
433433
]);
434434
```
435435

@@ -438,7 +438,7 @@ Or using a relative or absolute URL:
438438
``` php
439439
return $this->redirect('/orders/confirm');
440440

441-
return $this->redirect('http://www.example.com');
441+
return $this->redirect('https://www.example.com');
442442
```
443443

444444
Or to the referer page:
@@ -471,7 +471,7 @@ the controller's default one:
471471
// In a controller method.
472472
$recentArticles = $this->fetchTable('Articles')->find('all',
473473
limit: 5,
474-
order: 'Articles.created DESC'
474+
order: 'Articles.created DESC',
475475
)
476476
->all();
477477
```

docs/en/controllers/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class SsoComponent extends Component
198198
public function __construct(
199199
ComponentRegistry $registry,
200200
array $config = [],
201-
UserService $users
201+
UserService $users,
202202
) {
203203
parent::__construct($registry, $config);
204204
$this->users = $users;

docs/en/controllers/middleware.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ $middlewareQueue->insertAt(2, $layer);
118118
// an exception will be raised.
119119
$middlewareQueue->insertBefore(
120120
'Cake\Error\Middleware\ErrorHandlerMiddleware',
121-
$layer
121+
$layer,
122122
);
123123

124124
// Insert after another middleware.
125125
// If the named class cannot be found, the
126126
// middleware will added to the end.
127127
$middlewareQueue->insertAfter(
128128
'Cake\Error\Middleware\ErrorHandlerMiddleware',
129-
$layer
129+
$layer,
130130
);
131131
```
132132

@@ -189,7 +189,7 @@ class TrackingCookieMiddleware implements MiddlewareInterface
189189
{
190190
public function process(
191191
ServerRequestInterface $request,
192-
RequestHandlerInterface $handler
192+
RequestHandlerInterface $handler,
193193
): ResponseInterface
194194
{
195195
// Calling $handler->handle() delegates control to the *next* middleware
@@ -201,7 +201,7 @@ class TrackingCookieMiddleware implements MiddlewareInterface
201201
$response = $response->withCookie(new Cookie(
202202
'landing_page',
203203
$request->getRequestTarget(),
204-
$expiry
204+
$expiry,
205205
));
206206
}
207207

@@ -265,7 +265,7 @@ use Cake\Http\Middleware\EncryptedCookieMiddleware;
265265
$cookies = new EncryptedCookieMiddleware(
266266
// Names of cookies to protect
267267
['secrets', 'protected'],
268-
Configure::read('Security.cookieKey')
268+
Configure::read('Security.cookieKey'),
269269
);
270270

271271
$middlewareQueue->add($cookies);

docs/en/controllers/pages-controller.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a simple and optional controller for serving up static content. The home
55
you see after installation is generated using this controller and the view
66
file **templates/Pages/home.php**. If you make the view file
77
**templates/Pages/about_us.php** you can access it using the URL
8-
**http://example.com/pages/about_us**. You are free to modify the Pages
8+
**https://example.com/pages/about_us**. You are free to modify the Pages
99
Controller to meet your needs.
1010

1111
When you "bake" an app using Composer the Pages Controller is created in your

docs/en/controllers/pagination.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class ArticlesController extends AppController
7979
$tags = $this->request->getParam('pass');
8080

8181
$customFinderOptions = [
82-
'tags' => $tags
82+
'tags' => $tags,
8383
];
8484
// We're using the $settings argument to paginate() here.
8585
// But the same structure could be used in $this->paginate
@@ -90,7 +90,7 @@ class ArticlesController extends AppController
9090
// public function findTagged(Query $query, array $tagged = [])
9191
$settings = [
9292
'finder' => [
93-
'tagged' => $customFinderOptions
93+
'tagged' => $customFinderOptions,
9494
]
9595
];
9696
$articles = $this->paginate($this->Articles, $settings);
@@ -153,7 +153,7 @@ call to the `paginate()` method:
153153
// Paginate property
154154
protected array $paginate = [
155155
'Articles' => ['scope' => 'article'],
156-
'Tags' => ['scope' => 'tag']
156+
'Tags' => ['scope' => 'tag'],
157157
];
158158

159159
// In a controller action
@@ -197,7 +197,7 @@ $this->paginate = [
197197

198198
$publishedArticles = $this->paginate(
199199
$this->Articles->find('all', scope: 'published_articles')
200-
->where(['published' => true])
200+
->where(['published' => true]),
201201
);
202202

203203
// Load an additional table object to allow differentiating in the paginator
@@ -209,7 +209,7 @@ $unpublishedArticlesTable = $this->fetchTable('UnpublishedArticles', [
209209

210210
$unpublishedArticles = $this->paginate(
211211
$unpublishedArticlesTable->find('all', scope: 'unpublished_articles')
212-
->where(['published' => false])
212+
->where(['published' => false]),
213213
);
214214
```
215215

@@ -355,7 +355,7 @@ example reducing it to `10`:
355355
``` php
356356
protected array $paginate = [
357357
// Other keys here.
358-
'maxLimit' => 10
358+
'maxLimit' => 10,
359359
];
360360
```
361361

0 commit comments

Comments
 (0)