nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Peternator7/strum
Pull request #76 (2019-11-08 22:42:45)

Add checks to guard against overflow in iterator methods.
When a generated iterator runs of the end it keeps on incrementing the index variable, which is undesirable. Furthermore the size_hint method does not guard against the index being greater than the variant count, which causes an overflow.

These issues cause our static analyses [tool](https://github.com/facebookexperimental/MIRAI) to generate warnings when analyzing code generated by strum, which is annoying.

Thanks for considering this.


Patch:
diff --git a/strum_macros/src/macros/enum_iter.rs b/strum_macros/src/macros/enum_iter.rs
index afc6d8b..a62bfd8 100644
--- a/strum_macros/src/macros/enum_iter.rs
+++ b/strum_macros/src/macros/enum_iter.rs
@@ -83,12 +83,14 @@ pub fn enum_iter_inner(ast: &syn::DeriveInput) -> TokenStream {
                     #(#arms),*
                 };
 
-                self.idx += 1;
+                if self.idx < #variant_count {
+                    self.idx += 1;
+                }
                 output
             }
 
             fn size_hint(&self) -> (usize, Option<usize>) {
-                let t = #variant_count - self.idx;
+                let t = if self.idx >= #variant_count { 0 } else { #variant_count - self.idx };
                 (t, Some(t))
             }
         }


Test patch:
diff --git a/strum_tests/tests/enum_iter.rs b/strum_tests/tests/enum_iter.rs
index e3cffa5..b0813ef 100644
--- a/strum_tests/tests/enum_iter.rs
+++ b/strum_tests/tests/enum_iter.rs
@@ -63,6 +63,9 @@ fn len_test() {
     i.next();
 
     assert_eq!(0, i.len());
+    i.next();
+
+    assert_eq!(0, i.size_hint().1.unwrap());
 }
 
 #[test]
Repository: Peternator7/strum
Pull request #95 (2020-05-23 22:34:35)

Fix Display macro to handle fill/align


Patch:
diff --git a/strum_macros/src/macros/strings/display.rs b/strum_macros/src/macros/strings/display.rs
index b2f24d3..2260b60 100644
--- a/strum_macros/src/macros/strings/display.rs
+++ b/strum_macros/src/macros/strings/display.rs
@@ -47,7 +47,7 @@ pub fn display_inner(ast: &syn::DeriveInput) -> TokenStream {
             Named(..) => quote! { {..} },
         };
 
-        arms.push(quote! { #name::#ident #params => f.write_str(#output) });
+        arms.push(quote! { #name::#ident #params => f.pad(#output) });
     }
 
     if arms.len() < variants.len() {


Test patch:
diff --git a/strum_tests/tests/display.rs b/strum_tests/tests/display.rs
index 3642f60..c36d6d2 100644
--- a/strum_tests/tests/display.rs
+++ b/strum_tests/tests/display.rs
@@ -19,6 +19,14 @@ fn to_blue_string() {
     assert_eq!(String::from("blue"), format!("{}", Color::Blue { hue: 0 }));
 }
 
+#[test]
+fn test_formatters() {
+    assert_eq!(String::from("  blue"), format!("{:>6}", Color::Blue { hue: 0 }));
+    assert_eq!(String::from("blue  "), format!("{:<6}", Color::Blue { hue: 0 }));
+    assert_eq!(String::from(" blue "), format!("{:^6}", Color::Blue { hue: 0 }));
+    assert_eq!(String::from("bl"), format!("{:.2}", Color::Blue { hue: 0 }));
+}
+
 #[test]
 fn to_yellow_string() {
     assert_eq!(String::from("yellow"), format!("{}", Color::Yellow));
Repository: Peternator7/strum
Pull request #196 (2021-11-20 00:11:09)

Add tests for nostd environment


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 619d955..094b6e6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,7 +2,7 @@
 members = [
     "strum",
     "strum_macros",
-    "strum_tests"
+    "strum_tests",
+    "strum_nostd_tests"
 ]
-
-exclude = [ "strum_tests_rename" ]
\ No newline at end of file
+ 
\ No newline at end of file


Test patch:
diff --git a/strum_nostd_tests/Cargo.toml b/strum_nostd_tests/Cargo.toml
new file mode 100644
index 0000000..9e44e16
--- /dev/null
+++ b/strum_nostd_tests/Cargo.toml
@@ -0,0 +1,13 @@
+[package]
+name = "strum_nostd_tests"
+version = "0.23.1"
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+strum = { path = "../strum", features = ["derive"] }
+strum_macros = { path = "../strum_macros", features = [] }
+
+[dev-dependencies]
+rustversion = "1.0"
\ No newline at end of file
diff --git a/strum_nostd_tests/src/lib.rs b/strum_nostd_tests/src/lib.rs
new file mode 100644
index 0000000..816c073
--- /dev/null
+++ b/strum_nostd_tests/src/lib.rs
@@ -0,0 +1,37 @@
+#![no_std]
+
+#[cfg(test)]
+mod tests {
+    use core::str::FromStr;
+    use strum::EnumString;
+
+    #[derive(Debug, Eq, PartialEq, EnumString)]
+    enum Color {
+        Red,
+        Blue {
+            hue: usize,
+        },
+        #[strum(serialize = "y", serialize = "yellow")]
+        Yellow,
+        #[strum(to_string = "purp")]
+        Purple,
+        #[strum(serialize = "blk", serialize = "Black", ascii_case_insensitive)]
+        Black,
+    }
+
+    #[test]
+    fn from_str_no_std() {
+        assert_eq!(Color::Yellow, Color::from_str("yellow").unwrap());
+    }
+
+    #[test]
+    #[rustversion::since(1.34)]
+    fn try_from_str_no_std() {
+        use core::convert::TryFrom;
+        assert_eq!(Color::Yellow, Color::try_from("yellow").unwrap());
+    }
+
+    #[test]
+    #[rustversion::before(1.34)]
+    fn try_from_str_no_std() {}
+}
diff --git a/strum_tests/tests/from_str.rs b/strum_tests/tests/from_str.rs
index 463e3b5..845768c 100644
--- a/strum_tests/tests/from_str.rs
+++ b/strum_tests/tests/from_str.rs
@@ -131,7 +131,7 @@ fn lifetime_test() {
 #[derive(Debug, Eq, PartialEq, EnumString)]
 enum Generic<T: Default> {
     Gen(T),
-    None,
+    Error,
 }
 
 #[test]
Repository: Peternator7/strum
Pull request #410 (2025-02-08 16:59:11)

Use a "Path" instead of "String" for FromStr's error methods


Patch:
diff --git a/strum_macros/src/helpers/metadata.rs b/strum_macros/src/helpers/metadata.rs
index 4c333e4..9863d67 100644
--- a/strum_macros/src/helpers/metadata.rs
+++ b/strum_macros/src/helpers/metadata.rs
@@ -95,16 +95,12 @@ impl Parse for EnumMeta {
         } else if lookahead.peek(kw::parse_err_ty) {
             let kw = input.parse::<kw::parse_err_ty>()?;
             input.parse::<Token![=]>()?;
-            let path_str: LitStr = input.parse()?;
-            let path_tokens = parse_str(&path_str.value())?;
-            let path = parse2(path_tokens)?;
+            let path: Path = input.parse()?;
             Ok(EnumMeta::ParseErrTy { kw, path })
         } else if lookahead.peek(kw::parse_err_fn) {
             let kw = input.parse::<kw::parse_err_fn>()?;
             input.parse::<Token![=]>()?;
-            let path_str: LitStr = input.parse()?;
-            let path_tokens = parse_str(&path_str.value())?;
-            let path = parse2(path_tokens)?;
+            let path: Path = input.parse()?;
             Ok(EnumMeta::ParseErrFn { kw, path })
         } else if lookahead.peek(kw::const_into_str) {
             Ok(EnumMeta::ConstIntoStr(input.parse()?))


Test patch:
diff --git a/strum_tests/tests/from_str.rs b/strum_tests/tests/from_str.rs
index ff4ffeb..31456e1 100644
--- a/strum_tests/tests/from_str.rs
+++ b/strum_tests/tests/from_str.rs
@@ -232,8 +232,8 @@ fn color_default_with_white() {
 
 #[derive(Debug, EnumString)]
 #[strum(
-    parse_err_fn = "some_enum_not_found_err",
-    parse_err_ty = "CaseCustomParseErrorNotFoundError"
+    parse_err_fn = some_enum_not_found_err,
+    parse_err_ty = CaseCustomParseErrorNotFoundError
 )]
 enum CaseCustomParseErrorEnum {
     #[strum(serialize = "red")]
Repository: Peternator7/strum
Pull request #411 (2025-02-08 19:57:41)

Per cargo docs, this should fix the circular dep when publishing strum


Patch:
diff --git a/strum_macros/Cargo.toml b/strum_macros/Cargo.toml
index f76a994..f3635cf 100644
--- a/strum_macros/Cargo.toml
+++ b/strum_macros/Cargo.toml
@@ -27,4 +27,4 @@ rustversion = "1.0"
 syn = { version = "2.0", features = ["parsing"] }
 
 [dev-dependencies]
-strum = { path = "../strum", version= "0.26" }
+strum = { path = "../strum" }
diff --git a/strum_macros/src/helpers/metadata.rs b/strum_macros/src/helpers/metadata.rs
index 9863d67..4c333e4 100644
--- a/strum_macros/src/helpers/metadata.rs
+++ b/strum_macros/src/helpers/metadata.rs
@@ -95,12 +95,16 @@ impl Parse for EnumMeta {
         } else if lookahead.peek(kw::parse_err_ty) {
             let kw = input.parse::<kw::parse_err_ty>()?;
             input.parse::<Token![=]>()?;
-            let path: Path = input.parse()?;
+            let path_str: LitStr = input.parse()?;
+            let path_tokens = parse_str(&path_str.value())?;
+            let path = parse2(path_tokens)?;
             Ok(EnumMeta::ParseErrTy { kw, path })
         } else if lookahead.peek(kw::parse_err_fn) {
             let kw = input.parse::<kw::parse_err_fn>()?;
             input.parse::<Token![=]>()?;
-            let path: Path = input.parse()?;
+            let path_str: LitStr = input.parse()?;
+            let path_tokens = parse_str(&path_str.value())?;
+            let path = parse2(path_tokens)?;
             Ok(EnumMeta::ParseErrFn { kw, path })
         } else if lookahead.peek(kw::const_into_str) {
             Ok(EnumMeta::ConstIntoStr(input.parse()?))


Test patch:
diff --git a/strum_tests/tests/from_str.rs b/strum_tests/tests/from_str.rs
index 31456e1..ff4ffeb 100644
--- a/strum_tests/tests/from_str.rs
+++ b/strum_tests/tests/from_str.rs
@@ -232,8 +232,8 @@ fn color_default_with_white() {
 
 #[derive(Debug, EnumString)]
 #[strum(
-    parse_err_fn = some_enum_not_found_err,
-    parse_err_ty = CaseCustomParseErrorNotFoundError
+    parse_err_fn = "some_enum_not_found_err",
+    parse_err_ty = "CaseCustomParseErrorNotFoundError"
 )]
 enum CaseCustomParseErrorEnum {
     #[strum(serialize = "red")]
Repository: Peternator7/strum
Pull request #412 (2025-02-08 19:58:34)

Remove gnu toolchains from appveyor
They always fail, and this crate doesn't really do anything OS/toolchain dependent so it's not likely to catch anything anyway.


Patch:
diff --git a/appveyor.yml b/appveyor.yml
index 8b53fc6..6972e34 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -64,35 +64,6 @@ environment:
       target: i686-pc-windows-msvc
       #cargoflags: --features "unstable"
 
-### GNU Toolchains ###
-
-  # MSRC 64-bit GNU
-    - channel: 1.66.1
-      target: x86_64-pc-windows-gnu
-  # MSRC 32-bit GNU
-    - channel: 1.66.1
-      target: i686-pc-windows-gnu
-  # Stable 64-bit GNU
-    - channel: stable
-      target: x86_64-pc-windows-gnu
-  # Stable 32-bit GNU
-    - channel: stable
-      target: i686-pc-windows-gnu
-  # Beta 64-bit GNU
-    - channel: beta
-      target: x86_64-pc-windows-gnu
-  # Beta 32-bit GNU
-    - channel: beta
-      target: i686-pc-windows-gnu
-  # Nightly 64-bit GNU
-    - channel: nightly
-      target: x86_64-pc-windows-gnu
-      #cargoflags: --features "unstable"
-  # Nightly 32-bit GNU
-    - channel: nightly
-      target: i686-pc-windows-gnu
-      #cargoflags: --features "unstable"
-
 ### Allowed failures ###
 
 # See Appveyor documentation for specific details. In short, place any channel or targets you wish
diff --git a/strum_macros/src/helpers/metadata.rs b/strum_macros/src/helpers/metadata.rs
index 9863d67..4c333e4 100644
--- a/strum_macros/src/helpers/metadata.rs
+++ b/strum_macros/src/helpers/metadata.rs
@@ -95,12 +95,16 @@ impl Parse for EnumMeta {
         } else if lookahead.peek(kw::parse_err_ty) {
             let kw = input.parse::<kw::parse_err_ty>()?;
             input.parse::<Token![=]>()?;
-            let path: Path = input.parse()?;
+            let path_str: LitStr = input.parse()?;
+            let path_tokens = parse_str(&path_str.value())?;
+            let path = parse2(path_tokens)?;
             Ok(EnumMeta::ParseErrTy { kw, path })
         } else if lookahead.peek(kw::parse_err_fn) {
             let kw = input.parse::<kw::parse_err_fn>()?;
             input.parse::<Token![=]>()?;
-            let path: Path = input.parse()?;
+            let path_str: LitStr = input.parse()?;
+            let path_tokens = parse_str(&path_str.value())?;
+            let path = parse2(path_tokens)?;
             Ok(EnumMeta::ParseErrFn { kw, path })
         } else if lookahead.peek(kw::const_into_str) {
             Ok(EnumMeta::ConstIntoStr(input.parse()?))


Test patch:
diff --git a/strum_tests/tests/from_str.rs b/strum_tests/tests/from_str.rs
index 31456e1..ff4ffeb 100644
--- a/strum_tests/tests/from_str.rs
+++ b/strum_tests/tests/from_str.rs
@@ -232,8 +232,8 @@ fn color_default_with_white() {
 
 #[derive(Debug, EnumString)]
 #[strum(
-    parse_err_fn = some_enum_not_found_err,
-    parse_err_ty = CaseCustomParseErrorNotFoundError
+    parse_err_fn = "some_enum_not_found_err",
+    parse_err_ty = "CaseCustomParseErrorNotFoundError"
 )]
 enum CaseCustomParseErrorEnum {
     #[strum(serialize = "red")]
Repository: prettier/plugin-php
Pull request #158 (2018-03-06 09:54:55)

fix: indent in long `switch` test
PSR-12: https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#52-switch-case

evilebottnawi: Also i think we should open issue about option for PSR compatibility:
```php
if (
    $var1 && 
    $var2
)
```
vs
```php
if (
    $var1 
    && $var2
)
```
czosel: >  Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both.

That means we're compatible right now, aren't we?
evilebottnawi: @czosel right now no, but in near future we will :smile: 

Patch:
diff --git a/src/printer.js b/src/printer.js
index 657dc77..8af10cf 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1040,8 +1040,7 @@ function printStatement(path, options, print) {
         group(
           concat([
             "switch (",
-            softline,
-            path.call(print, "test"),
+            indent(concat([softline, path.call(print, "test")])),
             softline,
             concat([")", node.shortForm ? ":" : " {"])
           ])


Test patch:
diff --git a/tests/switch/__snapshots__/jsfmt.spec.js.snap b/tests/switch/__snapshots__/jsfmt.spec.js.snap
index 077c2ce..3420457 100644
--- a/tests/switch/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/switch/__snapshots__/jsfmt.spec.js.snap
@@ -51,6 +51,10 @@ switch ($expr) {
         echo 'Default case';
         break;
 }
+
+switch ($longLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable) {}
+
+switch ($longLongLongLongLongLongLongVariable && $longLongLongLongLongLongLongVariable) {}
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 switch (2) {
@@ -103,4 +107,15 @@ switch ($expr) {
         break;
 }
 
+switch (
+    $longLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable
+) {
+}
+
+switch (
+    $longLongLongLongLongLongLongVariable &&
+    $longLongLongLongLongLongLongVariable
+) {
+}
+
 `;
diff --git a/tests/switch/switch.php b/tests/switch/switch.php
index 4f060bb..611f65b 100644
--- a/tests/switch/switch.php
+++ b/tests/switch/switch.php
@@ -48,3 +48,7 @@ switch ($expr) {
         echo 'Default case';
         break;
 }
+
+switch ($longLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongVariable) {}
+
+switch ($longLongLongLongLongLongLongVariable && $longLongLongLongLongLongLongVariable) {}
Repository: prettier/plugin-php
Pull request #180 (2018-03-08 16:32:22)

fix: string escape for fwd slash
#176 

mgrip: @evilebottnawi ignoring the parser issue I think this should be good now!

Patch:
diff --git a/src/printer.js b/src/printer.js
index ba8d534..ffdb8d0 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -479,11 +479,7 @@ function printExpression(path, options, print) {
         // use setting from options. need to figure out how this works w/ complex strings and interpolation
         // also need to figure out splitting long strings
         const quote = node.isDoubleQuote ? '"' : "'";
-        return makeString(
-          node.isDoubleQuote ? util.stringEscape(node.value) : node.value,
-          quote,
-          false
-        );
+        return makeString(util.stringEscape(node.value), quote, false);
       }
       case "number":
         return util.printNumber(node.value);
diff --git a/src/util.js b/src/util.js
index a601d04..f5d523a 100644
--- a/src/util.js
+++ b/src/util.js
@@ -34,7 +34,7 @@ function stringEscape(str) {
         return "\\e";
       case "\\": {
         const nextCharacter = str[index + 1];
-        return nextCharacter && !/[ux0-7]/.test(nextCharacter) ? "\\\\" : "\\";
+        return !nextCharacter || !/[ux0-7]/.test(nextCharacter) ? "\\\\" : "\\";
       }
     }
   });


Test patch:
diff --git a/tests/string/__snapshots__/jsfmt.spec.js.snap b/tests/string/__snapshots__/jsfmt.spec.js.snap
index f762ba0..5c1770f 100644
--- a/tests/string/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/string/__snapshots__/jsfmt.spec.js.snap
@@ -57,6 +57,8 @@ $string = "This is the value of the var named by the return value of getName():
 // $string = "This is the value of the var named by the return value of \\$object->getName(): {\${$object->getName()}}";
 $string = "I'd like an {\${beers::softdrink}}\\n";
 $string = "I'd like an {\${beers::$ale}}\\n";
+$test = "\\\\";
+$test = '\\\\';
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 $string = 'this is a simple string';
@@ -64,8 +66,8 @@ $string = 'this is a simple string';
 // strings this way as it is
 // okay to do';
 $string = 'Arnold once said: "I\\'ll be back"';
-$string = 'You deleted C:\\*.*?';
-$string = 'You deleted C:\\*.*?';
+$string = 'You deleted C:\\\\*.*?';
+$string = 'You deleted C:\\\\*.*?';
 // $string = 'This will not expand: \\n a newline';
 $string = 'Variables do not $expand $either';
 $string = 'qwe{$a}rty';
@@ -120,5 +122,7 @@ $string = "I'd like an \${beers::softdrink}
 ";
 $string = "I'd like an \${beers::$ale}
 ";
+$test = "\\\\";
+$test = '\\\\';
 
 `;
diff --git a/tests/string/string.php b/tests/string/string.php
index 942f0df..7c38da8 100644
--- a/tests/string/string.php
+++ b/tests/string/string.php
@@ -54,3 +54,5 @@ $string = "This is the value of the var named by the return value of getName():
 // $string = "This is the value of the var named by the return value of \$object->getName(): {${$object->getName()}}";
 $string = "I'd like an {${beers::softdrink}}\n";
 $string = "I'd like an {${beers::$ale}}\n";
+$test = "\\";
+$test = '\\';
Repository: prettier/plugin-php
Pull request #202 (2018-03-12 09:43:27)

fix: don't loose type of `useitem`
Bug :smile: 


Patch:
diff --git a/src/printer.js b/src/printer.js
index 970a5a9..f9d8c61 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1185,7 +1185,11 @@ function printStatement(path, options, print) {
         ])
       );
     case "useitem":
-      return node.alias ? concat([node.name, " as ", node.alias]) : node.name;
+      return concat([
+        node.type ? concat([node.type, " "]) : "",
+        node.name,
+        node.alias ? concat([" as ", node.alias]) : ""
+      ]);
     case "closure":
       return concat([
         "function ",


Test patch:
diff --git a/tests/use/__snapshots__/jsfmt.spec.js.snap b/tests/use/__snapshots__/jsfmt.spec.js.snap
index 2933a35..118155e 100644
--- a/tests/use/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/use/__snapshots__/jsfmt.spec.js.snap
@@ -20,6 +20,16 @@ use Vendor\\Package\\SomeNamespace\\{
     SubnamespaceTwo\\ClassY,
     ClassZ
 };
+use Mizo\\Web\\{
+    Php\\WebSite,
+    Php\\KeyWord,
+    Php\\UnicodePrint,
+    JS\\JavaScript,
+    function JS\\printTotal,
+    function JS\\printList,
+    const JS\\BUAIKUM,
+    const JS\\MAUTAM
+};
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 <?php
 namespace foo;
@@ -41,6 +51,16 @@ use Vendor\\Package\\SomeNamespace\\{
     SubnamespaceTwo\\ClassY,
     ClassZ
 };
+use Mizo\\Web\\{
+    Php\\WebSite,
+    Php\\KeyWord,
+    Php\\UnicodePrint,
+    JS\\JavaScript,
+    function JS\\printTotal,
+    function JS\\printList,
+    const JS\\BUAIKUM,
+    const JS\\MAUTAM
+};
 
 `;
 
diff --git a/tests/use/use.php b/tests/use/use.php
index 7256dfc..1eaf6c5 100644
--- a/tests/use/use.php
+++ b/tests/use/use.php
@@ -17,3 +17,13 @@ use Vendor\Package\SomeNamespace\{
     SubnamespaceTwo\ClassY,
     ClassZ
 };
+use Mizo\Web\{
+    Php\WebSite,
+    Php\KeyWord,
+    Php\UnicodePrint,
+    JS\JavaScript,
+    function JS\printTotal,
+    function JS\printList,
+    const JS\BUAIKUM,
+    const JS\MAUTAM
+};
Repository: prettier/plugin-php
Pull request #339 (2018-04-06 12:52:00)

fix: output comments in `print` node
Ugly, let's fix it in other PR

evilebottnawi: Merge as is, just couple of lines and tests. Feel free to feedback :+1: 

Patch:
diff --git a/src/index.js b/src/index.js
index 83536e5..aea91ff 100644
--- a/src/index.js
+++ b/src/index.js
@@ -158,6 +158,10 @@ const printers = {
         {
           kinds: ["global"],
           children: { listNodes: ["items"], nodes: [] }
+        },
+        {
+          kinds: ["print"],
+          children: { listNodes: [], nodes: ["arguments"] }
         }
       ];
       const children = nodeMap.reduce((currentChildren, map) => {


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 1d80d7e..c4a6530 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -895,6 +895,25 @@ static /* Comment */
 
 `;
 
+exports[`print.php 1`] = `
+<?php
+
+print // Comment
+    $foo
+    /* Comment */
+    ;
+
+print /* Comment */ $foo /* Comment */;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+print // Comment
+$foo;
+/* Comment */
+print /* Comment */
+$foo; /* Comment */
+
+`;
+
 exports[`switch.php 1`] = `
 <?php
 // Comment
diff --git a/tests/comments/print.php b/tests/comments/print.php
new file mode 100644
index 0000000..303209a
--- /dev/null
+++ b/tests/comments/print.php
@@ -0,0 +1,8 @@
+<?php
+
+print // Comment
+    $foo
+    /* Comment */
+    ;
+
+print /* Comment */ $foo /* Comment */;
Repository: prettier/plugin-php
Pull request #342 (2018-04-06 13:48:21)

fix: output comments in `eval` node


Patch:
diff --git a/src/index.js b/src/index.js
index c53a01c..e3b95f5 100644
--- a/src/index.js
+++ b/src/index.js
@@ -162,6 +162,10 @@ const printers = {
         {
           kinds: ["print"],
           children: { listNodes: [], nodes: ["arguments"] }
+        },
+        {
+          kinds: ["eval"],
+          children: { listNodes: [], nodes: ["source"] }
         }
       ];
       const children = nodeMap.reduce((currentChildren, map) => {


Test patch:
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index 77e6451..96dbf43 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -663,6 +663,24 @@ if (
 
 `;
 
+exports[`eval.php 1`] = `
+<?php
+
+eval(
+    /* Comment */
+    "echo 'test';"
+    /* Comment */
+);
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+<?php
+eval(
+    /* Comment */
+    "echo 'test';"
+    /* Comment */
+);
+
+`;
+
 exports[`for.php 1`] = `
 <?php
 for // Comment
diff --git a/tests/comments/eval.php b/tests/comments/eval.php
new file mode 100644
index 0000000..1dfc9d4
--- /dev/null
+++ b/tests/comments/eval.php
@@ -0,0 +1,7 @@
+<?php
+
+eval(
+    /* Comment */
+    "echo 'test';"
+    /* Comment */
+);