See https://externals.io/message/112189.
Fixes bug #80328.
message). (Nikita)
. Fixed bug #80266 (parse_url silently drops port number 0). (cmb, Nikita)
+- Tokenizer:
+ . Fixed bug #80328 (PhpToken::getAll() confusing name). (Nikita)
+
29 Oct 2020, PHP 8.0.0RC3
- Core:
}
}
-foreach (MyPhpToken::getAll($code) as $token) {
+foreach (MyPhpToken::tokenize($code) as $token) {
echo $token->getLoweredText();
if ($token->extra !== 123) {
}
try {
- var_dump(MyPhpToken1::getAll("<?php foo"));
+ var_dump(MyPhpToken1::tokenize("<?php foo"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
}
try {
- var_dump(MyPhpToken2::getAll("<?php foo"));
+ var_dump(MyPhpToken2::tokenize("<?php foo"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
PHP;
// Token names and ignorability.
-$tokens = PhpToken::getAll($code);
+$tokens = PhpToken::tokenize($code);
foreach ($tokens as $i => $token) {
printf("[%2d] %-26s %s\n", $i, $token->getTokenName(),
$token->isIgnorable() ? "ignorable" : "meaningful");
--FILE--
<?php
-$tokens = PhpToken::getAll('<?php echo "Hello ". $what;');
+$tokens = PhpToken::tokenize('<?php echo "Hello ". $what;');
var_dump(implode($tokens));
var_dump($tokens[0] instanceof Stringable);
--TEST--
-PhpToken::getAll() method
+PhpToken::tokenize() method
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
--FILE--
echo "bar";
}
PHP;
-var_dump(PhpToken::getAll($code));
-var_dump(PhpToken::getAll($code, TOKEN_PARSE));
+var_dump(PhpToken::tokenize($code));
+var_dump(PhpToken::tokenize($code, TOKEN_PARSE));
?>
--EXPECTF--
}
CODE;
-$tokens = PhpToken::getAll($code, TOKEN_PARSE);
+$tokens = PhpToken::tokenize($code, TOKEN_PARSE);
foreach ($tokens as $token) {
echo "{$token->getTokenName()}: \"$token->text\"\n";
}
Foo \ Bar
CODE;
-foreach (PhpToken::getAll($code) as $token) {
+foreach (PhpToken::tokenize($code) as $token) {
echo "{$token->getTokenName()}: \"$token->text\"\n";
}
static zend_bool tokenize_common(
zval *return_value, zend_string *source, zend_long flags, zend_class_entry *token_class);
-PHP_METHOD(PhpToken, getAll)
+PHP_METHOD(PhpToken, tokenize)
{
zend_string *source;
zend_long flags = 0;
class PhpToken implements Stringable
{
/** @return static[] */
- public static function getAll(string $code, int $flags = 0): array {}
+ public static function tokenize(string $code, int $flags = 0): array {}
final public function __construct(int $id, string $text, int $line = -1, int $pos = -1) {}
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: ef39f4efec05a3ebc5cf56a6b26e01369f00d129 */
+ * Stub hash: a06da9ea0191ed78ee7af8f0d9eaccb17dfa4b20 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_token_get_all, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, code, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, id, IS_LONG, 0)
ZEND_END_ARG_INFO()
-#define arginfo_class_PhpToken_getAll arginfo_token_get_all
+#define arginfo_class_PhpToken_tokenize arginfo_token_get_all
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PhpToken___construct, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, id, IS_LONG, 0)
ZEND_FUNCTION(token_get_all);
ZEND_FUNCTION(token_name);
-ZEND_METHOD(PhpToken, getAll);
+ZEND_METHOD(PhpToken, tokenize);
ZEND_METHOD(PhpToken, __construct);
ZEND_METHOD(PhpToken, is);
ZEND_METHOD(PhpToken, isIgnorable);
static const zend_function_entry class_PhpToken_methods[] = {
- ZEND_ME(PhpToken, getAll, arginfo_class_PhpToken_getAll, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ ZEND_ME(PhpToken, tokenize, arginfo_class_PhpToken_tokenize, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_ME(PhpToken, __construct, arginfo_class_PhpToken___construct, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(PhpToken, is, arginfo_class_PhpToken_is, ZEND_ACC_PUBLIC)
ZEND_ME(PhpToken, isIgnorable, arginfo_class_PhpToken_isIgnorable, ZEND_ACC_PUBLIC)