@wasm-fmt/mago_fmt 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsr.jsonc +1 -1
- package/mago_fmt.d.ts +14 -2
- package/mago_fmt_bg.js +7 -12
- package/mago_fmt_bg.wasm +0 -0
- package/mago_fmt_settings.d.ts +1015 -0
- package/mago_fmt_web.d.ts +1 -1
- package/package.json +2 -5
package/jsr.jsonc
CHANGED
package/mago_fmt.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
import type { Settings } from "./mago_fmt_settings.d.ts";
|
|
5
|
+
export type { Settings };
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* Format PHP code with optional filename and settings.
|
|
11
|
+
* @param code - PHP code to format
|
|
12
|
+
* @param filename - Optional filename for context
|
|
13
|
+
* @param settings - Optional formatter settings
|
|
6
14
|
*/
|
|
7
|
-
export function format(code: string, filename?: string | null, settings?:
|
|
15
|
+
export function format(code: string, filename?: string | null, settings?: Settings | null): string;
|
|
8
16
|
|
|
9
17
|
/**
|
|
10
18
|
* Format PHP code with specified PHP version, optional filename and settings.
|
|
19
|
+
* @param code - PHP code to format
|
|
20
|
+
* @param php_version - PHP version (e.g., '7.4', '8.0', '8.1')
|
|
21
|
+
* @param filename - Optional filename for context
|
|
22
|
+
* @param settings - Optional formatter settings
|
|
11
23
|
*/
|
|
12
|
-
export function format_with_version(code: string, php_version: string, filename?: string | null, settings?:
|
|
24
|
+
export function format_with_version(code: string, php_version: string, filename?: string | null, settings?: Settings | null): string;
|
package/mago_fmt_bg.js
CHANGED
|
@@ -194,9 +194,9 @@ let WASM_VECTOR_LEN = 0;
|
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Format PHP code with optional filename and settings.
|
|
197
|
-
* @param {string} code
|
|
198
|
-
* @param {string | null} [filename]
|
|
199
|
-
* @param {
|
|
197
|
+
* @param {string} code - PHP code to format
|
|
198
|
+
* @param {string | null} [filename] - Optional filename for context
|
|
199
|
+
* @param {Settings | null} [settings] - Optional formatter settings
|
|
200
200
|
* @returns {string}
|
|
201
201
|
*/
|
|
202
202
|
export function format(code, filename, settings) {
|
|
@@ -230,10 +230,10 @@ export function format(code, filename, settings) {
|
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
232
|
* Format PHP code with specified PHP version, optional filename and settings.
|
|
233
|
-
* @param {string} code
|
|
234
|
-
* @param {string} php_version
|
|
235
|
-
* @param {string | null} [filename]
|
|
236
|
-
* @param {
|
|
233
|
+
* @param {string} code - PHP code to format
|
|
234
|
+
* @param {string} php_version - PHP version (e.g., '7.4', '8.0', '8.1')
|
|
235
|
+
* @param {string | null} [filename] - Optional filename for context
|
|
236
|
+
* @param {Settings | null} [settings] - Optional formatter settings
|
|
237
237
|
* @returns {string}
|
|
238
238
|
*/
|
|
239
239
|
export function format_with_version(code, php_version, filename, settings) {
|
|
@@ -435,8 +435,3 @@ export function __wbindgen_object_clone_ref(arg0) {
|
|
|
435
435
|
export function __wbindgen_object_drop_ref(arg0) {
|
|
436
436
|
takeObject(arg0);
|
|
437
437
|
};
|
|
438
|
-
|
|
439
|
-
export function __wbindgen_object_is_undefined(arg0) {
|
|
440
|
-
const ret = getObject(arg0) === undefined;
|
|
441
|
-
return ret;
|
|
442
|
-
};
|
package/mago_fmt_bg.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,1015 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See {@link https://mago.carthage.software/tools/formatter/configuration-reference}
|
|
3
|
+
*/
|
|
4
|
+
export interface Settings {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum line length that the printer will wrap on.
|
|
7
|
+
* @default 120
|
|
8
|
+
*/
|
|
9
|
+
"print-width"?: number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Number of spaces per indentation level.
|
|
13
|
+
* @default 4
|
|
14
|
+
*/
|
|
15
|
+
"tab-width"?: number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Whether to use tabs instead of spaces for indentation.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
"use-tabs"?: boolean;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* End-of-line characters to use.
|
|
25
|
+
* @default "auto"
|
|
26
|
+
*/
|
|
27
|
+
"end-of-line"?: "auto" | "lf" | "crlf" | "cr";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether to use single quotes instead of double quotes for strings.
|
|
31
|
+
*
|
|
32
|
+
* The formatter automatically determines which quotes to use based on the string content,
|
|
33
|
+
* with a preference for single quotes if this option is enabled.
|
|
34
|
+
*
|
|
35
|
+
* Decision logic:
|
|
36
|
+
* - If the string contains more single quotes than double quotes, double quotes are used
|
|
37
|
+
* - If the string contains more double quotes than single quotes, single quotes are used
|
|
38
|
+
* - If equal number of both, single quotes are used if this option is true
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
"single-quote"?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether to add a trailing comma to the last element in multi-line syntactic structures.
|
|
45
|
+
*
|
|
46
|
+
* When enabled, trailing commas are added to lists, arrays, parameter lists,
|
|
47
|
+
* argument lists, and other similar structures when they span multiple lines.
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
"trailing-comma"?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether to remove the trailing PHP close tag (`?>`) from files.
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
"remove-trailing-close-tag"?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Brace placement for control structures (if, for, while, etc.).
|
|
60
|
+
* @default "same-line"
|
|
61
|
+
*
|
|
62
|
+
* @example "same-line"
|
|
63
|
+
* ```php
|
|
64
|
+
* if ($expr) {
|
|
65
|
+
* return 'Hello, world!';
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example "next-line"
|
|
70
|
+
* ```php
|
|
71
|
+
* if ($expr)
|
|
72
|
+
* {
|
|
73
|
+
* return 'Hello, world!';
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
"control-brace-style"?: "same-line" | "next-line";
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Brace placement for closures.
|
|
81
|
+
* @default "same-line"
|
|
82
|
+
*
|
|
83
|
+
* @example "same-line"
|
|
84
|
+
* ```php
|
|
85
|
+
* $closure = function() {
|
|
86
|
+
* return 'Hello, world!';
|
|
87
|
+
* };
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @example "next-line"
|
|
91
|
+
* ```php
|
|
92
|
+
* $closure = function()
|
|
93
|
+
* {
|
|
94
|
+
* return 'Hello, world!';
|
|
95
|
+
* };
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
"closure-brace-style"?: "same-line" | "next-line";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Brace placement for function declarations.
|
|
102
|
+
* @default "next-line"
|
|
103
|
+
*
|
|
104
|
+
* @example "same-line"
|
|
105
|
+
* ```php
|
|
106
|
+
* function foo() {
|
|
107
|
+
* return 'Hello, world!';
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @example "next-line"
|
|
112
|
+
* ```php
|
|
113
|
+
* function foo()
|
|
114
|
+
* {
|
|
115
|
+
* return 'Hello, world!';
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
"function-brace-style"?: "same-line" | "next-line";
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Brace placement for method declarations.
|
|
123
|
+
* @default "next-line"
|
|
124
|
+
*
|
|
125
|
+
* @example "same-line"
|
|
126
|
+
* ```php
|
|
127
|
+
* class Foo
|
|
128
|
+
* {
|
|
129
|
+
* public function bar() {
|
|
130
|
+
* return 'Hello, world!';
|
|
131
|
+
* }
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example "next-line"
|
|
136
|
+
* ```php
|
|
137
|
+
* class Foo
|
|
138
|
+
* {
|
|
139
|
+
* public function bar()
|
|
140
|
+
* {
|
|
141
|
+
* return 'Hello, world!';
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
"method-brace-style"?: "same-line" | "next-line";
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Brace placement for class-like structures (classes, interfaces, traits, enums).
|
|
150
|
+
* @default "next-line"
|
|
151
|
+
*
|
|
152
|
+
* @example "same-line"
|
|
153
|
+
* ```php
|
|
154
|
+
* class Foo {
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example "next-line"
|
|
159
|
+
* ```php
|
|
160
|
+
* class Foo
|
|
161
|
+
* {
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
"classlike-brace-style"?: "same-line" | "next-line";
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Place empty control structure bodies on the same line.
|
|
169
|
+
* @default false
|
|
170
|
+
*
|
|
171
|
+
* @example false
|
|
172
|
+
* ```php
|
|
173
|
+
* if ($expr)
|
|
174
|
+
* {
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @example true
|
|
179
|
+
* ```php
|
|
180
|
+
* if ($expr) {}
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
"inline-empty-control-braces"?: boolean;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Place empty closure bodies on the same line.
|
|
187
|
+
* @default true
|
|
188
|
+
*
|
|
189
|
+
* @example false
|
|
190
|
+
* ```php
|
|
191
|
+
* $closure = function()
|
|
192
|
+
* {
|
|
193
|
+
* };
|
|
194
|
+
* ```
|
|
195
|
+
*
|
|
196
|
+
* @example true
|
|
197
|
+
* ```php
|
|
198
|
+
* $closure = function() {};
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
"inline-empty-closure-braces"?: boolean;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Place empty function bodies on the same line.
|
|
205
|
+
* @default false
|
|
206
|
+
*
|
|
207
|
+
* @example false
|
|
208
|
+
* ```php
|
|
209
|
+
* function foo()
|
|
210
|
+
* {
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @example true
|
|
215
|
+
* ```php
|
|
216
|
+
* function foo() {}
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
"inline-empty-function-braces"?: boolean;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Place empty method bodies on the same line.
|
|
223
|
+
* @default false
|
|
224
|
+
*
|
|
225
|
+
* @example false
|
|
226
|
+
* ```php
|
|
227
|
+
* class Foo
|
|
228
|
+
* {
|
|
229
|
+
* public function bar()
|
|
230
|
+
* {
|
|
231
|
+
* }
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @example true
|
|
236
|
+
* ```php
|
|
237
|
+
* class Foo
|
|
238
|
+
* {
|
|
239
|
+
* public function bar() {}
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
"inline-empty-method-braces"?: boolean;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Place empty constructor bodies on the same line.
|
|
247
|
+
* @default true
|
|
248
|
+
*
|
|
249
|
+
* @example false
|
|
250
|
+
* ```php
|
|
251
|
+
* class Foo {
|
|
252
|
+
* public function __construct()
|
|
253
|
+
* {
|
|
254
|
+
* }
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @example true
|
|
259
|
+
* ```php
|
|
260
|
+
* class Foo {
|
|
261
|
+
* public function __construct() {}
|
|
262
|
+
* }
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
"inline-empty-constructor-braces"?: boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Place empty class-like bodies on the same line.
|
|
269
|
+
* @default true
|
|
270
|
+
*
|
|
271
|
+
* @example false
|
|
272
|
+
* ```php
|
|
273
|
+
* class Foo
|
|
274
|
+
* {
|
|
275
|
+
* }
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @example true
|
|
279
|
+
* ```php
|
|
280
|
+
* class Foo {}
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
"inline-empty-classlike-braces"?: boolean;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Place empty anonymous class bodies on the same line.
|
|
287
|
+
* @default true
|
|
288
|
+
*
|
|
289
|
+
* @example false
|
|
290
|
+
* ```php
|
|
291
|
+
* $anon = new class
|
|
292
|
+
* {
|
|
293
|
+
* };
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @example true
|
|
297
|
+
* ```php
|
|
298
|
+
* $anon = new class {};
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
"inline-empty-anonymous-class-braces"?: boolean;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* How to format broken method/property chains.
|
|
305
|
+
* @default "next-line"
|
|
306
|
+
*
|
|
307
|
+
* @example "next-line"
|
|
308
|
+
* ```php
|
|
309
|
+
* $foo
|
|
310
|
+
* ->bar()
|
|
311
|
+
* ->baz();
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @example "same-line"
|
|
315
|
+
* ```php
|
|
316
|
+
* $foo->bar()
|
|
317
|
+
* ->baz();
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
"method-chain-breaking-style"?: "same-line" | "next-line";
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* When method chaining breaks across lines, place the first method on a new line.
|
|
324
|
+
*
|
|
325
|
+
* This follows PER-CS 4.7: "When [method chaining is] put on separate lines, [...] the first method MUST be on the next line."
|
|
326
|
+
* @default true
|
|
327
|
+
*
|
|
328
|
+
* @example true
|
|
329
|
+
* ```php
|
|
330
|
+
* $this
|
|
331
|
+
* ->getCache()
|
|
332
|
+
* ->forget();
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @example false
|
|
336
|
+
* ```php
|
|
337
|
+
* $this->getCache()
|
|
338
|
+
* ->forget();
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
"first-method-chain-on-new-line"?: boolean;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Whether to preserve line breaks in method chains, even if they could fit on a single line.
|
|
345
|
+
* @default false
|
|
346
|
+
*/
|
|
347
|
+
"preserve-breaking-member-access-chain"?: boolean;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Whether to preserve line breaks in argument lists, even if they could fit on a single line.
|
|
351
|
+
* @default false
|
|
352
|
+
*/
|
|
353
|
+
"preserve-breaking-argument-list"?: boolean;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Whether to preserve line breaks in array-like structures, even if they could fit on a single line.
|
|
357
|
+
* @default true
|
|
358
|
+
*/
|
|
359
|
+
"preserve-breaking-array-like"?: boolean;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Whether to preserve line breaks in parameter lists, even if they could fit on a single line.
|
|
363
|
+
* @default false
|
|
364
|
+
*/
|
|
365
|
+
"preserve-breaking-parameter-list"?: boolean;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Whether to preserve line breaks in attribute lists, even if they could fit on a single line.
|
|
369
|
+
* @default false
|
|
370
|
+
*/
|
|
371
|
+
"preserve-breaking-attribute-list"?: boolean;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Whether to preserve line breaks in conditional (ternary) expressions.
|
|
375
|
+
* @default false
|
|
376
|
+
*/
|
|
377
|
+
"preserve-breaking-conditional-expression"?: boolean;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Whether to break a parameter list with one or more promoted properties into multiple lines.
|
|
381
|
+
* @default true
|
|
382
|
+
*
|
|
383
|
+
* @example true
|
|
384
|
+
* ```php
|
|
385
|
+
* class User {
|
|
386
|
+
* public function __construct(
|
|
387
|
+
* public string $name,
|
|
388
|
+
* public string $email,
|
|
389
|
+
* ) {}
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* @example false
|
|
394
|
+
* ```php
|
|
395
|
+
* class User {
|
|
396
|
+
* public function __construct(public string $name, public string $email) {}
|
|
397
|
+
* }
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
"break-promoted-properties-list"?: boolean;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Whether to add a line before binary operators or after when breaking.
|
|
404
|
+
* @default true
|
|
405
|
+
*
|
|
406
|
+
* @example true
|
|
407
|
+
* ```php
|
|
408
|
+
* $foo = 'Hello, '
|
|
409
|
+
* . 'world!';
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* @example false
|
|
413
|
+
* ```php
|
|
414
|
+
* $foo = 'Hello, ' .
|
|
415
|
+
* 'world!';
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @remarks Note: If the right side has a leading comment, this setting is always false.
|
|
419
|
+
*/
|
|
420
|
+
"line-before-binary-operator"?: boolean;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Whether to always break named argument lists into multiple lines.
|
|
424
|
+
* @default false
|
|
425
|
+
*
|
|
426
|
+
* @example true
|
|
427
|
+
* ```php
|
|
428
|
+
* $foo = some_function(
|
|
429
|
+
* argument1: 'value1',
|
|
430
|
+
* argument2: 'value2',
|
|
431
|
+
* );
|
|
432
|
+
* ```
|
|
433
|
+
*/
|
|
434
|
+
"always-break-named-arguments-list"?: boolean;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Whether to always break named argument lists in attributes into multiple lines.
|
|
438
|
+
* @default false
|
|
439
|
+
*
|
|
440
|
+
* @example true
|
|
441
|
+
* ```php
|
|
442
|
+
* #[SomeAttribute(
|
|
443
|
+
* argument1: 'value1',
|
|
444
|
+
* argument2: 'value2',
|
|
445
|
+
* )]
|
|
446
|
+
* class Foo {}
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
"always-break-attribute-named-argument-lists"?: boolean;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Whether to use table-style alignment for arrays.
|
|
453
|
+
* @default true
|
|
454
|
+
*
|
|
455
|
+
* @example true
|
|
456
|
+
* ```php
|
|
457
|
+
* $array = [
|
|
458
|
+
* ['foo', 1.2, 123, false],
|
|
459
|
+
* ['bar', 52.4, 456, true],
|
|
460
|
+
* ['baz', 3.6, 789, false],
|
|
461
|
+
* ['qux', 4.8, 1, true],
|
|
462
|
+
* ['quux', 5.0, 12, false],
|
|
463
|
+
* ];
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
"array-table-style-alignment"?: boolean;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Whether to align consecutive assignment-like constructs in columns.
|
|
470
|
+
*
|
|
471
|
+
* When enabled, consecutive variable assignments, class properties, class constants,
|
|
472
|
+
* global constants, array key-value pairs, and backed enum cases are column-aligned.
|
|
473
|
+
* @default false
|
|
474
|
+
*
|
|
475
|
+
* @example true
|
|
476
|
+
* ```php
|
|
477
|
+
* $foo = 1;
|
|
478
|
+
* $b = 2;
|
|
479
|
+
* $ccccccc = 3;
|
|
480
|
+
*
|
|
481
|
+
* class X {
|
|
482
|
+
* public string $foo = 1;
|
|
483
|
+
* public readonly int $barrrr = 2;
|
|
484
|
+
* }
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* @example false
|
|
488
|
+
* ```php
|
|
489
|
+
* $foo = 1;
|
|
490
|
+
* $b = 2;
|
|
491
|
+
* $ccccccc = 3;
|
|
492
|
+
* ```
|
|
493
|
+
*
|
|
494
|
+
* @remarks Note: Blank lines and comments break alignment runs. In class bodies,
|
|
495
|
+
* different member types (properties vs constants) are aligned separately.
|
|
496
|
+
*/
|
|
497
|
+
"align-assignment-like"?: boolean;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Whether to sort use statements alphabetically.
|
|
501
|
+
* @default true
|
|
502
|
+
*/
|
|
503
|
+
"sort-uses"?: boolean;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Whether to sort class methods by visibility and name.
|
|
507
|
+
*
|
|
508
|
+
* When enabled, methods in class-like structures are automatically reordered:
|
|
509
|
+
* 1. Constructor (`__construct`) - always first
|
|
510
|
+
* 2. Static methods (by visibility: public, protected, private)
|
|
511
|
+
* - Abstract methods before concrete methods
|
|
512
|
+
* - Alphabetically by name within each group
|
|
513
|
+
* 3. Instance methods (by visibility: public, protected, private)
|
|
514
|
+
* - Abstract methods before concrete methods
|
|
515
|
+
* - Alphabetically by name within each group
|
|
516
|
+
* 4. Other magic methods (e.g., `__toString`, `__get`, `__set`)
|
|
517
|
+
* - Sorted alphabetically by name
|
|
518
|
+
* 5. Destructor (`__destruct`) - always last
|
|
519
|
+
*
|
|
520
|
+
* This applies to all class-like structures: classes, traits, interfaces, and enums.
|
|
521
|
+
* Other members (constants, properties, trait uses, enum cases) remain in their original positions.
|
|
522
|
+
* @default false
|
|
523
|
+
*/
|
|
524
|
+
"sort-class-methods"?: boolean;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Whether to insert a blank line between different types of use statements.
|
|
528
|
+
* @default true
|
|
529
|
+
*
|
|
530
|
+
* @example true
|
|
531
|
+
* ```php
|
|
532
|
+
* use Foo\Bar;
|
|
533
|
+
* use Foo\Baz;
|
|
534
|
+
*
|
|
535
|
+
* use function Foo\bar;
|
|
536
|
+
* use function Foo\baz;
|
|
537
|
+
*
|
|
538
|
+
* use const Foo\A;
|
|
539
|
+
* use const Foo\B;
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @example false
|
|
543
|
+
* ```php
|
|
544
|
+
* use Foo\Bar;
|
|
545
|
+
* use Foo\Baz;
|
|
546
|
+
* use function Foo\bar;
|
|
547
|
+
* use function Foo\baz;
|
|
548
|
+
* use const Foo\A;
|
|
549
|
+
* use const Foo\B;
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
"separate-use-types"?: boolean;
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Whether to expand grouped use statements into individual statements.
|
|
556
|
+
* @default true
|
|
557
|
+
*
|
|
558
|
+
* @example true
|
|
559
|
+
* ```php
|
|
560
|
+
* use Foo\Bar;
|
|
561
|
+
* use Foo\Baz;
|
|
562
|
+
* ```
|
|
563
|
+
*
|
|
564
|
+
* @example false
|
|
565
|
+
* ```php
|
|
566
|
+
* use Foo\{Bar, Baz};
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
"expand-use-groups"?: boolean;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* How to format null type hints.
|
|
573
|
+
* @default "question"
|
|
574
|
+
*
|
|
575
|
+
* @example "question"
|
|
576
|
+
* ```php
|
|
577
|
+
* function foo(?string $bar) {
|
|
578
|
+
* return $bar;
|
|
579
|
+
* }
|
|
580
|
+
* ```
|
|
581
|
+
*
|
|
582
|
+
* @example "null-pipe"
|
|
583
|
+
* ```php
|
|
584
|
+
* function foo(null|string $bar) {
|
|
585
|
+
* return $bar;
|
|
586
|
+
* }
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
"null-type-hint"?: "null-pipe" | "question";
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Whether to include parentheses around `new` when followed by a member access.
|
|
593
|
+
*
|
|
594
|
+
* Controls whether to use PHP 8.4's shorthand syntax for new expressions
|
|
595
|
+
* followed by member access. If PHP version is earlier than 8.4, this is always true.
|
|
596
|
+
* @default false
|
|
597
|
+
*
|
|
598
|
+
* @example true
|
|
599
|
+
* ```php
|
|
600
|
+
* $foo = (new Foo)->bar();
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @example false
|
|
604
|
+
* ```php
|
|
605
|
+
* $foo = new Foo->bar();
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
"parentheses-around-new-in-member-access"?: boolean;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Whether to include parentheses in `new` expressions when no arguments are provided.
|
|
612
|
+
* @default true
|
|
613
|
+
*
|
|
614
|
+
* @example true
|
|
615
|
+
* ```php
|
|
616
|
+
* $foo = new Foo();
|
|
617
|
+
* ```
|
|
618
|
+
*
|
|
619
|
+
* @example false
|
|
620
|
+
* ```php
|
|
621
|
+
* $foo = new Foo;
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
"parentheses-in-new-expression"?: boolean;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Whether to include parentheses in `exit` and `die` constructs.
|
|
628
|
+
* @default true
|
|
629
|
+
*
|
|
630
|
+
* @example true
|
|
631
|
+
* ```php
|
|
632
|
+
* exit();
|
|
633
|
+
* die();
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @example false
|
|
637
|
+
* ```php
|
|
638
|
+
* exit;
|
|
639
|
+
* die;
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
"parentheses-in-exit-and-die"?: boolean;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Whether to include parentheses in attributes with no arguments.
|
|
646
|
+
* @default false
|
|
647
|
+
*
|
|
648
|
+
* @example true
|
|
649
|
+
* ```php
|
|
650
|
+
* #[SomeAttribute()]
|
|
651
|
+
* class Foo {}
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @example false
|
|
655
|
+
* ```php
|
|
656
|
+
* #[SomeAttribute]
|
|
657
|
+
* class Foo {}
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
"parentheses-in-attribute"?: boolean;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Whether to add a space before the opening parameters in arrow functions.
|
|
664
|
+
* @default false
|
|
665
|
+
*
|
|
666
|
+
* @example true
|
|
667
|
+
* ```php
|
|
668
|
+
* fn ($x) => $x * 2
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @example false
|
|
672
|
+
* ```php
|
|
673
|
+
* fn($x) => $x * 2
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
"space-before-arrow-function-parameter-list-parenthesis"?: boolean;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Whether to add a space before the opening parameters in closures.
|
|
680
|
+
* @default true
|
|
681
|
+
*
|
|
682
|
+
* @example true
|
|
683
|
+
* ```php
|
|
684
|
+
* function ($x) use ($y)
|
|
685
|
+
* ```
|
|
686
|
+
*
|
|
687
|
+
* @example false
|
|
688
|
+
* ```php
|
|
689
|
+
* function($x) use ($y)
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
"space-before-closure-parameter-list-parenthesis"?: boolean;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Whether to add a space before the opening parameters in hooks.
|
|
696
|
+
* @default false
|
|
697
|
+
*
|
|
698
|
+
* @example true
|
|
699
|
+
* ```php
|
|
700
|
+
* $hook ($param)
|
|
701
|
+
* ```
|
|
702
|
+
*
|
|
703
|
+
* @example false
|
|
704
|
+
* ```php
|
|
705
|
+
* $hook($param)
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
"space-before-hook-parameter-list-parenthesis"?: boolean;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Whether to add a space before the opening parenthesis in closure use clause.
|
|
712
|
+
* @default true
|
|
713
|
+
*
|
|
714
|
+
* @example true
|
|
715
|
+
* ```php
|
|
716
|
+
* function() use ($var)
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* @example false
|
|
720
|
+
* ```php
|
|
721
|
+
* function() use($var)
|
|
722
|
+
* ```
|
|
723
|
+
*/
|
|
724
|
+
"space-before-closure-use-clause-parenthesis"?: boolean;
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Whether to add a space after cast operators (int, float, string, etc.).
|
|
728
|
+
* @default true
|
|
729
|
+
*
|
|
730
|
+
* @example true
|
|
731
|
+
* ```php
|
|
732
|
+
* (int) $foo
|
|
733
|
+
* ```
|
|
734
|
+
*
|
|
735
|
+
* @example false
|
|
736
|
+
* ```php
|
|
737
|
+
* (int)$foo
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
740
|
+
"space-after-cast-unary-prefix-operators"?: boolean;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Whether to add a space after the reference operator (&).
|
|
744
|
+
* @default false
|
|
745
|
+
*
|
|
746
|
+
* @example true
|
|
747
|
+
* ```php
|
|
748
|
+
* & $foo
|
|
749
|
+
* ```
|
|
750
|
+
*
|
|
751
|
+
* @example false
|
|
752
|
+
* ```php
|
|
753
|
+
* &$foo
|
|
754
|
+
* ```
|
|
755
|
+
*/
|
|
756
|
+
"space-after-reference-unary-prefix-operator"?: boolean;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Whether to add a space after the error control operator (@).
|
|
760
|
+
* @default false
|
|
761
|
+
*
|
|
762
|
+
* @example true
|
|
763
|
+
* ```php
|
|
764
|
+
* @ $foo
|
|
765
|
+
* ```
|
|
766
|
+
*
|
|
767
|
+
* @example false
|
|
768
|
+
* ```php
|
|
769
|
+
* @$foo
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
"space-after-error-control-unary-prefix-operator"?: boolean;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Whether to add a space after the logical not operator (!).
|
|
776
|
+
* @default false
|
|
777
|
+
*
|
|
778
|
+
* @example true
|
|
779
|
+
* ```php
|
|
780
|
+
* ! $foo
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @example false
|
|
784
|
+
* ```php
|
|
785
|
+
* !$foo
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
"space-after-logical-not-unary-prefix-operator"?: boolean;
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Whether to add a space after the bitwise not operator (~).
|
|
792
|
+
* @default false
|
|
793
|
+
*
|
|
794
|
+
* @example true
|
|
795
|
+
* ```php
|
|
796
|
+
* ~ $foo
|
|
797
|
+
* ```
|
|
798
|
+
*
|
|
799
|
+
* @example false
|
|
800
|
+
* ```php
|
|
801
|
+
* ~$foo
|
|
802
|
+
* ```
|
|
803
|
+
*/
|
|
804
|
+
"space-after-bitwise-not-unary-prefix-operator"?: boolean;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Whether to add a space after the increment prefix operator (++).
|
|
808
|
+
* @default false
|
|
809
|
+
*
|
|
810
|
+
* @example true
|
|
811
|
+
* ```php
|
|
812
|
+
* ++ $i
|
|
813
|
+
* ```
|
|
814
|
+
*
|
|
815
|
+
* @example false
|
|
816
|
+
* ```php
|
|
817
|
+
* ++$i
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
"space-after-increment-unary-prefix-operator"?: boolean;
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Whether to add a space after the decrement prefix operator (--).
|
|
824
|
+
* @default false
|
|
825
|
+
*
|
|
826
|
+
* @example true
|
|
827
|
+
* ```php
|
|
828
|
+
* -- $i
|
|
829
|
+
* ```
|
|
830
|
+
*
|
|
831
|
+
* @example false
|
|
832
|
+
* ```php
|
|
833
|
+
* --$i
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
"space-after-decrement-unary-prefix-operator"?: boolean;
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Whether to add a space after the additive unary operators (+ and -).
|
|
840
|
+
* @default false
|
|
841
|
+
*
|
|
842
|
+
* @example true
|
|
843
|
+
* ```php
|
|
844
|
+
* + $i
|
|
845
|
+
* ```
|
|
846
|
+
*
|
|
847
|
+
* @example false
|
|
848
|
+
* ```php
|
|
849
|
+
* +$i
|
|
850
|
+
* ```
|
|
851
|
+
*/
|
|
852
|
+
"space-after-additive-unary-prefix-operator"?: boolean;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Whether to add spaces around the concatenation operator (.).
|
|
856
|
+
* @default true
|
|
857
|
+
*
|
|
858
|
+
* @example true
|
|
859
|
+
* ```php
|
|
860
|
+
* $a . $b
|
|
861
|
+
* ```
|
|
862
|
+
*
|
|
863
|
+
* @example false
|
|
864
|
+
* ```php
|
|
865
|
+
* $a.$b
|
|
866
|
+
* ```
|
|
867
|
+
*/
|
|
868
|
+
"space-around-concatenation-binary-operator"?: boolean;
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Whether to add spaces around the assignment in declare statements.
|
|
872
|
+
* @default false
|
|
873
|
+
*
|
|
874
|
+
* @example true
|
|
875
|
+
* ```php
|
|
876
|
+
* declare(strict_types = 1)
|
|
877
|
+
* ```
|
|
878
|
+
*
|
|
879
|
+
* @example false
|
|
880
|
+
* ```php
|
|
881
|
+
* declare(strict_types=1)
|
|
882
|
+
* ```
|
|
883
|
+
*/
|
|
884
|
+
"space-around-assignment-in-declare"?: boolean;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Whether to add spaces within grouping parentheses.
|
|
888
|
+
* @default false
|
|
889
|
+
*
|
|
890
|
+
* @example true
|
|
891
|
+
* ```php
|
|
892
|
+
* ( $expr ) - $expr
|
|
893
|
+
* ```
|
|
894
|
+
*
|
|
895
|
+
* @example false
|
|
896
|
+
* ```php
|
|
897
|
+
* ($expr) - $expr
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
"space-within-grouping-parenthesis"?: boolean;
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Whether to add an empty line after control structures (if, for, foreach, while, do, switch).
|
|
904
|
+
* @default false
|
|
905
|
+
*
|
|
906
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
907
|
+
*/
|
|
908
|
+
"empty-line-after-control-structure"?: boolean;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Whether to add an empty line after opening tag.
|
|
912
|
+
* @default true
|
|
913
|
+
*
|
|
914
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
915
|
+
*/
|
|
916
|
+
"empty-line-after-opening-tag"?: boolean;
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Whether to add an empty line after declare statement.
|
|
920
|
+
* @default true
|
|
921
|
+
*
|
|
922
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
923
|
+
*/
|
|
924
|
+
"empty-line-after-declare"?: boolean;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Whether to add an empty line after namespace.
|
|
928
|
+
* @default true
|
|
929
|
+
*
|
|
930
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
931
|
+
*/
|
|
932
|
+
"empty-line-after-namespace"?: boolean;
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Whether to add an empty line after use statements.
|
|
936
|
+
* @default true
|
|
937
|
+
*
|
|
938
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
939
|
+
*/
|
|
940
|
+
"empty-line-after-use"?: boolean;
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Whether to add an empty line after symbols (class, enum, interface, trait, function, const).
|
|
944
|
+
* @default true
|
|
945
|
+
*
|
|
946
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
947
|
+
*/
|
|
948
|
+
"empty-line-after-symbols"?: boolean;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Whether to add an empty line between consecutive symbols of the same type.
|
|
952
|
+
*
|
|
953
|
+
* Only applies when `empty-line-after-symbols` is true.
|
|
954
|
+
* @default true
|
|
955
|
+
*/
|
|
956
|
+
"empty-line-between-same-symbols"?: boolean;
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Whether to add an empty line after class-like constant.
|
|
960
|
+
* @default false
|
|
961
|
+
*
|
|
962
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
963
|
+
*/
|
|
964
|
+
"empty-line-after-classlike-constant"?: boolean;
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Whether to add an empty line after enum case.
|
|
968
|
+
* @default false
|
|
969
|
+
*
|
|
970
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
971
|
+
*/
|
|
972
|
+
"empty-line-after-enum-case"?: boolean;
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Whether to add an empty line after trait use.
|
|
976
|
+
* @default false
|
|
977
|
+
*
|
|
978
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
979
|
+
*/
|
|
980
|
+
"empty-line-after-trait-use"?: boolean;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Whether to add an empty line after property.
|
|
984
|
+
* @default false
|
|
985
|
+
*
|
|
986
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
987
|
+
*/
|
|
988
|
+
"empty-line-after-property"?: boolean;
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Whether to add an empty line after method.
|
|
992
|
+
* @default true
|
|
993
|
+
*
|
|
994
|
+
* @remarks Note: if an empty line already exists, it will be preserved regardless of this settings value.
|
|
995
|
+
*/
|
|
996
|
+
"empty-line-after-method"?: boolean;
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* Whether to add an empty line before return statements.
|
|
1000
|
+
* @default false
|
|
1001
|
+
*/
|
|
1002
|
+
"empty-line-before-return"?: boolean;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Whether to add an empty line before dangling comments.
|
|
1006
|
+
* @default true
|
|
1007
|
+
*/
|
|
1008
|
+
"empty-line-before-dangling-comments"?: boolean;
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* Whether to separate class-like members of different kinds with a blank line.
|
|
1012
|
+
* @default true
|
|
1013
|
+
*/
|
|
1014
|
+
"separate-classlike-members"?: boolean;
|
|
1015
|
+
}
|
package/mago_fmt_web.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"magic-akari <akari.ccino@gmail.com>"
|
|
6
6
|
],
|
|
7
7
|
"description": "A WASM based PHP Formatter",
|
|
8
|
-
"version": "0.4.
|
|
8
|
+
"version": "0.4.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -53,10 +53,7 @@
|
|
|
53
53
|
"types": "./mago_fmt_web.d.ts",
|
|
54
54
|
"default": "./mago_fmt_vite.js"
|
|
55
55
|
},
|
|
56
|
-
"./wasm":
|
|
57
|
-
"types": "./mago_fmt_bg.wasm.d.ts",
|
|
58
|
-
"default": "./mago_fmt_bg.wasm"
|
|
59
|
-
},
|
|
56
|
+
"./wasm": "./mago_fmt_bg.wasm",
|
|
60
57
|
"./package.json": "./package.json",
|
|
61
58
|
"./*": "./*"
|
|
62
59
|
}
|