]> granicus.if.org Git - php/commitdiff
Rename PhpToken::getAll() to PhpToken::tokenize()
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 9 Nov 2020 08:40:31 +0000 (09:40 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 9 Nov 2020 08:40:31 +0000 (09:40 +0100)
See https://externals.io/message/112189.
Fixes bug #80328.

NEWS
ext/tokenizer/tests/PhpToken_extension.phpt
ext/tokenizer/tests/PhpToken_extension_errors.phpt
ext/tokenizer/tests/PhpToken_methods.phpt
ext/tokenizer/tests/PhpToken_toString.phpt
ext/tokenizer/tests/PhpToken_tokenize.phpt [moved from ext/tokenizer/tests/PhpToken_getAll.phpt with 97% similarity]
ext/tokenizer/tests/bug77966.phpt
ext/tokenizer/tests/namespaced_names.phpt
ext/tokenizer/tokenizer.c
ext/tokenizer/tokenizer.stub.php
ext/tokenizer/tokenizer_arginfo.h

diff --git a/NEWS b/NEWS
index 95aa4618a7f63977155a3e13a1c5dc2224aed36d..9e7efeaf974437e5bed6797dfbd08be3ee754529 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,9 @@ PHP                                                                        NEWS
     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:
index ef1a4f12722cf9a6e5b8212ca5634c321be7e4ce..b41843c0604c02c3f76ad994d692729966b2bd84 100644 (file)
@@ -20,7 +20,7 @@ class MyPhpToken extends PhpToken {
     }
 }
 
-foreach (MyPhpToken::getAll($code) as $token) {
+foreach (MyPhpToken::tokenize($code) as $token) {
     echo $token->getLoweredText();
 
     if ($token->extra !== 123) {
index d2bee1bc8f440a671e2ae696a85fbbe49b772243..72164f398cb1b559f8195c169706ae86e9746338 100644 (file)
@@ -10,7 +10,7 @@ class MyPhpToken1 extends PhpToken {
 }
 
 try {
-    var_dump(MyPhpToken1::getAll("<?php foo"));
+    var_dump(MyPhpToken1::tokenize("<?php foo"));
 } catch (Error $e) {
     echo $e->getMessage(), "\n";
 }
@@ -19,7 +19,7 @@ abstract class MyPhpToken2 extends PhpToken {
 }
 
 try {
-    var_dump(MyPhpToken2::getAll("<?php foo"));
+    var_dump(MyPhpToken2::tokenize("<?php foo"));
 } catch (Error $e) {
     echo $e->getMessage(), "\n";
 }
index 570e880473720d21e47c3ad91ef5c299ffeeb57a..269fdf527776b54680397aa18ad93734d9c37e52 100644 (file)
@@ -15,7 +15,7 @@ function foo() {
 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");
index 17dbfa84a7c118d4d4ef7b0ddbb24c6d52d1b05a..f4b9e8b118674b5ad506302dd28c3184af4b0b18 100644 (file)
@@ -3,7 +3,7 @@ PhpToken implements __toString()
 --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);
similarity index 97%
rename from ext/tokenizer/tests/PhpToken_getAll.phpt
rename to ext/tokenizer/tests/PhpToken_tokenize.phpt
index 73980b3733d4533c9472204a5dda4294e9042929..3cf113d75e3732888a603b504917ac14b3a1feb2 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-PhpToken::getAll() method
+PhpToken::tokenize() method
 --SKIPIF--
 <?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
 --FILE--
@@ -11,8 +11,8 @@ function foo() {
     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--
index 142cc7c9aba6b4849701b0f9c3d350d78916b472..db2ed83738cf542c6363a71b28a8368d6df0e349 100644 (file)
@@ -12,7 +12,7 @@ class C {
 }
 CODE;
 
-$tokens = PhpToken::getAll($code, TOKEN_PARSE);
+$tokens = PhpToken::tokenize($code, TOKEN_PARSE);
 foreach ($tokens as $token) {
     echo "{$token->getTokenName()}: \"$token->text\"\n";
 }
index 34e947b3525e10ea7ce6d55a5a8e075d33f2c97e..651524b8e4ce5f8edd2f3ebb309aacefd9ea8724 100644 (file)
@@ -12,7 +12,7 @@ namespace\Foo
 Foo \ Bar
 CODE;
 
-foreach (PhpToken::getAll($code) as $token) {
+foreach (PhpToken::tokenize($code) as $token) {
     echo "{$token->getTokenName()}: \"$token->text\"\n";
 }
 
index d12b5edba8deda5773455eab3346d3a9afa3a19e..7567a270afc94f626f7fe821970eb8378457e62d 100644 (file)
@@ -92,7 +92,7 @@ static zend_string *php_token_get_text(zval *obj) {
 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;
index a3a4246a1af6a5d8a7fc3227c58de62cc361522b..c329ef49322a037285f0138ae5dc603000a02ca5 100644 (file)
@@ -9,7 +9,7 @@ function token_name(int $id): string {}
 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) {}
 
index 8bf694074e2e1725cfd269bc9e5d5a4fc784d585..01d37d406e0b8d777099c3754ce9f1785be5d5ee 100644 (file)
@@ -1,5 +1,5 @@
 /* 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)
@@ -10,7 +10,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_token_name, 0, 1, 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)
@@ -35,7 +35,7 @@ ZEND_END_ARG_INFO()
 
 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);
@@ -51,7 +51,7 @@ static const zend_function_entry ext_functions[] = {
 
 
 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)