Commit 0e8478f
committed
Squiz/FunctionSpacing: selectively ignore nested functions
The `Squiz.WhiteSpace.FunctionSpacing` sniff enforces a defined number of blank lines before and after a function declaration.
However, when a function is declared nested within another function, this may conflict with rules about superfluous blank lines within a function causing a fixer conflict.
This commit fixes this conflict by ignoring an error for nested function declarations when the required spacing for before/after in the specific situation being examined would be more than 1 line.
Includes tests.
Includes some adjustments to pre-existing tests.
This doesn't diminish the value of those pre-existing tests.
These tests were introduced via c3a7ec5 and 07ccaf2 to address squizlabs/PHP_CodeSniffer 2406, which was about the sniff recognizing nested functions as (potentially) first or last and applying the correct spacing based on `spacingBeforeFirst`/`spacingAfterLast` properties in those cases.
The current fix doesn't "undo" that change and the error codes for nested functions are still correctly identifying first/last functions.1 parent bfdc6ea commit 0e8478f
File tree
4 files changed
+157
-22
lines changed- src/Standards/Squiz
- Sniffs/WhiteSpace
- Tests/WhiteSpace
4 files changed
+157
-22
lines changedLines changed: 18 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
105 | 117 | | |
106 | 118 | | |
107 | 119 | | |
| |||
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
216 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
217 | 231 | | |
218 | 232 | | |
219 | 233 | | |
| |||
324 | 338 | | |
325 | 339 | | |
326 | 340 | | |
327 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
328 | 344 | | |
329 | 345 | | |
330 | 346 | | |
| |||
Lines changed: 65 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| |||
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
Lines changed: 63 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
506 | | - | |
| 506 | + | |
507 | 507 | | |
508 | 508 | | |
509 | 509 | | |
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
519 | | - | |
520 | 518 | | |
521 | 519 | | |
522 | 520 | | |
523 | 521 | | |
524 | 522 | | |
525 | 523 | | |
526 | | - | |
527 | | - | |
528 | 524 | | |
529 | | - | |
530 | | - | |
531 | 525 | | |
532 | 526 | | |
533 | | - | |
534 | | - | |
535 | 527 | | |
536 | 528 | | |
537 | 529 | | |
| |||
541 | 533 | | |
542 | 534 | | |
543 | 535 | | |
544 | | - | |
545 | | - | |
546 | 536 | | |
547 | 537 | | |
548 | 538 | | |
| |||
551 | 541 | | |
552 | 542 | | |
553 | 543 | | |
554 | | - | |
555 | | - | |
556 | 544 | | |
557 | 545 | | |
558 | | - | |
559 | | - | |
560 | 546 | | |
561 | 547 | | |
562 | 548 | | |
563 | 549 | | |
564 | 550 | | |
565 | 551 | | |
566 | | - | |
567 | | - | |
568 | 552 | | |
569 | 553 | | |
570 | 554 | | |
| |||
822 | 806 | | |
823 | 807 | | |
824 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| |||
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| |||
0 commit comments