From c5b40ad32226ea394f7d1929fa7d9e1f570d858b Mon Sep 17 00:00:00 2001 From: Drew Paroski Date: Wed, 26 Mar 2014 04:46:21 -0700 Subject: [PATCH] Enable hard enforcement of return typehints by default Reviewed By: @elgenie Differential Revision: D1238170 --- hphp/runtime/base/runtime-option.h | 2 +- hphp/runtime/ext/icu/ext_icu_date_fmt.php | 3 +- hphp/runtime/ext/icu/ext_icu_locale.php | 6 +- hphp/runtime/ext/icu/ext_icu_num_fmt.php | 10 +-- hphp/runtime/ext/icu/ext_icu_uconverter.php | 2 +- hphp/runtime/ext/mysql/ext_mysqli.php | 2 +- .../{hh_return_type.php => hh_return_type_0.php} | 0 hphp/test/quick/hh_return_type_0.php.expect | 92 ++++++++++++++++++++++ hphp/test/quick/hh_return_type_0.php.opts | 1 + .../{hh_return_type.php => hh_return_type_1.php} | 0 ...type.php.expect => hh_return_type_1.php.expect} | 0 ...urn_type.php.opts => hh_return_type_1.php.opts} | 0 hphp/test/quick/hh_type_args.php | 14 ---- hphp/test/quick/hh_type_args.php.expect | 1 - 14 files changed, 104 insertions(+), 29 deletions(-) copy hphp/test/quick/{hh_return_type.php => hh_return_type_0.php} (100%) create mode 100644 hphp/test/quick/hh_return_type_0.php.expect create mode 100644 hphp/test/quick/hh_return_type_0.php.opts rename hphp/test/quick/{hh_return_type.php => hh_return_type_1.php} (100%) rename hphp/test/quick/{hh_return_type.php.expect => hh_return_type_1.php.expect} (100%) rename hphp/test/quick/{hh_return_type.php.opts => hh_return_type_1.php.opts} (100%) delete mode 100644 hphp/test/quick/hh_type_args.php delete mode 100644 hphp/test/quick/hh_type_args.php.expect diff --git a/hphp/runtime/base/runtime-option.h b/hphp/runtime/base/runtime-option.h index e0c8ecd22b5..14aab0555d6 100644 --- a/hphp/runtime/base/runtime-option.h +++ b/hphp/runtime/base/runtime-option.h @@ -384,7 +384,7 @@ public: 2 - raises E_RECOVERABLE_ERROR if regular type hint fails, raises E_WARNING if soft type hint fails; note that in repo mode the error handler is not allowed to resume on recoverable errors */ \ - F(int32_t, CheckReturnTypeHints, 0) \ + F(int32_t, CheckReturnTypeHints, 2) \ F(bool, JitNoGdb, true) \ F(bool, SpinOnCrash, false) \ F(uint32_t, DumpRingBufferOnCrash, 0) \ diff --git a/hphp/runtime/ext/icu/ext_icu_date_fmt.php b/hphp/runtime/ext/icu/ext_icu_date_fmt.php index 69c8e03ca34..221bdf21dd5 100644 --- a/hphp/runtime/ext/icu/ext_icu_date_fmt.php +++ b/hphp/runtime/ext/icu/ext_icu_date_fmt.php @@ -423,8 +423,7 @@ function datefmt_get_error_message(IntlDateFormatter $fmt): string { * * @return string - the locale of this formatter or 'false' if error */ -function datefmt_get_locale(IntlDateFormatter $fmt, - ?int $which = null): string { +function datefmt_get_locale(IntlDateFormatter $fmt, ?int $which = null) { return $fmt->getLocale($which); } diff --git a/hphp/runtime/ext/icu/ext_icu_locale.php b/hphp/runtime/ext/icu/ext_icu_locale.php index 524a905ec04..ddfe036395d 100644 --- a/hphp/runtime/ext/icu/ext_icu_locale.php +++ b/hphp/runtime/ext/icu/ext_icu_locale.php @@ -320,7 +320,7 @@ function locale_canonicalize(string $locale): mixed { * * @return string - The corresponding locale identifier. */ -function locale_compose(array $subtags): string { +function locale_compose(array $subtags) { return Locale::composeLocale($subtags); } @@ -348,7 +348,7 @@ function locale_filter_matches($langtag, * @return array - The array containing the list of all variants subtag * for the locale or NULL if not present */ -function locale_get_all_variants(string $locale): array { +function locale_get_all_variants(string $locale) { return Locale::getAllVariants($locale); } @@ -447,7 +447,7 @@ function locale_get_display_variant(string $locale, * @return array - Associative array containing the keyword-value pairs * for this locale */ -function locale_get_keywords(string $locale): array { +function locale_get_keywords(string $locale) { return Locale::getKeywords($locale); } diff --git a/hphp/runtime/ext/icu/ext_icu_num_fmt.php b/hphp/runtime/ext/icu/ext_icu_num_fmt.php index a626cb5a349..742a18e76f0 100644 --- a/hphp/runtime/ext/icu/ext_icu_num_fmt.php +++ b/hphp/runtime/ext/icu/ext_icu_num_fmt.php @@ -289,7 +289,7 @@ function numfmt_format_currency(NumberFormatter $fmt, * FALSE on error. */ function numfmt_format(NumberFormatter $fmt, - $value, $type = NumberFormatter::TYPE_DEFAULT): string { + $value, $type = NumberFormatter::TYPE_DEFAULT) { return $fmt->format($value, $type); } @@ -351,7 +351,7 @@ function numfmt_get_locale(NumberFormatter $fmt, * @return string - Pattern string that is used by the formatter, or * FALSE if an error happens. */ -function numfmt_get_pattern(NumberFormatter $fmt): string { +function numfmt_get_pattern(NumberFormatter $fmt) { return $fmt->getPattern(); } @@ -364,8 +364,7 @@ function numfmt_get_pattern(NumberFormatter $fmt): string { * * @return string - The symbol string or FALSE on error. */ -function numfmt_get_symbol(NumberFormatter $fmt, - $attr): string { +function numfmt_get_symbol(NumberFormatter $fmt, $attr) { return $fmt->getSymbol($attr); } @@ -379,8 +378,7 @@ function numfmt_get_symbol(NumberFormatter $fmt, * @return string - Return attribute value on success, or FALSE on * error. */ -function numfmt_get_text_attribute(NumberFormatter $fmt, - $attr): string { +function numfmt_get_text_attribute(NumberFormatter $fmt, $attr) { return $fmt->getTextAttribute($attr); } diff --git a/hphp/runtime/ext/icu/ext_icu_uconverter.php b/hphp/runtime/ext/icu/ext_icu_uconverter.php index ed90fd79175..e7ce61dfc18 100644 --- a/hphp/runtime/ext/icu/ext_icu_uconverter.php +++ b/hphp/runtime/ext/icu/ext_icu_uconverter.php @@ -269,7 +269,7 @@ class UConverter { public static function transcode(string $str, string $toEncoding, string $fromEncoding, - array $options = null): string { + array $options = null): ?string { $cnv = new UConverter($toEncoding, $fromEncoding); if ((isset($options['from_subst']) && !$cnv->setSourceSubstChars($options['from_subst'])) || diff --git a/hphp/runtime/ext/mysql/ext_mysqli.php b/hphp/runtime/ext/mysql/ext_mysqli.php index fe67a0bf340..1f2c647fe67 100644 --- a/hphp/runtime/ext/mysql/ext_mysqli.php +++ b/hphp/runtime/ext/mysql/ext_mysqli.php @@ -752,7 +752,7 @@ class mysqli { * * @return bool - */ - public function set_charset(string $charset): bool { + public function set_charset(string $charset) { $conn = $this->hh_get_connection(2); if (!$conn) { return null; diff --git a/hphp/test/quick/hh_return_type.php b/hphp/test/quick/hh_return_type_0.php similarity index 100% copy from hphp/test/quick/hh_return_type.php copy to hphp/test/quick/hh_return_type_0.php diff --git a/hphp/test/quick/hh_return_type_0.php.expect b/hphp/test/quick/hh_return_type_0.php.expect new file mode 100644 index 00000000000..d7710ff5a13 --- /dev/null +++ b/hphp/test/quick/hh_return_type_0.php.expect @@ -0,0 +1,92 @@ +calling f1 + +calling f2 + +calling f2_soft + +calling f3 + +calling f3_soft + +calling f4 + +calling f4_soft + +calling f5 + +calling f5_soft + +calling f6 + +calling f6_soft + +calling f7 + +calling f7_soft + +calling f8 + +calling f8_soft + +calling f9 + +calling f9_soft + +calling f10 + +calling f10_soft + +calling f11 + +calling f11_soft + +calling f12 + +calling f12_soft + +calling f13 + +calling f13_soft + +calling f14 + +calling f14_soft + +calling f15 + +calling f15_soft + +calling f16 + +calling f16_soft + +calling f17 + +calling f17_soft + +calling f18 + +calling f18_soft + +calling f19 + +calling f19_soft + +calling f20 + +calling f20_soft + +calling f21 + +calling f22 + +calling f22_soft + +calling f23 + +calling f23_soft + +calling f24 + +calling f24_soft +Done diff --git a/hphp/test/quick/hh_return_type_0.php.opts b/hphp/test/quick/hh_return_type_0.php.opts new file mode 100644 index 00000000000..8ea118a9744 --- /dev/null +++ b/hphp/test/quick/hh_return_type_0.php.opts @@ -0,0 +1 @@ +-vEval.CheckReturnTypeHints=0 diff --git a/hphp/test/quick/hh_return_type.php b/hphp/test/quick/hh_return_type_1.php similarity index 100% rename from hphp/test/quick/hh_return_type.php rename to hphp/test/quick/hh_return_type_1.php diff --git a/hphp/test/quick/hh_return_type.php.expect b/hphp/test/quick/hh_return_type_1.php.expect similarity index 100% rename from hphp/test/quick/hh_return_type.php.expect rename to hphp/test/quick/hh_return_type_1.php.expect diff --git a/hphp/test/quick/hh_return_type.php.opts b/hphp/test/quick/hh_return_type_1.php.opts similarity index 100% rename from hphp/test/quick/hh_return_type.php.opts rename to hphp/test/quick/hh_return_type_1.php.opts diff --git a/hphp/test/quick/hh_type_args.php b/hphp/test/quick/hh_type_args.php deleted file mode 100644 index a89f0c7f06e..00000000000 --- a/hphp/test/quick/hh_type_args.php +++ /dev/null @@ -1,14 +0,0 @@ -