ernie-research/MEnvBench huggingface dataset:
Repository: PHP-CS-Fixer/PHP-CS-Fixer (PHP)

Issue:
PhpUnitAttributesFixer - remove parentheses as they appear
### Problem description

Rule: `\PhpCsFixer\Fixer\PhpUnit\PhpUnitAttributesFixer` 

Sometimes, people use invalid syntax with brackets when defining the dataProvider annotation. While PHPUnit handles this annotation without issues, using the same syntax with attributes results in an error. Could we automatically remove these brackets at runtime?


### Minimal reproducer CLI command

vendor/bin/php-cs-fixer

### Minimal reproducer code snippet

Before:

```php
    /**
     * @dataProvider provideExamples()
     */
    public function test(mixed $param): void
```

Expected result:

```php
    #[DataProvider('provideExamples')]
    public function test(mixed $param): void
```

Current:

```php
    #[DataProvider('provideExamples()')]
    public function test(mixed $param): void
```

### Fixer version

3.68.5

### PHP version

8.4.4

### How do you run Fixer?

Composer package

### Contribution Checks

- [x] I have verified if this problem was already reported
- [x] I am familiar with ["Feature or bug?"](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/feature-or-bug.rst)



Fix (patch):
diff --git a/src/Fixer/PhpUnit/PhpUnitAttributesFixer.php b/src/Fixer/PhpUnit/PhpUnitAttributesFixer.php
index c10c3ef7331..537e2763724 100644
--- a/src/Fixer/PhpUnit/PhpUnitAttributesFixer.php
+++ b/src/Fixer/PhpUnit/PhpUnitAttributesFixer.php
@@ -366,12 +366,20 @@ private static function fixDataProvider(Tokens $tokens, int $index, Annotation $
                     ...self::toClassConstant($class),
                     new Token(','),
                     new Token([T_WHITESPACE, ' ']),
-                    self::createEscapedStringToken($method),
+                    self::fixNameAndCreateEscapedStringToken($method),
                 ],
             );
         }
 
-        return self::createAttributeTokens($tokens, $index, 'DataProvider', self::createEscapedStringToken($matches[1]));
+        return self::createAttributeTokens($tokens, $index, 'DataProvider', self::fixNameAndCreateEscapedStringToken($matches[1]));
+    }
+
+    /**
+     * @see https://github.com/sebastianbergmann/phpunit/blob/11.5.12/src/Metadata/Parser/AnnotationParser.php#L266
+     */
+    private static function fixNameAndCreateEscapedStringToken(string $methodName): Token
+    {
+        return self::createEscapedStringToken(rtrim($methodName, " ()\n\r\t\v\x00"));
     }
 
     /**
Repository: shopware/shopware (PHP)

Issue:
Inactive customer can buy
### Shopware Version

6.6.10.6

### Affected area / extension

Platform(Default)

### Actual behaviour

- a customer is logged in in frontend
- the customer will be disabled in admin
- the customer can use his account furthermore

### Expected behaviour

the customer is being logged out, at least when accessing any commerce function.

### How to reproduce

see behaviour

### Definition of Done

- [ ] An automated test covers the fix.
- [ ] Integration/E2E testing in staging is done.
- [ ] Changelog markdown file created or updated in /changelog/_unreleased directory.
- [ ] Developer documentation written/updated.
- [ ] End user and/or developer documentation written or updated with clarification.
- [ ] Regression test created to ensure bug does not reappear, and automated regression tests pass.
- [ ] Code changes resolve the reported bug without introducing new issues.


Discussion: FYI: During the assembly of the `SalesChannelContext`, the Criteria for getting the customer missing a active check - we should add that.
don't add it to the criteria, do it afterwards on php side because of mysql table index



Fix (patch):
diff --git a/src/Core/System/SalesChannel/Context/SalesChannelContextFactory.php b/src/Core/System/SalesChannel/Context/SalesChannelContextFactory.php
index f63e3f5efd4..8ae885800a1 100644
--- a/src/Core/System/SalesChannel/Context/SalesChannelContextFactory.php
+++ b/src/Core/System/SalesChannel/Context/SalesChannelContextFactory.php
@@ -242,8 +242,9 @@ private function loadCustomer(array $options, Context $context): ?CustomerEntity
             new EqualsFilter('customer.boundSalesChannelId', $source->getSalesChannelId()),
         ]));
 
-        $customer = $this->customerRepository->search($criteria, $context)->getEntities()->get($customerId);
-        if (!$customer) {
+        $customer = $this->customerRepository->search($criteria, $context)->get($customerId);
+        // active check here instead of DAL filter due to no DB index
+        if (!$customer?->getActive()) {
             return null;
         }
Repository: 10up/ElasticPress (PHP)

Issue:
Increase Unit tests coverage for Feature -> WooCommerce 
### Is your enhancement related to a problem? Please describe.

Currently only 20% of functionality of https://github.com/10up/ElasticPress/tree/develop/includes/classes/Feature/WooCommerce  is cover in the unit tests. We need to add the more unit tests.



### Designs

_No response_

### Describe alternatives you've considered

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct



Fix (patch):
diff --git a/includes/classes/Feature/WooCommerce/WooCommerce.php b/includes/classes/Feature/WooCommerce/WooCommerce.php
index 2322a4381f..5f45bbe276 100644
--- a/includes/classes/Feature/WooCommerce/WooCommerce.php
+++ b/includes/classes/Feature/WooCommerce/WooCommerce.php
@@ -300,12 +300,15 @@ public function translate_args( $query ) {
 
 		// Act only on a defined subset of all indexable post types here
 		$post_types = array(
-			'product',
 			'shop_order',
 			'shop_order_refund',
 			'product_variation',
 		);
 
+		if ( $query->is_post_type_archive( 'product' ) || isset( $query->query_vars['ep_integrate'] ) && filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) {
+			$post_types[] = 'product';
+		}
+
 		/**
 		 * Expands or contracts the post_types eligible for indexing.
 		 *
@@ -1221,6 +1224,14 @@ protected function should_integrate_with_query( $query ) {
 			return false;
 		}
 
+		if ( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST ) {
+			return false;
+		}
+
+		if ( isset( $query->query_vars['ep_integrate'] ) && ! filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) {
+			return false;
+		}
+
 		/**
 		 * Filter to skip WP Query integration
 		 *
@@ -1229,8 +1240,7 @@ protected function should_integrate_with_query( $query ) {
 		 * @param  {WP_Query} $query WP Query to evaluate
 		 * @return  {bool} New skip value
 		 */
-		if ( apply_filters( 'ep_skip_query_integration', false, $query ) ||
-			( isset( $query->query_vars['ep_integrate'] ) && ! filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) ) {
+		if ( apply_filters( 'ep_skip_query_integration', false, $query ) ) {
 			return false;
 		}
 
@@ -1238,13 +1248,10 @@ protected function should_integrate_with_query( $query ) {
 			return false;
 		}
 
-		$product_name = $query->get( 'product', false );
-
-		$post_parent = $query->get( 'post_parent', false );
-
 		/**
 		 * Do nothing for single product queries
 		 */
+		$product_name = $query->get( 'product', false );
 		if ( ! empty( $product_name ) || $query->is_single() ) {
 			return false;
 		}
@@ -1252,6 +1259,7 @@ protected function should_integrate_with_query( $query ) {
 		/**
 		 * ElasticPress does not yet support post_parent queries
 		 */
+		$post_parent = $query->get( 'post_parent', false );
 		if ( ! empty( $post_parent ) ) {
 			return false;
 		}
@@ -1263,13 +1271,6 @@ protected function should_integrate_with_query( $query ) {
 			return false;
 		}
 
-		/**
-		 * Cant hook into WC API yet
-		 */
-		if ( defined( 'WC_API_REQUEST' ) && WC_API_REQUEST ) {
-			return false;
-		}
-
 		return true;
 	}
Repository: zircote/swagger-php (PHP)

Issue:
Mix types when name is similar
```php
#[\OpenApi\Attributes\Schema()]
class Test
{
    /**
     * @param ?string[] $blah_values
     */
    public function __construct(
        #[\OpenApi\Attributes\Property(example: 'My value')]
        public ?string $blah,
        #[\OpenApi\Attributes\Property(nullable: true, items: new \OpenApi\Attributes\Items(type: 'string', example: 'hello'))]
        public ?array $blah_values,
    ) {
    }
}
```

output
```json
"Test": {
                "properties": {
                    "blah": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "example": "My value",
                        "nullable": true
                    },
                    "blah_values": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "example": "hello"
                        },
                        "nullable": true
                    }
                },
                "type": "object"
            },
```

blah is string or null, but it output array or null because there is another type that start with "blah" that is array



Fix (patch):
diff --git a/src/Type/LegacyTypeResolver.php b/src/Type/LegacyTypeResolver.php
index 4897e2882..33fd4a8fd 100644
--- a/src/Type/LegacyTypeResolver.php
+++ b/src/Type/LegacyTypeResolver.php
@@ -188,7 +188,7 @@ protected function getDocblockTypeDetails(\Reflector $reflector, ?Context $conte
         $pattern = "/$tagName\s+(?<type>[^\s]+)([ \t])?/im";
         if ('@param' === $tagName) {
             // need to match on $name too
-            $pattern = "/$tagName\s+(?<type>[^\s]+)([ \t])?\\$$name/im";
+            $pattern = "/$tagName\s+(?<type>[^\s]+)([ \t])?\\$$name([\s\r\n])/im";
         }
 
         $docComment = str_replace("\r\n", "\n", $docComment);
Repository: zircote/swagger-php (PHP)

Issue:
Add support for `doctrine/annotations` ^2.0
The `doctrine/annotations` package got a [2.0 release](https://github.com/doctrine/annotations/releases/tag/2.0.0) just before the new year.  Unfortunately, the release has a bit of impact on this package as the `OpenApi\Generator` class [relies on the deprecated `Doctrine\Common\Annotations\AnnotationRegistry::registerLoader()`](https://github.com/zircote/swagger-php/blob/e505bce612a86fe90f8fd50917e0848afc5d2ba8/src/Generator.php#L93-L113) to throw a targeted exception message to help with migrating from older versions (first introduced in https://github.com/zircote/swagger-php/commit/dddf1cf5bafe047dfc59fa3f2901c7a5138b1db0).

It's easy to add a `method_exists()` check to the existing [`class_exists()` check](https://github.com/zircote/swagger-php/blob/e505bce612a86fe90f8fd50917e0848afc5d2ba8/src/Generator.php#L89), but looking at the code and its purpose (also realizing that I've only been using this package since some point after 4.0 was released), a part of me wonders if this block of code even needs to exist moving forward as it looks like its entire purpose was to help catch issues with the namespace migration between 2.x and 3.x.


Discussion: Correct on both. I think I'll keep the code in there for now as with PhpCSFixer not allowing ^2.0 yet its mostly decoration.
I'll mark the code block as deprecated so we can remove it at a later time.



Fix (patch):
diff --git a/composer.json b/composer.json
index a68b5f4e6..d5e09024d 100644
--- a/composer.json
+++ b/composer.json
@@ -46,7 +46,7 @@
     "require": {
         "php": ">=7.2",
         "ext-json": "*",
-        "doctrine/annotations": "^1.7",
+        "doctrine/annotations": "^1.7 || ^2.0",
         "psr/log": "^1.1 || ^2.0 || ^3.0",
         "symfony/deprecation-contracts": "^2 || ^3",
         "symfony/finder": ">=2.2",
diff --git a/src/Generator.php b/src/Generator.php
index fbfc7b8df..1fdee5b7f 100644
--- a/src/Generator.php
+++ b/src/Generator.php
@@ -80,13 +80,14 @@ public function __construct(?LoggerInterface $logger = null)
         $this->setNamespaces(self::DEFAULT_NAMESPACES);
 
         // kinda config stack to stay BC...
+        // @deprecated Can be removed once doctrine/annotations 2.0 becomes mandatory
         $this->configStack = new class() {
             protected $generator;
 
             public function push(Generator $generator): void
             {
                 $this->generator = $generator;
-                if (class_exists(AnnotationRegistry::class, true)) {
+                if (class_exists(AnnotationRegistry::class, true) && method_exists(AnnotationRegistry::class, 'registerLoader')) {
                     // keeping track of &this->generator allows to 'disable' the loader after we are done;
                     // no unload, unfortunately :/
                     $gref = &$this->generator;
Repository: wp-graphql/wp-graphql (PHP)

Issue:
Uncategorized is added by default when adding a post
### Description


![image](https://github.com/user-attachments/assets/031cee66-fbe3-46c6-8f4a-06c87feb1d60)

![image](https://github.com/user-attachments/assets/38d39943-7d02-42bb-97fd-be53d0ffac63)

When adding a post, it adds the 'Uncategorized' category by default. Is there a way to fix this?


### Steps to reproduce

1. Create a create post mutation as in the picture and use it (only two categories are defined)
2. "Uncategorized" is added

### Additional context

_No response_

### WPGraphQL Version

1.29.3

### WordPress Version

 6.7.1

### PHP Version

7.4.33

### Additional environment details

_No response_

### Please confirm that you have searched existing issues in the repo.

- [X] Yes

### Please confirm that you have disabled ALL plugins except for WPGraphQL.

- [ ] Yes
- [ ] My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.


Discussion: @Pizza1 hello, Thanks for reporting this and providing clear steps to reproduce! 

I have confirmed this behavior and am looking into a resolution. 



Fix (patch):
diff --git a/src/Data/PostObjectMutation.php b/src/Data/PostObjectMutation.php
index cbb867196..e077db2dc 100644
--- a/src/Data/PostObjectMutation.php
+++ b/src/Data/PostObjectMutation.php
@@ -355,6 +355,13 @@ protected static function set_object_terms( int $post_id, array $input, WP_Post_
 						return;
 					}
 
+					if ( $append && 'category' === $tax_object->name ) {
+						$default_category_id = absint( get_option( 'default_category' ) );
+						if ( ! in_array( $default_category_id, $terms_to_connect, true ) ) {
+							wp_remove_object_terms( $post_id, $default_category_id, 'category' );
+						}
+					}
+
 					wp_set_object_terms( $post_id, $terms_to_connect, $tax_object->name, $append );
 				}
 			}
Repository: codeigniter4/CodeIgniter4 (PHP)

Issue:
Bug: The getFiles method of \CodeIgniter\Events class is declared as 'public', but it should probably be 'public static'.
### PHP Version

8.2

### CodeIgniter4 Version

4.2.11

### CodeIgniter4 Installation Method

Composer (using `codeigniter4/appstarter`)

### Which operating systems have you tested for this bug?

Linux

### Which server did you use?

apache

### Database

MySQL

### What happened?

The getFiles method of \CodeIgniter\Events class is declared as 'public', but it should probably be 'public static'?

### Steps to Reproduce

Just try to make this call (which will throw an error since the getFiles is not static, and its an anti-pattern to instantiate the Events class just to be able to call this method.):
\CodeIgniter\Events\Events::getFiles();

### Expected Output

A list of Events.php config file locations.

### Anything else?

We ran into this issue while trying to implement a solution that requires us to get a list of those locations, our system is a web-based configuration for installations were you don't have access to modify the files on the drive.

Our current workaround was just to patch the class to add the static keyword to that method definition and update our installation. Just wondering if there is maybe a valid reason why the getFiles method is not public static and if maybe we should change it to include the static keyword.


Discussion: The properties in the Event class are all static and all methods other than getFiles() are static.
So I agree that the method should be static.



Fix (patch):
diff --git a/system/Events/Events.php b/system/Events/Events.php
index 3117969882df..064f01ab4104 100644
--- a/system/Events/Events.php
+++ b/system/Events/Events.php
@@ -246,7 +246,7 @@ public static function setFiles(array $files)
      *
      * @return string[]
      */
-    public function getFiles()
+    public static function getFiles()
     {
         return static::$files;
     }
Repository: dedoc/scramble (PHP)

Issue:
Add `confirmed` rule support
        Rule:
'password'         => [
    'required',
    'string',
    'confirmed',
],

Problem:
Docs not showing the 'password_confirmation' parameter

_Originally posted by @JesperFiltenborg in https://github.com/dedoc/scramble/discussions/108_
      



Fix (patch):
diff --git a/src/Support/Generator/Parameter.php b/src/Support/Generator/Parameter.php
index 2e6222126..a4ef05928 100644
--- a/src/Support/Generator/Parameter.php
+++ b/src/Support/Generator/Parameter.php
@@ -65,6 +65,13 @@ public function required(bool $required)
         return $this;
     }
 
+    public function setName(string $name): self
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
     public function setSchema(?Schema $schema): self
     {
         $this->schema = $schema;
diff --git a/src/Support/OperationExtensions/RulesExtractor/RulesToParameters.php b/src/Support/OperationExtensions/RulesExtractor/RulesToParameters.php
index 8fc727156..cecd17f50 100644
--- a/src/Support/OperationExtensions/RulesExtractor/RulesToParameters.php
+++ b/src/Support/OperationExtensions/RulesExtractor/RulesToParameters.php
@@ -41,6 +41,7 @@ public function handle()
         return collect($this->rules)
             ->map(fn ($rules, $name) => (new RulesToParameter($name, $rules, $this->nodeDocs[$name] ?? null, $this->openApiTransformer))->generate())
             ->pipe(\Closure::fromCallable([$this, 'handleNested']))
+            ->pipe(\Closure::fromCallable([$this, 'handleConfirmed']))
             ->values()
             ->all();
     }
@@ -88,6 +89,27 @@ private function handleNested(Collection $parameters)
             ->merge($nested);
     }
 
+    private function handleConfirmed(Collection $parameters)
+    {
+        $confirmedParamNameRules = collect($this->rules)
+            ->map(fn ($rules, $name) => [$name, Arr::wrap(is_string($rules) ? explode('|', $rules) : $rules)])
+            ->first(fn ($nameRules) => in_array('confirmed', $nameRules[1]));
+
+        if (! $confirmedParamNameRules) {
+            return $parameters;
+        }
+
+        /** @var Parameter $confirmedParam */
+        $confirmedParam = $parameters->first(fn ($p) => $p->name === $confirmedParamNameRules[0]);
+
+        $parameters->offsetSet(
+            $name = "$confirmedParamNameRules[0]_confirmation",
+            (clone $confirmedParam)->setName($name),
+        );
+
+        return $parameters;
+    }
+
     private function setDeepType(Type &$base, string $key, Type $typeToSet)
     {
         $containingType = $this->getOrCreateDeepTypeContainer(
Repository: dedoc/scramble (PHP)

Issue:
Rule::enum doesn't take into consideration additional params
`Rule::enum` ignores `only` or `except` methods, which allows you to limit which enum values are allowed.

https://laravel.com/docs/master/validation#rule-enum

I've updated to latest version `0.11.4.`

<img width="1205" alt="Screenshot 2024-07-15 at 21 01 37" src="https://github.com/user-attachments/assets/4303a47a-f234-44a8-b810-1d979558cc1e">

# expected behavior
It should limit enum values which passed as argument to `only` function

PS. Thank you for an amazing library.




Discussion: I'm also running into the same problem
Here are the screenshots
![image](https://github.com/user-attachments/assets/030da88e-f0c6-4367-940c-2a3b04dbdd99)
![image](https://github.com/user-attachments/assets/14b251c4-45f3-435c-b109-8d1d40d96718)


If someone knows it is possible to hide the Enum values not in my only() call.\
Let me know!
Or if its not possible would be awesome if it was added as feature



Fix (patch):
diff --git a/src/Support/OperationExtensions/RulesExtractor/RulesMapper.php b/src/Support/OperationExtensions/RulesExtractor/RulesMapper.php
index acbaa386e..d8f345892 100644
--- a/src/Support/OperationExtensions/RulesExtractor/RulesMapper.php
+++ b/src/Support/OperationExtensions/RulesExtractor/RulesMapper.php
@@ -11,6 +11,8 @@
 use Dedoc\Scramble\Support\Generator\Types\UnknownType;
 use Dedoc\Scramble\Support\Generator\TypeTransformer;
 use Dedoc\Scramble\Support\Type\ObjectType;
+use Dedoc\Scramble\Support\Type\TypeHelper;
+use Dedoc\Scramble\Support\Type\Union;
 use Illuminate\Support\Str;
 use Illuminate\Support\Stringable;
 use Illuminate\Validation\Rules\Enum;
@@ -168,9 +170,26 @@ public function enum(Type $_, Enum $rule)
 
         $enumName = $getProtectedValue($rule, 'type');
 
-        return $this->openApiTransformer->transform(
-            new ObjectType($enumName)
-        );
+        $objectType = new ObjectType($enumName);
+
+        $except = $getProtectedValue($rule, 'except');
+        $only = $getProtectedValue($rule, 'only');
+
+        if ($except || $only) {
+            $cases = collect($enumName::cases())
+                ->reject(fn ($case) => in_array($case, $except))
+                ->filter(fn ($case) => !$only || in_array($case, $only));
+
+            if (! isset($cases->first()?->value)) {
+                return new UnknownType("$enumName enum doesnt have values (only/except context)");
+            }
+
+            return $this->openApiTransformer->transform(Union::wrap(
+                $cases->map(fn ($c) => TypeHelper::createTypeFromValue($c->value))->all()
+            ));
+        }
+
+        return $this->openApiTransformer->transform($objectType);
     }
 
     public function image(Type $type)
Repository: dedoc/scramble (PHP)

Issue:
ModelInfo->getCastsWithDates() - array_flip error
I am getting the following error when generating API documentation for my Laravel 10 project. 

"array_flip(): Can only flip string and integer values, entry skipped {"exception":"[object] (ErrorException(code: 0): array_flip()"

The array that $model->getDates() returns when this blows up, looks like this:
```
local.DEBUG: Array
(
    [0] => created_at
    [1] =>
)
```

It appears that $model->getDates() returns an array of two entries; however, one is null. I'm not sure why this is happening. However, it's easy to modify getCastType() to not blow up and return a null when calling getCastsWithDates(); it appears to work fine.

ModelInfo.php: Line 323



Discussion: @deffjay fixed in 0.8.1

https://github.com/dedoc/scramble/releases/tag/v0.8.1



Fix (patch):
diff --git a/src/Support/ResponseExtractor/ModelInfo.php b/src/Support/ResponseExtractor/ModelInfo.php
index d2067bf40..a3a785c73 100644
--- a/src/Support/ResponseExtractor/ModelInfo.php
+++ b/src/Support/ResponseExtractor/ModelInfo.php
@@ -321,6 +321,7 @@ protected function getCastType($column, $model)
     protected function getCastsWithDates($model)
     {
         return collect($model->getDates())
+            ->filter()
             ->flip()
             ->map(fn () => 'datetime')
             ->merge($model->getCasts());