forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
__Deprecated('...') user attribute results in runtime warning
Summary: Depending on whether the function in question is in systemlib, E_DEPRECATED or E_USER_DEPRECATED is used. Subtleties: * For `__Memoize` functions, each call to the function results in the warning. * For `__Native` functions, the function body is changed to emit the warning and then emit `NativeImpl` (ereg is marked __Deprecated to test this). * For trait methods, the name of the using class appears in the warning, rather than that of the trait: if suboptimal, this is at least consistent. Reviewed By: @jano Differential Revision: D1853244
- Loading branch information
Showing
10 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?hh | ||
|
||
function err_handler($errno, $errstr, $file, $line) { | ||
if ($errno === E_DEPRECATED) { | ||
echo 'E_DEPRECATED', ': ', $errstr, ' for ', $file, ':', $line, "\n"; | ||
return true; | ||
} else if ($errno === E_USER_DEPRECATED) { | ||
echo 'E_USER_DEPRECATED', ': ', $errstr, ' for ', $file, ':', $line, "\n"; | ||
return true; | ||
} | ||
throw new Exception($errstr); | ||
} | ||
error_reporting(-1); | ||
set_error_handler('err_handler'); | ||
|
||
trait Tr { | ||
<<__Deprecated('message')>> | ||
public function meth() { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public static function stMeth() { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public static function __callStatic($name, $args) { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public function __call($name, $args) { echo __METHOD__, "\n"; } | ||
} | ||
|
||
class C { | ||
<<__Deprecated('message')>> | ||
public function meth() { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public static function stMeth() { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public static function __callStatic($name, $args) { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
public function __call($name, $args) { echo __METHOD__, "\n"; } | ||
} | ||
|
||
class C_T { | ||
use Tr; | ||
} | ||
|
||
<<__Deprecated('message')>> | ||
function f() { echo __METHOD__, "\n"; } | ||
<<__Deprecated('message')>> | ||
function f_gen() { yield null; echo __METHOD__, "\n"; } | ||
<<__Memoize, __Deprecated('message')>> | ||
function fMem() { | ||
echo __METHOD__, "\n"; | ||
} | ||
|
||
function basic() { | ||
echo '= ', __FUNCTION__, " =", "\n"; | ||
f(); | ||
C::stMeth(); | ||
C::viaCallStatic(); | ||
$inst = new C(); | ||
$inst->meth(); | ||
$inst->viaCall(); | ||
f_gen(); | ||
echo "\n"; | ||
} | ||
|
||
function memoized() { | ||
echo '= ', __FUNCTION__, " =", "\n"; | ||
fMem(); | ||
fMem(); | ||
echo "\n"; | ||
} | ||
|
||
function builtin() { | ||
echo '= ', __FUNCTION__, " =", "\n"; | ||
ereg('foobar', 'foo'); | ||
echo "\n"; | ||
} | ||
|
||
function via_trait() { | ||
echo '= ', __FUNCTION__, " =", "\n"; | ||
// f(); | ||
C_T::stMeth(); | ||
C_T::viaCallStatic(); | ||
$inst = new C_T(); | ||
$inst->meth(); | ||
$inst->viaCall(); | ||
echo "\n"; | ||
} | ||
|
||
function main() { | ||
basic(); | ||
via_trait(); | ||
memoized(); | ||
builtin(); | ||
echo 'Done', "\n"; | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
= basic = | ||
E_USER_DEPRECATED: f: message for %s/lang/deprecated.php:43 | ||
f | ||
E_USER_DEPRECATED: C::stMeth: message for %s/lang/deprecated.php:31 | ||
C::stMeth | ||
E_USER_DEPRECATED: C::__callStatic: message for %s/lang/deprecated.php:33 | ||
C::__callStatic | ||
E_USER_DEPRECATED: C::meth: message for %s/lang/deprecated.php:29 | ||
C::meth | ||
E_USER_DEPRECATED: C::__call: message for %s/lang/deprecated.php:35 | ||
C::__call | ||
E_USER_DEPRECATED: f_gen: message for %s/lang/deprecated.php:45 | ||
|
||
= via_trait = | ||
E_USER_DEPRECATED: C_T::stMeth: message for %s/lang/deprecated.php:20 | ||
Tr::stMeth | ||
E_USER_DEPRECATED: C_T::__callStatic: message for %s/lang/deprecated.php:22 | ||
Tr::__callStatic | ||
E_USER_DEPRECATED: C_T::meth: message for %s/lang/deprecated.php:18 | ||
Tr::meth | ||
E_USER_DEPRECATED: C_T::__call: message for %s/lang/deprecated.php:24 | ||
Tr::__call | ||
|
||
= memoized = | ||
E_USER_DEPRECATED: fMem: message for %s/lang/deprecated.php:49 | ||
fMem | ||
E_USER_DEPRECATED: fMem: message for %s/lang/deprecated.php:49 | ||
fMem | ||
|
||
= builtin = | ||
E_DEPRECATED: ereg: As of PHP 5.3.0, preg_match is suggested instead for %s/lang/deprecated.php:72 | ||
|
||
Done |
File renamed without changes.
File renamed without changes.
File renamed without changes.