mago_formatter/settings.rs
1use std::str::FromStr;
2
3use serde::Deserialize;
4use serde::Serialize;
5
6/// Format settings for the PHP printer.
7#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
8pub struct FormatSettings {
9 /// Maximum line length that the printer will wrap on.
10 ///
11 /// Default: 120
12 #[serde(default = "default_print_width")]
13 pub print_width: usize,
14
15 /// Number of spaces per indentation level.
16 ///
17 /// Default: 4
18 #[serde(default = "default_tab_width")]
19 pub tab_width: usize,
20
21 /// Whether to use tabs instead of spaces for indentation.
22 ///
23 /// Default: false
24 #[serde(default = "default_false")]
25 pub use_tabs: bool,
26
27 /// End-of-line characters to use.
28 ///
29 /// Default: "lf"
30 #[serde(default)]
31 pub end_of_line: EndOfLine,
32
33 /// Whether to use single quotes instead of double quotes for strings.
34 ///
35 /// The formatter automatically determines which quotes to use based on the string content,
36 /// with a preference for single quotes if this option is enabled.
37 ///
38 /// Decision logic:
39 /// - If the string contains more single quotes than double quotes, double quotes are used
40 /// - If the string contains more double quotes than single quotes, single quotes are used
41 /// - If equal number of both, single quotes are used if this option is true
42 ///
43 /// Default: true
44 #[serde(default = "default_true")]
45 pub single_quote: bool,
46
47 /// Whether to add a trailing comma to the last element in multi-line syntactic structures.
48 ///
49 /// When enabled, trailing commas are added to lists, arrays, parameter lists,
50 /// argument lists, and other similar structures when they span multiple lines.
51 ///
52 /// Default: true
53 #[serde(default = "default_true")]
54 pub trailing_comma: bool,
55
56 /// Whether to remove the trailing PHP close tag (`?>`) from files.
57 ///
58 /// Default: true
59 #[serde(default = "default_true")]
60 pub remove_trailing_close_tag: bool,
61
62 /// Brace placement for control structures (if, for, while, etc.).
63 ///
64 /// Example with `same_line`:
65 /// ```php
66 /// if ($expr) {
67 /// return 'Hello, world!';
68 /// }
69 /// ```
70 ///
71 /// Example with `next_line`:
72 /// ```php
73 /// if ($expr)
74 /// {
75 /// return 'Hello, world!';
76 /// }
77 /// ```
78 ///
79 /// Default: same_line
80 #[serde(default = "BraceStyle::same_line")]
81 pub control_brace_style: BraceStyle,
82
83 /// Brace placement for closures.
84 ///
85 /// Example with `same_line`:
86 /// ```php
87 /// $closure = function() {
88 /// return 'Hello, world!';
89 /// };
90 /// ```
91 ///
92 /// Example with `next_line`:
93 /// ```php
94 /// $closure = function()
95 /// {
96 /// return 'Hello, world!';
97 /// };
98 /// ```
99 ///
100 /// Default: same_line
101 #[serde(default = "BraceStyle::same_line")]
102 pub closure_brace_style: BraceStyle,
103
104 /// Brace placement for function declarations.
105 ///
106 /// Example with `same_line`:
107 /// ```php
108 /// function foo() {
109 /// return 'Hello, world!';
110 /// }
111 /// ```
112 ///
113 /// Example with `next_line`:
114 /// ```php
115 /// function foo()
116 /// {
117 /// return 'Hello, world!';
118 /// }
119 /// ```
120 ///
121 /// Default: next_line
122 #[serde(default = "BraceStyle::next_line")]
123 pub function_brace_style: BraceStyle,
124
125 /// Brace placement for method declarations.
126 ///
127 /// Example with `same_line`:
128 /// ```php
129 /// class Foo
130 /// {
131 /// public function bar() {
132 /// return 'Hello, world!';
133 /// }
134 /// }
135 /// ```
136 ///
137 /// Example with `next_line`:
138 /// ```php
139 /// class Foo
140 /// {
141 /// public function bar()
142 /// {
143 /// return 'Hello, world!';
144 /// }
145 /// }
146 /// ```
147 ///
148 /// Default: next_line
149 #[serde(default = "BraceStyle::next_line")]
150 pub method_brace_style: BraceStyle,
151
152 /// Brace placement for class-like structures (classes, interfaces, traits, enums).
153 ///
154 /// Example with `same_line`:
155 /// ```php
156 /// class Foo {
157 /// }
158 /// ```
159 ///
160 /// Example with `next_line`:
161 /// ```php
162 /// class Foo
163 /// {
164 /// }
165 /// ```
166 ///
167 /// Default: next_line
168 #[serde(default = "BraceStyle::next_line")]
169 pub classlike_brace_style: BraceStyle,
170
171 /// Place empty control structure bodies on the same line.
172 ///
173 /// Example with `false`:
174 /// ```php
175 /// if ($expr)
176 /// {
177 /// }
178 /// ```
179 ///
180 /// Example with `true`:
181 /// ```php
182 /// if ($expr) {}
183 /// ```
184 ///
185 /// Default: false
186 #[serde(default = "default_false")]
187 pub inline_empty_control_braces: bool,
188
189 /// Place empty closure bodies on the same line.
190 ///
191 /// Example with `false`:
192 /// ```php
193 /// $closure = function()
194 /// {
195 /// };
196 /// ```
197 ///
198 /// Example with `true`:
199 /// ```php
200 /// $closure = function() {};
201 /// ```
202 ///
203 /// Default: true
204 #[serde(default = "default_true")]
205 pub inline_empty_closure_braces: bool,
206
207 /// Place empty function bodies on the same line.
208 ///
209 /// Example with `false`:
210 /// ```php
211 /// function foo()
212 /// {
213 /// }
214 /// ```
215 ///
216 /// Example with `true`:
217 /// ```php
218 /// function foo() {}
219 /// ```
220 ///
221 /// Default: false
222 #[serde(default = "default_false")]
223 pub inline_empty_function_braces: bool,
224
225 /// Place empty method bodies on the same line.
226 ///
227 /// Example with `false`:
228 /// ```php
229 /// class Foo
230 /// {
231 /// public function bar()
232 /// {
233 /// }
234 /// }
235 /// ```
236 ///
237 /// Example with `true`:
238 /// ```php
239 /// class Foo
240 /// {
241 /// public function bar() {}
242 /// }
243 /// ```
244 ///
245 /// Default: false
246 #[serde(default = "default_false")]
247 pub inline_empty_method_braces: bool,
248
249 /// Place empty constructor bodies on the same line.
250 ///
251 /// Example with `false`:
252 /// ```php
253 /// class Foo {
254 /// public function __construct()
255 /// {
256 /// }
257 /// }
258 /// ```
259 ///
260 /// Example with `true`:
261 /// ```php
262 /// class Foo {
263 /// public function __construct() {}
264 /// }
265 /// ```
266 ///
267 /// Default: true
268 #[serde(default = "default_true")]
269 pub inline_empty_constructor_braces: bool,
270
271 /// Place empty class-like bodies on the same line.
272 ///
273 /// Example with `false`:
274 /// ```php
275 /// class Foo
276 /// {
277 /// }
278 /// ```
279 ///
280 /// Example with `true`:
281 /// ```php
282 /// class Foo {}
283 /// ```
284 ///
285 /// Default: false
286 #[serde(default = "default_false")]
287 pub inline_empty_classlike_braces: bool,
288
289 /// Place empty anonymous class bodies on the same line.
290 ///
291 /// Example with `false`:
292 /// ```php
293 /// $anon = new class
294 /// {
295 /// };
296 /// ```
297 ///
298 /// Example with `true`:
299 /// ```php
300 /// $anon = new class {};
301 /// ```
302 ///
303 /// Default: true
304 #[serde(default = "default_true")]
305 pub inline_empty_anonymous_class_braces: bool,
306
307 /// How to format broken method/property chains.
308 ///
309 /// When `next_line`, the first method/property starts on a new line:
310 /// ```php
311 /// $foo
312 /// ->bar()
313 /// ->baz();
314 /// ```
315 ///
316 /// When `same_line`, the first method/property stays on the same line:
317 /// ```php
318 /// $foo->bar()
319 /// ->baz();
320 /// ```
321 ///
322 /// Default: next_line
323 #[serde(default)]
324 pub method_chain_breaking_style: MethodChainBreakingStyle,
325
326 /// Whether to preserve line breaks in method chains, even if they could fit on a single line.
327 ///
328 /// Default: false
329 #[serde(default = "default_false")]
330 pub preserve_breaking_member_access_chain: bool,
331
332 /// Whether to preserve line breaks in argument lists, even if they could fit on a single line.
333 ///
334 /// Default: false
335 #[serde(default = "default_false")]
336 pub preserve_breaking_argument_list: bool,
337
338 /// Whether to preserve line breaks in array-like structures, even if they could fit on a single line.
339 ///
340 /// Default: true
341 #[serde(default = "default_true")]
342 pub preserve_breaking_array_like: bool,
343
344 /// Whether to preserve line breaks in parameter lists, even if they could fit on a single line.
345 ///
346 /// Default: false
347 #[serde(default = "default_false")]
348 pub preserve_breaking_parameter_list: bool,
349
350 /// Whether to preserve line breaks in attribute lists, even if they could fit on a single line.
351 ///
352 /// Default: false
353 #[serde(default = "default_false")]
354 pub preserve_breaking_attribute_list: bool,
355
356 /// Whether to preserve line breaks in conditional (ternary) expressions.
357 ///
358 /// Default: false
359 #[serde(default = "default_false")]
360 pub preserve_breaking_conditional_expression: bool,
361
362 /// Whether to break a parameter list with one or more promoted properties into multiple lines.
363 ///
364 /// When enabled, parameter lists with promoted properties are always multi-line:
365 /// ```php
366 /// class User {
367 /// public function __construct(
368 /// public string $name,
369 /// public string $email,
370 /// ) {}
371 /// }
372 /// ```
373 ///
374 /// When disabled, they may be kept on a single line if space allows:
375 /// ```php
376 /// class User {
377 /// public function __construct(public string $name, public string $email) {}
378 /// }
379 /// ```
380 ///
381 /// Default: true
382 #[serde(default = "default_true")]
383 pub break_promoted_properties_list: bool,
384
385 /// Whether to add a line before binary operators or after when breaking.
386 ///
387 /// When true:
388 /// ```php
389 /// $foo = 'Hello, '
390 /// . 'world!';
391 /// ```
392 ///
393 /// When false:
394 /// ```php
395 /// $foo = 'Hello, ' .
396 /// 'world!';
397 /// ```
398 ///
399 /// Note: If the right side has a leading comment, this setting is always false.
400 ///
401 /// Default: false
402 #[serde(default = "default_false")]
403 pub line_before_binary_operator: bool,
404
405 /// Whether to always break named argument lists into multiple lines.
406 ///
407 /// When enabled:
408 /// ```php
409 /// $foo = some_function(
410 /// argument1: 'value1',
411 /// argument2: 'value2',
412 /// );
413 /// ```
414 ///
415 /// Default: true
416 #[serde(default = "default_true")]
417 pub always_break_named_arguments_list: bool,
418
419 /// Whether to always break named argument lists in attributes into multiple lines.
420 ///
421 /// When enabled:
422 /// ```php
423 /// #[SomeAttribute(
424 /// argument1: 'value1',
425 /// argument2: 'value2',
426 /// )]
427 /// class Foo {}
428 /// ```
429 ///
430 /// Default: false
431 #[serde(default = "default_false")]
432 pub always_break_attribute_named_argument_lists: bool,
433
434 /// Whether to use table-style alignment for arrays.
435 ///
436 /// When enabled, array elements are aligned in a table-like format:
437 /// ```php
438 /// $array = [
439 /// ['foo', 1.2, 123, false],
440 /// ['bar', 52.4, 456, true],
441 /// ['baz', 3.6, 789, false],
442 /// ['qux', 4.8, 1, true],
443 /// ['quux', 5.0, 12, false],
444 /// ];
445 /// ```
446 ///
447 /// Default: true
448 #[serde(default = "default_true")]
449 pub array_table_style_alignment: bool,
450
451 /// Whether to sort use statements alphabetically.
452 ///
453 /// Default: true
454 #[serde(default = "default_true")]
455 pub sort_uses: bool,
456
457 /// Whether to insert a blank line between different types of use statements.
458 ///
459 /// When enabled:
460 /// ```php
461 /// use Foo\Bar;
462 /// use Foo\Baz;
463 ///
464 /// use function Foo\bar;
465 /// use function Foo\baz;
466 ///
467 /// use const Foo\A;
468 /// use const Foo\B;
469 /// ```
470 ///
471 /// When disabled:
472 /// ```php
473 /// use Foo\Bar;
474 /// use Foo\Baz;
475 /// use function Foo\bar;
476 /// use function Foo\baz;
477 /// use const Foo\A;
478 /// use const Foo\B;
479 /// ```
480 ///
481 /// Default: true
482 #[serde(default = "default_true")]
483 pub separate_use_types: bool,
484
485 /// Whether to expand grouped use statements into individual statements.
486 ///
487 /// When enabled:
488 /// ```php
489 /// use Foo\Bar;
490 /// use Foo\Baz;
491 /// ```
492 ///
493 /// When disabled:
494 /// ```php
495 /// use Foo\{Bar, Baz};
496 /// ```
497 ///
498 /// Default: true
499 #[serde(default = "default_true")]
500 pub expand_use_groups: bool,
501
502 /// How to format null type hints.
503 ///
504 /// With `NullPipe`:
505 /// ```php
506 /// function foo(null|string $bar) {
507 /// return $bar;
508 /// }
509 /// ```
510 ///
511 /// With `Question`:
512 /// ```php
513 /// function foo(?string $bar) {
514 /// return $bar;
515 /// }
516 /// ```
517 ///
518 /// Default: NullPipe
519 #[serde(default)]
520 pub null_type_hint: NullTypeHint,
521
522 /// Whether to put `static` before visibility keywords.
523 ///
524 /// When enabled:
525 /// ```php
526 /// class Foo {
527 /// static public $bar;
528 /// }
529 /// ```
530 ///
531 /// When disabled:
532 /// ```php
533 /// class Foo {
534 /// public static $bar;
535 /// }
536 /// ```
537 ///
538 /// This also affects placement of the `readonly` keyword.
539 ///
540 /// Default: false
541 #[serde(default = "default_false")]
542 pub static_before_visibility: bool,
543
544 /// Whether to include parentheses around `new` when followed by a member access.
545 ///
546 /// Controls whether to use PHP 8.4's shorthand syntax for new expressions
547 /// followed by member access. If PHP version is earlier than 8.4, this is always true.
548 ///
549 /// When enabled:
550 /// ```php
551 /// $foo = (new Foo)->bar();
552 /// ```
553 ///
554 /// When disabled (PHP 8.4+ only):
555 /// ```php
556 /// $foo = new Foo->bar();
557 /// ```
558 ///
559 /// Default: false
560 #[serde(default = "default_false")]
561 pub parentheses_around_new_in_member_access: bool,
562
563 /// Whether to include parentheses in `new` expressions when no arguments are provided.
564 ///
565 /// When enabled:
566 /// ```php
567 /// $foo = new Foo();
568 /// ```
569 ///
570 /// When disabled:
571 /// ```php
572 /// $foo = new Foo;
573 /// ```
574 ///
575 /// Default: true
576 #[serde(default = "default_true")]
577 pub parentheses_in_new_expression: bool,
578
579 /// Whether to include parentheses in `exit` and `die` constructs.
580 ///
581 /// When enabled:
582 /// ```php
583 /// exit();
584 /// die();
585 /// ```
586 ///
587 /// When disabled:
588 /// ```php
589 /// exit;
590 /// die;
591 /// ```
592 ///
593 /// Default: true
594 #[serde(default = "default_true")]
595 pub parentheses_in_exit_and_die: bool,
596
597 /// Whether to include parentheses in attributes with no arguments.
598 ///
599 /// When enabled:
600 /// ```php
601 /// #[SomeAttribute()]
602 /// class Foo {}
603 /// ```
604 ///
605 /// When disabled:
606 /// ```php
607 /// #[SomeAttribute]
608 /// class Foo {}
609 /// ```
610 ///
611 /// Default: false
612 #[serde(default = "default_false")]
613 pub parentheses_in_attribute: bool,
614
615 /// Whether to add a space before the opening parenthesis in `if` statements.
616 ///
617 /// When enabled: `if ($condition)`
618 /// When disabled: `if($condition)`
619 ///
620 /// Default: true
621 #[serde(default = "default_true")]
622 pub space_before_if_parenthesis: bool,
623
624 /// Whether to add a space before the opening parenthesis in `for` loops.
625 ///
626 /// When enabled: `for ($i = 0; $i < 10; $i++)`
627 /// When disabled: `for($i = 0; $i < 10; $i++)`
628 ///
629 /// Default: true
630 #[serde(default = "default_true")]
631 pub space_before_for_parenthesis: bool,
632
633 /// Whether to add a space before the opening parenthesis in `foreach` loops.
634 ///
635 /// When enabled: `foreach ($items as $item)`
636 /// When disabled: `foreach($items as $item)`
637 ///
638 /// Default: true
639 #[serde(default = "default_true")]
640 pub space_before_foreach_parenthesis: bool,
641
642 /// Whether to add a space before the opening parenthesis in `while` loops.
643 ///
644 /// When enabled: `while ($condition)`
645 /// When disabled: `while($condition)`
646 ///
647 /// Default: true
648 #[serde(default = "default_true")]
649 pub space_before_while_parenthesis: bool,
650
651 /// Whether to add a space before the opening parenthesis in `catch` blocks.
652 ///
653 /// When enabled: `catch (Exception $e)`
654 /// When disabled: `catch(Exception $e)`
655 ///
656 /// Default: true
657 #[serde(default = "default_true")]
658 pub space_before_catch_parenthesis: bool,
659
660 /// Whether to add a space before the opening parenthesis in `switch` statements.
661 ///
662 /// When enabled: `switch ($value)`
663 /// When disabled: `switch($value)`
664 ///
665 /// Default: true
666 #[serde(default = "default_true")]
667 pub space_before_switch_parenthesis: bool,
668
669 /// Whether to add a space before the opening parenthesis in `match` expressions.
670 ///
671 /// When enabled: `match ($value)`
672 /// When disabled: `match($value)`
673 ///
674 /// Default: true
675 #[serde(default = "default_true")]
676 pub space_before_match_parenthesis: bool,
677
678 /// Whether to add a space before the opening parameters in arrow functions.
679 ///
680 /// When enabled: `fn ($x) => $x * 2`
681 /// When disabled: `fn($x) => $x * 2`
682 ///
683 /// Default: false
684 #[serde(default = "default_false")]
685 pub space_before_arrow_function_parameter_list_parenthesis: bool,
686
687 /// Whether to add a space before the opening parameters in closures.
688 ///
689 /// When enabled: `function ($x) use ($y)`
690 /// When disabled: `function($x) use ($y)`
691 ///
692 /// Default: true
693 #[serde(default = "default_true")]
694 pub space_before_closure_parameter_list_parenthesis: bool,
695
696 /// Whether to add a space before the opening parameters in hooks.
697 ///
698 /// When enabled: `$hook ($param)`
699 /// When disabled: `$hook($param)`
700 ///
701 /// Default: false
702 #[serde(default = "default_false")]
703 pub space_before_hook_parameter_list_parenthesis: bool,
704
705 /// Whether to add a space before the opening parameters in function declarations.
706 ///
707 /// When enabled: `function foo ($param)`
708 /// When disabled: `function foo($param)`
709 ///
710 /// Default: false
711 #[serde(default = "default_false")]
712 pub space_before_function_parameter_list_parenthesis: bool,
713
714 /// Whether to add a space before the opening parameters in method declarations.
715 ///
716 /// When enabled: `public function foo ($param)`
717 /// When disabled: `public function foo($param)`
718 ///
719 /// Default: false
720 #[serde(default = "default_false")]
721 pub space_before_method_parameter_list_parenthesis: bool,
722
723 /// Whether to add a space before the opening parenthesis in closure use clause.
724 ///
725 /// When enabled: `function() use ($var)`
726 /// When disabled: `function() use($var)`
727 ///
728 /// Default: true
729 #[serde(default = "default_true")]
730 pub space_before_closure_use_clause_parenthesis: bool,
731
732 /// Whether to add a space before the opening parenthesis in function-like calls.
733 ///
734 /// When enabled: `foo ($arg)`
735 /// When disabled: `foo($arg)`
736 ///
737 /// Default: false
738 #[serde(default = "default_false")]
739 pub space_before_argument_list_parenthesis: bool,
740
741 /// Whether to add a space before the opening parenthesis in list destructuring.
742 ///
743 /// When enabled: `list ($a, $b) = $array`
744 /// When disabled: `list($a, $b) = $array`
745 ///
746 /// Default: false
747 #[serde(default = "default_false")]
748 pub space_before_list_parenthesis: bool,
749
750 /// Whether to add a space before the opening parenthesis in legacy array syntax.
751 ///
752 /// When enabled: `array ($item)`
753 /// When disabled: `array($item)`
754 ///
755 /// Default: false
756 #[serde(default = "default_false")]
757 pub space_before_legacy_array_parenthesis: bool,
758
759 /// Whether to add a space before increment postfix operator (++).
760 ///
761 /// When enabled: `$i ++`
762 /// When disabled: `$i++`
763 ///
764 /// Default: false
765 #[serde(default = "default_false")]
766 pub space_before_increment_unary_postfix_operator: bool,
767
768 /// Whether to add a space before decrement postfix operator (--).
769 ///
770 /// When enabled: `$i --`
771 /// When disabled: `$i--`
772 ///
773 /// Default: false
774 #[serde(default = "default_false")]
775 pub space_before_decrement_unary_postfix_operator: bool,
776
777 /// Whether to add a space before semicolons in for loops.
778 ///
779 /// When enabled: `for ($i = 0 ; $i < 10 ; $i++)`
780 /// When disabled: `for ($i = 0; $i < 10; $i++)`
781 ///
782 /// Default: false
783 #[serde(default = "default_false")]
784 pub space_before_for_semicolon: bool,
785
786 /// Whether to add a space before the colon in return type hints.
787 ///
788 /// When enabled: `function foo() : string`
789 /// When disabled: `function foo(): string`
790 ///
791 /// Default: false
792 #[serde(default = "default_false")]
793 pub space_before_colon_in_return_type: bool,
794
795 /// Whether to add a space before the colon in named arguments.
796 ///
797 /// When enabled: `foo(name : 'value')`
798 /// When disabled: `foo(name: 'value')`
799 ///
800 /// Default: false
801 #[serde(default = "default_false")]
802 pub space_before_colon_in_named_argument: bool,
803
804 /// Whether to add a space before the colon in enum backing types.
805 ///
806 /// When enabled: `enum Foo : string`
807 /// When disabled: `enum Foo: string`
808 ///
809 /// Default: false
810 #[serde(default = "default_false")]
811 pub space_before_colon_in_enum_backing_type: bool,
812
813 /// Whether to add a space after semicolons in for loops.
814 ///
815 /// When enabled: `for ($i = 0; $i < 10; $i++)`
816 /// When disabled: `for ($i = 0;$i < 10;$i++)`
817 ///
818 /// Default: true
819 #[serde(default = "default_true")]
820 pub space_after_for_semicolon: bool,
821
822 /// Whether to add a space after the colon in return type hints.
823 ///
824 /// When enabled: `function foo(): string`
825 /// When disabled: `function foo():string`
826 ///
827 /// Default: true
828 #[serde(default = "default_true")]
829 pub space_after_colon_in_return_type: bool,
830
831 /// Whether to add a space after the colon in named arguments.
832 ///
833 /// When enabled: `foo(name: 'value')`
834 /// When disabled: `foo(name:'value')`
835 ///
836 /// Default: true
837 #[serde(default = "default_true")]
838 pub space_after_colon_in_named_argument: bool,
839
840 /// Whether to add a space after the colon in enum backing types.
841 ///
842 /// When enabled: `enum Foo: string`
843 /// When disabled: `enum Foo:string`
844 ///
845 /// Default: true
846 #[serde(default = "default_true")]
847 pub space_after_colon_in_enum_backing_type: bool,
848
849 /// Whether to add a space after the question mark in nullable type hints.
850 ///
851 /// When enabled: `function foo(? string $bar)`
852 /// When disabled: `function foo(?string $bar)`
853 ///
854 /// Default: false
855 #[serde(default = "default_false")]
856 pub space_after_nullable_type_question_mark: bool,
857
858 /// Whether to add a space after cast operators (int, float, string, etc.).
859 ///
860 /// When enabled: `(int) $foo`
861 /// When disabled: `(int)$foo`
862 ///
863 /// Default: true
864 #[serde(default = "default_true")]
865 pub space_after_cast_unary_prefix_operators: bool,
866
867 /// Whether to add a space after the reference operator (&).
868 ///
869 /// When enabled: `& $foo`
870 /// When disabled: `&$foo`
871 ///
872 /// Default: false
873 #[serde(default = "default_false")]
874 pub space_after_reference_unary_prefix_operator: bool,
875
876 /// Whether to add a space after the error control operator (@).
877 ///
878 /// When enabled: `@ $foo`
879 /// When disabled: `@$foo`
880 ///
881 /// Default: false
882 #[serde(default = "default_false")]
883 pub space_after_error_control_unary_prefix_operator: bool,
884
885 /// Whether to add a space after the logical not operator (!).
886 ///
887 /// When enabled: `! $foo`
888 /// When disabled: `!$foo`
889 ///
890 /// Default: false
891 #[serde(default = "default_false")]
892 pub space_after_logical_not_unary_prefix_operator: bool,
893
894 /// Whether to add a space after the bitwise not operator (~).
895 ///
896 /// When enabled: `~ $foo`
897 /// When disabled: `~$foo`
898 ///
899 /// Default: false
900 #[serde(default = "default_false")]
901 pub space_after_bitwise_not_unary_prefix_operator: bool,
902
903 /// Whether to add a space after the increment prefix operator (++).
904 ///
905 /// When enabled: `++ $i`
906 /// When disabled: `++$i`
907 ///
908 /// Default: false
909 #[serde(default = "default_false")]
910 pub space_after_increment_unary_prefix_operator: bool,
911
912 /// Whether to add a space after the decrement prefix operator (--).
913 ///
914 /// When enabled: `-- $i`
915 /// When disabled: `--$i`
916 ///
917 /// Default: false
918 #[serde(default = "default_false")]
919 pub space_after_decrement_unary_prefix_operator: bool,
920
921 /// Whether to add a space after the additive unary operators (+ and -).
922 ///
923 /// When enabled: `+ $i`
924 /// When disabled: `+$i`
925 ///
926 /// Default: false
927 #[serde(default = "default_false")]
928 pub space_after_additive_unary_prefix_operator: bool,
929
930 /// Whether to add spaces around assignment operators.
931 ///
932 /// When enabled: `$a = $b`
933 /// When disabled: `$a=$b`
934 ///
935 /// Default: true
936 #[serde(default = "default_true")]
937 pub space_around_assignment_operators: bool,
938
939 /// Whether to add spaces around logical operators (&&, ||, and, or, xor).
940 ///
941 /// When enabled: `$a && $b`
942 /// When disabled: `$a&&$b`
943 ///
944 /// Default: true
945 #[serde(default = "default_true")]
946 pub space_around_logical_binary_operators: bool,
947
948 /// Whether to add spaces around equality operators (==, ===, !=, !==).
949 ///
950 /// When enabled: `$a === $b`
951 /// When disabled: `$a===$b`
952 ///
953 /// Default: true
954 #[serde(default = "default_true")]
955 pub space_around_equality_binary_operators: bool,
956
957 /// Whether to add spaces around comparison operators (<, >, <=, >=, <=>).
958 ///
959 /// When enabled: `$a < $b`
960 /// When disabled: `$a<$b`
961 ///
962 /// Default: true
963 #[serde(default = "default_true")]
964 pub space_around_comparison_binary_operators: bool,
965
966 /// Whether to add spaces around bitwise operators (&, |, ^).
967 ///
968 /// When enabled: `$a | $b`
969 /// When disabled: `$a|$b`
970 ///
971 /// Default: true
972 #[serde(default = "default_true")]
973 pub space_around_bitwise_binary_operators: bool,
974
975 /// Whether to add spaces around additive operators (+ and -).
976 ///
977 /// When enabled: `$a + $b`
978 /// When disabled: `$a+$b`
979 ///
980 /// Default: true
981 #[serde(default = "default_true")]
982 pub space_around_additive_binary_operators: bool,
983
984 /// Whether to add spaces around multiplicative operators (*, /, %).
985 ///
986 /// When enabled: `$a * $b`
987 /// When disabled: `$a*$b`
988 ///
989 /// Default: true
990 #[serde(default = "default_true")]
991 pub space_around_multiplicative_binary_operators: bool,
992
993 /// Whether to add spaces around exponentiation operator (**).
994 ///
995 /// When enabled: `$a ** $b`
996 /// When disabled: `$a**$b`
997 ///
998 /// Default: true
999 #[serde(default = "default_true")]
1000 pub space_around_exponentiation_binary_operators: bool,
1001
1002 /// Whether to add spaces around shift operators (<<, >>).
1003 ///
1004 /// When enabled: `$a << $b`
1005 /// When disabled: `$a<<$b`
1006 ///
1007 /// Default: true
1008 #[serde(default = "default_true")]
1009 pub space_around_shift_binary_operators: bool,
1010
1011 /// Whether to add spaces around the concatenation operator (.)
1012 ///
1013 /// When enabled: `$a . $b`
1014 /// When disabled: `$a.$b`
1015 ///
1016 /// Default: true
1017 #[serde(default = "default_true")]
1018 pub space_around_concatenation_binary_operator: bool,
1019
1020 /// Whether to add spaces around the null coalescing operator (??).
1021 ///
1022 /// When enabled: `$a ?? $b`
1023 /// When disabled: `$a??$b`
1024 ///
1025 /// Default: true
1026 #[serde(default = "default_true")]
1027 pub space_around_null_coalescing_binary_operator: bool,
1028
1029 /// Whether to add spaces around the elvis operator (?:).
1030 ///
1031 /// When enabled: `$a ?: $b`
1032 /// When disabled: `$a?:$b`
1033 ///
1034 /// Default: true
1035 #[serde(default = "default_true")]
1036 pub space_around_elvis_binary_operator: bool,
1037
1038 /// Whether to add spaces around the assignment in declare statements.
1039 ///
1040 /// When enabled: `declare(strict_types = 1)`
1041 /// When disabled: `declare(strict_types=1)`
1042 ///
1043 /// Default: false
1044 #[serde(default = "default_false")]
1045 pub space_around_assignment_in_declare: bool,
1046
1047 /// Whether to add spaces around the pipe in union type hints.
1048 ///
1049 /// When enabled: `function foo(int | string $bar)`
1050 /// When disabled: `function foo(int|string $bar)`
1051 ///
1052 /// Default: false
1053 #[serde(default = "default_false")]
1054 pub space_around_pipe_in_union_type: bool,
1055
1056 /// Whether to add spaces around the pipe in union type hints.
1057 ///
1058 /// When enabled: `function foo(Foo & Bar $bar)`
1059 /// When disabled: `function foo(Foo&Bar $bar)`
1060 ///
1061 /// Default: false
1062 #[serde(default = "default_false")]
1063 pub space_around_ampersand_in_intersection_type: bool,
1064
1065 /// Whether to add spaces within array access brackets.
1066 ///
1067 /// When enabled: `$array[ $key ]`
1068 /// When disabled: `$array[$key]`
1069 ///
1070 /// Default: false
1071 #[serde(default = "default_false")]
1072 pub space_within_array_access_brackets: bool,
1073
1074 /// Whether to add spaces within type parentheses.
1075 ///
1076 /// When enabled: `function foo(string|( Foo&Stringable ) $bar)`
1077 /// When disabled: `function foo(string|(Foo&Stringable) $bar)`
1078 ///
1079 /// Default: false
1080 #[serde(default = "default_false")]
1081 pub space_within_type_parenthesis: bool,
1082
1083 /// Whether to add spaces within array brackets.
1084 ///
1085 /// When enabled: `[ $item1, $item2 ]`
1086 /// When disabled: `[$item1, $item2]`
1087 ///
1088 /// Default: false
1089 #[serde(default = "default_false")]
1090 pub space_within_array_brackets: bool,
1091
1092 /// Whether to add spaces within grouping parentheses.
1093 ///
1094 /// When enabled: `( $expr ) - $expr`
1095 /// When disabled: `($expr) - $expr`
1096 ///
1097 /// Default: false
1098 #[serde(default = "default_false")]
1099 pub space_within_grouping_parenthesis: bool,
1100
1101 /// Whether to add spaces within legacy array parentheses.
1102 ///
1103 /// When enabled: `array( $item1, $item2 )`
1104 /// When disabled: `array($item1, $item2)`
1105 ///
1106 /// Default: false
1107 #[serde(default = "default_false")]
1108 pub space_within_legacy_array_parenthesis: bool,
1109
1110 /// Whether to add spaces within list parentheses.
1111 ///
1112 /// When enabled: `list( $item1, $item2 )`
1113 /// When disabled: `list($item1, $item2)`
1114 ///
1115 /// Default: false
1116 #[serde(default = "default_false")]
1117 pub space_within_list_parenthesis: bool,
1118
1119 /// Whether to add spaces within argument list parentheses.
1120 ///
1121 /// When enabled: `some_function( $arg1, $arg2 )`
1122 /// When disabled: `some_function($arg1, $arg2)`
1123 ///
1124 /// Default: false
1125 #[serde(default = "default_false")]
1126 pub space_within_argument_list_parenthesis: bool,
1127
1128 /// Whether to add spaces within parameter list parentheses.
1129 ///
1130 /// When enabled: `function foo( $param1, $param2 )`
1131 /// When disabled: `function foo($param1, $param2)`
1132 ///
1133 /// Default: false
1134 #[serde(default = "default_false")]
1135 pub space_within_parameter_list_parenthesis: bool,
1136
1137 /// Whether to add spaces within if statement parentheses.
1138 ///
1139 /// When enabled: `if ( $condition )`
1140 /// When disabled: `if ($condition)`
1141 ///
1142 /// Default: false
1143 #[serde(default = "default_false")]
1144 pub space_within_if_parenthesis: bool,
1145
1146 /// Whether to add spaces within for loop parentheses.
1147 ///
1148 /// When enabled: `for ( $i = 0; $i < 10; $i++ )`
1149 /// When disabled: `for ($i = 0; $i < 10; $i++)`
1150 ///
1151 /// Default: false
1152 #[serde(default = "default_false")]
1153 pub space_within_for_parenthesis: bool,
1154
1155 /// Whether to add spaces within foreach loop parentheses.
1156 ///
1157 /// When enabled: `foreach ( $items as $item )`
1158 /// When disabled: `foreach ($items as $item)`
1159 ///
1160 /// Default: false
1161 #[serde(default = "default_false")]
1162 pub space_within_foreach_parenthesis: bool,
1163
1164 /// Whether to add spaces within while loop parentheses.
1165 ///
1166 /// When enabled: `while ( $condition )`
1167 /// When disabled: `while ($condition)`
1168 ///
1169 /// Default: false
1170 #[serde(default = "default_false")]
1171 pub space_within_while_parenthesis: bool,
1172
1173 /// Whether to add spaces within catch block parentheses.
1174 ///
1175 /// When enabled: `catch ( Throwable $exception )`
1176 /// When disabled: `catch (Throwable $exception)`
1177 ///
1178 /// Default: false
1179 #[serde(default = "default_false")]
1180 pub space_within_catch_parenthesis: bool,
1181
1182 /// Whether to add spaces within switch statement parentheses.
1183 ///
1184 /// When enabled: `switch ( $value )`
1185 /// When disabled: `switch ($value)`
1186 ///
1187 /// Default: false
1188 #[serde(default = "default_false")]
1189 pub space_within_switch_parenthesis: bool,
1190
1191 /// Whether to add spaces within match statement parentheses.
1192 ///
1193 /// When enabled: `match ( $value )`
1194 /// When disabled: `match ($value)`
1195 ///
1196 /// Default: false
1197 #[serde(default = "default_false")]
1198 pub space_within_match_parenthesis: bool,
1199
1200 /// Whether to add an empty line after control structures (if, for, foreach, while, do, switch).
1201 ///
1202 /// Note: if an empty line already exists, it will be preserved regardless of this
1203 /// settings value.
1204 ///
1205 /// Default: false
1206 #[serde(default = "default_false")]
1207 pub empty_line_after_control_structure: bool,
1208
1209 /// Whether to add an empty line after opening tag.
1210 ///
1211 /// Note: if an empty line already exists, it will be preserved regardless of this
1212 /// settings value.
1213 ///
1214 /// Default: true
1215 #[serde(default = "default_true")]
1216 pub empty_line_after_opening_tag: bool,
1217
1218 /// Whether to add an empty line after declare statement.
1219 ///
1220 /// Note: if an empty line already exists, it will be preserved regardless of this
1221 /// settings value.
1222 ///
1223 /// Default: true
1224 #[serde(default = "default_true")]
1225 pub empty_line_after_declare: bool,
1226
1227 /// Whether to add an empty line after namespace.
1228 ///
1229 /// Note: if an empty line already exists, it will be preserved regardless of this
1230 /// settings value.
1231 ///
1232 /// Default: true
1233 #[serde(default = "default_true")]
1234 pub empty_line_after_namespace: bool,
1235
1236 /// Whether to add an empty line after use statements.
1237 ///
1238 /// Note: if an empty line already exists, it will be preserved regardless of this
1239 /// settings value.
1240 ///
1241 /// Default: true
1242 #[serde(default = "default_true")]
1243 pub empty_line_after_use: bool,
1244
1245 /// Whether to add an empty line after symbols (class, enum, interface, trait, function, const).
1246 ///
1247 /// Note: if an empty line already exists, it will be preserved regardless of this
1248 /// settings value.
1249 ///
1250 /// Default: true
1251 #[serde(default = "default_true")]
1252 pub empty_line_after_symbols: bool,
1253
1254 /// Whether to add an empty line after class-like constant.
1255 ///
1256 /// Note: if an empty line already exists, it will be preserved regardless of this
1257 /// settings value.
1258 ///
1259 /// Default: false
1260 #[serde(default = "default_false")]
1261 pub empty_line_after_class_like_constant: bool,
1262
1263 /// Whether to add an empty line after enum case.
1264 ///
1265 /// Note: if an empty line already exists, it will be preserved regardless of this
1266 /// settings value.
1267 ///
1268 /// Default: false
1269 #[serde(default = "default_false")]
1270 pub empty_line_after_enum_case: bool,
1271
1272 /// Whether to add an empty line after trait use.
1273 ///
1274 /// Note: if an empty line already exists, it will be preserved regardless of this
1275 /// settings value.
1276 ///
1277 /// Default: false
1278 #[serde(default = "default_false")]
1279 pub empty_line_after_trait_use: bool,
1280
1281 /// Whether to add an empty line after property.
1282 ///
1283 /// Note: if an empty line already exists, it will be preserved regardless of this
1284 /// settings value.
1285 ///
1286 /// Default: false
1287 #[serde(default = "default_false")]
1288 pub empty_line_after_property: bool,
1289
1290 /// Whether to add an empty line after method.
1291 ///
1292 /// Note: if an empty line already exists, it will be preserved regardless of this
1293 /// settings value.
1294 ///
1295 /// Default: true
1296 #[serde(default = "default_true")]
1297 pub empty_line_after_method: bool,
1298
1299 /// Whether to add an empty line before return statements.
1300 ///
1301 /// Default: false
1302 #[serde(default = "default_false")]
1303 pub empty_line_before_return: bool,
1304
1305 /// Whether to add an empty line before dangling comments.
1306 ///
1307 /// Default: true
1308 #[serde(default = "default_true")]
1309 pub empty_line_before_dangling_comments: bool,
1310
1311 /// Whether to use double slash comments instead of hash comments.
1312 ///
1313 /// When enabled: `// This is a comment`
1314 /// When disabled: `# This is a comment`
1315 ///
1316 /// Default: true
1317 #[serde(default = "default_true")]
1318 pub double_slash_comments: bool,
1319
1320 /// Whether to separate class-like members of different kinds with a blank line.
1321 ///
1322 /// Default: true
1323 #[serde(default = "default_true")]
1324 pub separate_class_like_members: bool,
1325}
1326
1327impl Default for FormatSettings {
1328 /// Sets default values to align with best practices.
1329 fn default() -> Self {
1330 Self {
1331 print_width: default_print_width(),
1332 tab_width: default_tab_width(),
1333 use_tabs: false,
1334 end_of_line: EndOfLine::default(),
1335 single_quote: true,
1336 trailing_comma: true,
1337 closure_brace_style: BraceStyle::SameLine,
1338 function_brace_style: BraceStyle::NextLine,
1339 method_brace_style: BraceStyle::NextLine,
1340 classlike_brace_style: BraceStyle::NextLine,
1341 control_brace_style: BraceStyle::SameLine,
1342 inline_empty_control_braces: false,
1343 inline_empty_closure_braces: true,
1344 inline_empty_function_braces: false,
1345 inline_empty_method_braces: false,
1346 inline_empty_constructor_braces: true,
1347 inline_empty_classlike_braces: false,
1348 inline_empty_anonymous_class_braces: true,
1349 static_before_visibility: false,
1350 null_type_hint: NullTypeHint::default(),
1351 break_promoted_properties_list: true,
1352 method_chain_breaking_style: MethodChainBreakingStyle::NextLine,
1353 line_before_binary_operator: false,
1354 sort_uses: true,
1355 separate_use_types: true,
1356 expand_use_groups: true,
1357 remove_trailing_close_tag: true,
1358 parentheses_around_new_in_member_access: false,
1359 parentheses_in_new_expression: true,
1360 parentheses_in_exit_and_die: true,
1361 parentheses_in_attribute: false,
1362 array_table_style_alignment: true,
1363 always_break_named_arguments_list: true,
1364 always_break_attribute_named_argument_lists: false,
1365 preserve_breaking_member_access_chain: false,
1366 preserve_breaking_argument_list: false,
1367 preserve_breaking_array_like: true,
1368 preserve_breaking_parameter_list: false,
1369 preserve_breaking_attribute_list: false,
1370 preserve_breaking_conditional_expression: false,
1371 space_before_if_parenthesis: true,
1372 space_before_for_parenthesis: true,
1373 space_before_foreach_parenthesis: true,
1374 space_before_while_parenthesis: true,
1375 space_before_catch_parenthesis: true,
1376 space_before_switch_parenthesis: true,
1377 space_before_match_parenthesis: true,
1378 space_before_arrow_function_parameter_list_parenthesis: false,
1379 space_before_closure_parameter_list_parenthesis: true,
1380 space_before_closure_use_clause_parenthesis: true,
1381 space_before_argument_list_parenthesis: false,
1382 space_before_function_parameter_list_parenthesis: false,
1383 space_before_list_parenthesis: false,
1384 space_before_legacy_array_parenthesis: false,
1385 space_before_for_semicolon: false,
1386 space_before_colon_in_return_type: false,
1387 space_before_colon_in_named_argument: false,
1388 space_before_colon_in_enum_backing_type: false,
1389 space_around_assignment_in_declare: false,
1390 space_around_pipe_in_union_type: false,
1391 space_within_array_access_brackets: false,
1392 space_within_array_brackets: false,
1393 space_within_grouping_parenthesis: false,
1394 space_within_list_parenthesis: false,
1395 space_within_argument_list_parenthesis: false,
1396 space_within_parameter_list_parenthesis: false,
1397 space_within_if_parenthesis: false,
1398 space_within_for_parenthesis: false,
1399 space_within_foreach_parenthesis: false,
1400 space_within_while_parenthesis: false,
1401 space_within_catch_parenthesis: false,
1402 space_within_switch_parenthesis: false,
1403 space_within_match_parenthesis: false,
1404 space_after_for_semicolon: true,
1405 space_after_colon_in_return_type: true,
1406 space_after_colon_in_named_argument: true,
1407 space_after_colon_in_enum_backing_type: true,
1408 space_before_hook_parameter_list_parenthesis: false,
1409 space_before_method_parameter_list_parenthesis: false,
1410 space_before_increment_unary_postfix_operator: false,
1411 space_before_decrement_unary_postfix_operator: false,
1412 space_around_assignment_operators: true,
1413 space_around_logical_binary_operators: true,
1414 space_around_equality_binary_operators: true,
1415 space_around_comparison_binary_operators: true,
1416 space_around_bitwise_binary_operators: true,
1417 space_around_additive_binary_operators: true,
1418 space_around_multiplicative_binary_operators: true,
1419 space_around_exponentiation_binary_operators: true,
1420 space_around_shift_binary_operators: true,
1421 space_around_concatenation_binary_operator: true,
1422 space_around_null_coalescing_binary_operator: true,
1423 space_around_elvis_binary_operator: true,
1424 space_around_ampersand_in_intersection_type: false,
1425 space_within_type_parenthesis: false,
1426 space_within_legacy_array_parenthesis: false,
1427 space_after_cast_unary_prefix_operators: true,
1428 space_after_reference_unary_prefix_operator: false,
1429 space_after_error_control_unary_prefix_operator: false,
1430 space_after_logical_not_unary_prefix_operator: false,
1431 space_after_bitwise_not_unary_prefix_operator: false,
1432 space_after_increment_unary_prefix_operator: false,
1433 space_after_decrement_unary_prefix_operator: false,
1434 space_after_additive_unary_prefix_operator: false,
1435 space_after_nullable_type_question_mark: false,
1436 empty_line_after_control_structure: false,
1437 empty_line_after_opening_tag: false,
1438 empty_line_after_declare: true,
1439 empty_line_after_namespace: true,
1440 empty_line_after_use: true,
1441 empty_line_after_symbols: true,
1442 empty_line_after_class_like_constant: false,
1443 empty_line_after_enum_case: false,
1444 empty_line_after_trait_use: false,
1445 empty_line_after_property: false,
1446 empty_line_after_method: true,
1447 empty_line_before_return: false,
1448 empty_line_before_dangling_comments: true,
1449 double_slash_comments: true,
1450 separate_class_like_members: true,
1451 }
1452 }
1453}
1454
1455/// Specifies the style of line endings.
1456#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
1457pub enum EndOfLine {
1458 #[default]
1459 #[serde(alias = "auto")]
1460 Auto,
1461 #[serde(alias = "lf")]
1462 Lf,
1463 #[serde(alias = "crlf")]
1464 Crlf,
1465 #[serde(alias = "cr")]
1466 Cr,
1467}
1468
1469/// Specifies the style of line endings.
1470#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
1471pub enum BraceStyle {
1472 #[serde(alias = "same_line")]
1473 SameLine,
1474 #[serde(alias = "next_line")]
1475 NextLine,
1476}
1477
1478#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
1479pub enum MethodChainBreakingStyle {
1480 #[serde(alias = "same_line")]
1481 SameLine,
1482 #[default]
1483 #[serde(alias = "next_line")]
1484 NextLine,
1485}
1486
1487impl BraceStyle {
1488 pub fn same_line() -> Self {
1489 Self::SameLine
1490 }
1491
1492 pub fn next_line() -> Self {
1493 Self::NextLine
1494 }
1495
1496 #[inline]
1497 pub fn is_next_line(&self) -> bool {
1498 *self == Self::NextLine
1499 }
1500}
1501
1502impl MethodChainBreakingStyle {
1503 #[inline]
1504 pub fn is_next_line(&self) -> bool {
1505 *self == Self::NextLine
1506 }
1507}
1508
1509impl EndOfLine {
1510 #[inline]
1511 pub const fn as_str(&self) -> &'static str {
1512 match self {
1513 Self::Crlf => "\r\n",
1514 Self::Cr => "\r",
1515 Self::Lf | Self::Auto => "\n",
1516 }
1517 }
1518}
1519
1520impl FromStr for EndOfLine {
1521 type Err = ();
1522
1523 fn from_str(s: &str) -> Result<Self, Self::Err> {
1524 Ok(match s {
1525 "crlf" => Self::Crlf,
1526 "cr" => Self::Cr,
1527 "auto" => Self::Auto,
1528 "lf" => Self::Lf,
1529 _ => Self::default(),
1530 })
1531 }
1532}
1533
1534/// Specifies null type hint style.
1535#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Hash, Serialize, Deserialize, PartialOrd, Ord)]
1536pub enum NullTypeHint {
1537 #[default]
1538 #[serde(alias = "null_pipe", alias = "pipe", alias = "long", alias = "|")]
1539 NullPipe,
1540 #[serde(alias = "question", alias = "short", alias = "?")]
1541 Question,
1542}
1543
1544impl NullTypeHint {
1545 pub fn is_question(&self) -> bool {
1546 *self == Self::Question
1547 }
1548}
1549
1550fn default_print_width() -> usize {
1551 120
1552}
1553
1554fn default_tab_width() -> usize {
1555 4
1556}
1557
1558fn default_false() -> bool {
1559 false
1560}
1561
1562fn default_true() -> bool {
1563 true
1564}