PrimeIntellect/SWE-rebench-V2 huggingface dataset:
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:
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()
+];
+',
+        ];
     }
 }
Repository: PHP-CS-Fixer/PHP-CS-Fixer (php)

Issue:
PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer removes only the first variable name
## Bug report
PHP version: 7.4
PHP CS Fixer 2.17.3 Desert Beast by Fabien Potencier and Dariusz Ruminski

Run via `https://github.com/symplify/easy-coding-standard`

Console output:
``` bash
13) FeedbackModalControl.php

    ---------- begin diff ----------
--- Original
+++ New
@@ -16,7 +16,7 @@
 {

     /**
-     * @var array<callable(string $feedback, FileUpload $screenshot): void>
+     * @var array<callable(string, FileUpload $screenshot): void>
      */
     public array $onSuccess = [];
    ----------- end diff -----------


Applied checkers:

 * PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer
```

Relevant source code:
```php
final class FeedbackModalControl extends Control
{

    /**
     * @var array<callable(string $feedback, FileUpload $screenshot): void>
     */
    public array $onSuccess = [];

}
```

Expected behavior:
Remove both variables.

Pull request:
fix: Remove all variable names in `@var` callable signature
Fixes #5402.

Patch:
diff --git a/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php b/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
index f2240105f..f42b2d9fe 100644
--- a/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
+++ b/src/Fixer/Phpdoc/PhpdocVarWithoutNameFixer.php
@@ -114,12 +114,12 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
 
     private function fixLine(Line $line): void
     {
-        $content = $line->getContent();
+        Preg::matchAll('/ \$'.TypeExpression::REGEX_IDENTIFIER.'(?<!\$this)/', $line->getContent(), $matches);
 
-        Preg::matchAll('/ \$'.TypeExpression::REGEX_IDENTIFIER.'(?<!\$this)/', $content, $matches);
-
-        if (isset($matches[0][0])) {
-            $line->setContent(str_replace($matches[0][0], '', $content));
+        if (isset($matches[0])) {
+            foreach ($matches[0] as $match) {
+                $line->setContent(str_replace($match, '', $line->getContent()));
+            }
         }
     }
 


Test patch:
diff --git a/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php b/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
index 19782bc33..f4c447bdb 100644
--- a/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
+++ b/tests/Fixer/Phpdoc/PhpdocVarWithoutNameFixerTest.php
@@ -595,6 +595,29 @@ class Foo
                 EOF
             ,
         ];
+
+        yield '@var with callable syntax' => [
+            <<<'EOF'
+                <?php
+
+                class Foo
+                {
+                    /** @var array<callable(string, Buzz): void> */
+                    protected $bar;
+                }
+                EOF
+            ,
+            <<<'EOF'
+                <?php
+
+                class Foo
+                {
+                    /** @var array<callable(string $baz, Buzz $buzz): void> */
+                    protected $bar;
+                }
+                EOF
+            ,
+        ];
     }
 
     /**
Repository: JuliaDiff/FiniteDifferences.jl (julia)

Issue:
Mutation of input arguments
Code like this https://github.com/JuliaDiff/FiniteDifferences.jl/blob/c7a4624092d90b6d49d5701967982226231d4478/src/grad.jl#L18

mutates the input argument, but before returning makes sure the input argument is restored to its original value. However, if the user-provided function errors, the input argument is left in a mutated state, which can cause bugs that are very hard to detect.

Pull request:
Fixes #221 
needs tests still

Patch:
diff --git a/src/grad.jl b/src/grad.jl
index 316d6ab..1aac95d 100644
--- a/src/grad.jl
+++ b/src/grad.jl
@@ -15,10 +15,12 @@ function jacobian(fdm, f, x::Vector{<:Real}; len=nothing)
     ẏs = map(eachindex(x)) do n
         return fdm(zero(eltype(x))) do ε
             xn = x[n]
-            x[n] = xn + ε
-            ret = copy(first(to_vec(f(x))))  # copy required incase `f(x)` returns something that aliases `x`
-            x[n] = xn  # Can't do `x[n] -= ϵ` as floating-point math is not associative
-            return ret
+            try
+                x[n] = xn + ε
+                return copy(first(to_vec(f(x))))  # copy required incase `f(x)` returns something that aliases `x`
+            finally
+                x[n] = xn  # Can't do `x[n] -= ϵ` as floating-point math is not associative
+            end
         end
     end
     return (reduce(hcat, ẏs), )


Test patch:
diff --git a/test/grad.jl b/test/grad.jl
index 9ebf197..cf36893 100644
--- a/test/grad.jl
+++ b/test/grad.jl
@@ -84,6 +84,19 @@ using FiniteDifferences: grad, jacobian, _jvp, jvp, j′vp, _j′vp, to_vec
         @test J ≈ one(Matrix{T}(undef, size(J)))
     end
 
+    @testset "jacobian that throws errors" begin
+        # https://github.com/JuliaDiff/FiniteDifferences.jl/issues/221
+        fdm = central_fdm(5, 1)
+        x = zeros(5)
+        try
+            jacobian(fdm, error, x)
+        catch err
+            @assert err isa ErrorException
+        end
+        # Make sure state of `x` is restored.
+        @test x == zeros(5)
+    end
+
     @testset "multi vars jacobian/grad" begin
         rng, fdm = MersenneTwister(123456), central_fdm(5, 1)