Repository: FriendsOfPHP/PHP-CS-Fixer (php)

Issue:
`braces` fixer adds unnecessary empty lines in files where code doesn't start at offset 0
## Bug report

given a file where code doesn't start at offset 0 (which is bad, I know), cs-fixer recently started  (through the `braces` fixer) adding random empty lines to the file in front of each indented statement.

If I manually fix the indent, the problem disappears.

### Code snippet that reproduces the problem

```php
<?php

    function foo()
    {
    }
```

running cs-fixer with just the `braces` fixer enabled will produce the following diff

```diff
   1) /path/to/test.php (braces)
      ---------- begin diff ----------
--- /path/to/test.php
+++ /path/to/test.php
@@ -1,5 +1,6 @@
 <?php

+
     function foo()
     {
     }

      ----------- end diff -----------
```

if I remove the 4 space indent at the beginning of all lines, the empty line will not be added.

Also, I can't quite reproduce it yet, but sometimes after making unrelated changes to the file, *another* empty line will be added.

Pull request description:
bug: SingleLineThrowFixer - Handle throw expression inside block
Closes #6647
Replaces #6649 

Patch:
diff --git a/src/Fixer/FunctionNotation/SingleLineThrowFixer.php b/src/Fixer/FunctionNotation/SingleLineThrowFixer.php
index c64147794..7a6e8c23a 100644
--- a/src/Fixer/FunctionNotation/SingleLineThrowFixer.php
+++ b/src/Fixer/FunctionNotation/SingleLineThrowFixer.php
@@ -78,7 +78,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
                 $blockType = Tokens::detectBlockType($tokens[$endCandidateIndex]);
 
                 if (null !== $blockType) {
-                    if (Tokens::BLOCK_TYPE_CURLY_BRACE === $blockType['type']) {
+                    if (Tokens::BLOCK_TYPE_CURLY_BRACE === $blockType['type'] || !$blockType['isStart']) {
                         break;
                     }
 


Test patch:
diff --git a/tests/Fixer/FunctionNotation/SingleLineThrowFixerTest.php b/tests/Fixer/FunctionNotation/SingleLineThrowFixerTest.php
index 1d2f7c200..fc3f93e18 100644
--- a/tests/Fixer/FunctionNotation/SingleLineThrowFixerTest.php
+++ b/tests/Fixer/FunctionNotation/SingleLineThrowFixerTest.php
@@ -340,5 +340,30 @@ public static function provideFix80Cases(): iterable
                 3 => "b"
             });',
         ];
+
+        yield [
+            '<?php
+$var = [
+    $something[1] ?? throw new Exception(123)
+];
+',
+            '<?php
+$var = [
+    $something[1] ?? throw new Exception(
+
+    123
+
+    )
+];
+',
+        ];
+
+        yield [
+            '<?php
+$var = [
+    $something[1] ?? throw new Exception()
+];
+',
+        ];
     }
 }