From eab4714c29873ff842552693a07a55b26f8e97c9 Mon Sep 17 00:00:00 2001 From: Emil Hesslow Date: Wed, 25 Sep 2019 08:17:23 -0700 Subject: [PATCH] Strip property comments in prod Summary: - We missed using makeDocComment on property comments so they were always included even in prod repo builds Reviewed By: alexeyt Differential Revision: D17561495 fbshipit-source-id: 603010c26472497c175118541ba0380d4762a212 --- hphp/runtime/vm/as.cpp | 2 +- .../slow/reflection/getDocCommentStripping.php | 28 ++++++++++++++++++++++ .../reflection/getDocCommentStripping.php.expect | 9 +++++++ .../getDocCommentStripping.php.expect-repo | 3 +++ .../getDocCommentStripping.php.hphp_opts | 1 + 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 hphp/test/slow/reflection/getDocCommentStripping.php create mode 100644 hphp/test/slow/reflection/getDocCommentStripping.php.expect create mode 100644 hphp/test/slow/reflection/getDocCommentStripping.php.expect-repo create mode 100644 hphp/test/slow/reflection/getDocCommentStripping.php.hphp_opts diff --git a/hphp/runtime/vm/as.cpp b/hphp/runtime/vm/as.cpp index 537e06ba82c..f2b9cfe9463 100644 --- a/hphp/runtime/vm/as.cpp +++ b/hphp/runtime/vm/as.cpp @@ -2760,7 +2760,7 @@ void parse_prop_or_field_impl(AsmState& as, AttrValidator validate, Adder add) { Attr attrs = parse_attribute_list(as, AttrContext::Prop, &userAttributes); validate(attrs); - auto const heredoc = makeStaticString(parse_maybe_long_string(as)); + auto const heredoc = makeDocComment(parse_maybe_long_string(as)); const StringData* userTy; TypeConstraint typeConstraint; diff --git a/hphp/test/slow/reflection/getDocCommentStripping.php b/hphp/test/slow/reflection/getDocCommentStripping.php new file mode 100644 index 00000000000..f01ed004b69 --- /dev/null +++ b/hphp/test/slow/reflection/getDocCommentStripping.php @@ -0,0 +1,28 @@ +> +function main(): void { + $r = new ReflectionClass(A::class); + var_dump($r->getDocComment()); + var_dump($r->getProperty('a')->getDocComment()); + var_dump($r->getMethod('a')->getDocComment()); +} diff --git a/hphp/test/slow/reflection/getDocCommentStripping.php.expect b/hphp/test/slow/reflection/getDocCommentStripping.php.expect new file mode 100644 index 00000000000..7ed668108b0 --- /dev/null +++ b/hphp/test/slow/reflection/getDocCommentStripping.php.expect @@ -0,0 +1,9 @@ +string(29) "/** + * Info about class A + */" +string(37) "/** + * Info about property $a + */" +string(36) "/** + * Info about function a + */" diff --git a/hphp/test/slow/reflection/getDocCommentStripping.php.expect-repo b/hphp/test/slow/reflection/getDocCommentStripping.php.expect-repo new file mode 100644 index 00000000000..3ac9cfeafcd --- /dev/null +++ b/hphp/test/slow/reflection/getDocCommentStripping.php.expect-repo @@ -0,0 +1,3 @@ +bool(false) +bool(false) +bool(false) diff --git a/hphp/test/slow/reflection/getDocCommentStripping.php.hphp_opts b/hphp/test/slow/reflection/getDocCommentStripping.php.hphp_opts new file mode 100644 index 00000000000..9a521c804b5 --- /dev/null +++ b/hphp/test/slow/reflection/getDocCommentStripping.php.hphp_opts @@ -0,0 +1 @@ +-vRuntime.Eval.GenerateDocComments=false -- 2.11.4.GIT