php-src/ext/tokenizer/tests/PhpToken_constructor.phpt
Nikita Popov 5a09b9fb0f Add PhpToken class
RFC: https://wiki.php.net/rfc/token_as_object

Relative to the RFC, this also adds a __toString() method,
as discussed on list.

Closes GH-5176.
2020-03-26 11:09:18 +01:00

46 lines
741 B
PHP

--TEST--
PhpToken constructor
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
--FILE--
<?php
$token = new PhpToken(300, 'function');
var_dump($token);
$token = new PhpToken(300, 'function', 10);
var_dump($token);
$token = new PhpToken(300, 'function', 10, 100);
var_dump($token);
?>
--EXPECT--
object(PhpToken)#1 (4) {
["id"]=>
int(300)
["text"]=>
string(8) "function"
["line"]=>
int(-1)
["pos"]=>
int(-1)
}
object(PhpToken)#2 (4) {
["id"]=>
int(300)
["text"]=>
string(8) "function"
["line"]=>
int(10)
["pos"]=>
int(-1)
}
object(PhpToken)#1 (4) {
["id"]=>
int(300)
["text"]=>
string(8) "function"
["line"]=>
int(10)
["pos"]=>
int(100)
}