How to use rewind method of token class

Best Atoum code snippet using token.rewind

Parser.php

Source:Parser.php Github

copy

Full Screen

...155 $start = $tokenList->getPosition() - 1;156 switch (strtoupper($first->value)) {157 case '(':158 // ({SELECT|TABLE|VALUES} ...) ...159 return $this->factory->getQueryParser()->parseQuery($tokenList->rewind($start));160 case Keyword::ALTER:161 $second = strtoupper($tokenList->expect(TokenType::KEYWORD)->value);162 switch ($second) {163 case Keyword::DATABASE:164 case Keyword::SCHEMA:165 // ALTER {DATABASE|SCHEMA}166 return $this->factory->getSchemaCommandsParser()->parseAlterSchema($tokenList->rewind($start));167 case Keyword::FUNCTION:168 // ALTER FUNCTION169 return $this->factory->getRoutineCommandsParser()->parseAlterFunction($tokenList->rewind($start));170 case Keyword::INSTANCE:171 // ALTER INSTANCE172 return $this->factory->getInstanceCommandParser()->parseAlterInstance($tokenList->rewind($start));173 case Keyword::LOGFILE:174 // ALTER LOGFILE GROUP175 return $this->factory->getLogfileGroupCommandsParser()->parseAlterLogfileGroup($tokenList->rewind($start));176 case Keyword::PROCEDURE:177 // ALTER PROCEDURE178 return $this->factory->getRoutineCommandsParser()->parseAlterProcedure($tokenList->rewind($start));179 case Keyword::RESOURCE:180 // ALTER RESOURCE GROUP181 return $this->factory->getResourceCommandsParser()->parseAlterResourceGroup($tokenList->rewind($start));182 case Keyword::SERVER:183 // ALTER SERVER184 return $this->factory->getServerCommandsParser()->parseAlterServer($tokenList->rewind($start));185 case Keyword::TABLE:186 case Keyword::ONLINE:187 // ALTER [ONLINE] TABLE188 return $this->factory->getTableCommandsParser()->parseAlterTable($tokenList->rewind($start));189 case Keyword::TABLESPACE:190 case Keyword::UNDO:191 // ALTER [UNDO] TABLESPACE192 return $this->factory->getTablespaceCommandsParser()->parseAlterTablespace($tokenList->rewind($start));193 case Keyword::USER:194 // ALTER USER195 return $this->factory->getUserCommandsParser()->parseAlterUser($tokenList->rewind($start));196 case Keyword::EVENT:197 // ALTER [DEFINER = { user | CURRENT_USER }] EVENT198 return $this->factory->getEventCommandsParser()->parseAlterEvent($tokenList->rewind($start));199 case Keyword::VIEW:200 case Keyword::ALGORITHM:201 case Keyword::SQL:202 // ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW203 return $this->factory->getViewCommandsParser()->parseAlterView($tokenList->rewind($start));204 default:205 if ($tokenList->seekKeyword(Keyword::EVENT, 8)) {206 // ALTER [DEFINER = { user | CURRENT_USER }] EVENT event_name207 return $this->factory->getEventCommandsParser()->parseAlterEvent($tokenList->rewind($start));208 } elseif ($tokenList->seekKeyword(Keyword::VIEW, 15)) {209 // ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW ...210 return $this->factory->getViewCommandsParser()->parseAlterView($tokenList->rewind($start));211 }212 $tokenList->missingAnyKeyword(213 Keyword::DATABASE, Keyword::SCHEMA, Keyword::FUNCTION, Keyword::INSTANCE, Keyword::LOGFILE,214 Keyword::SERVER, Keyword::TABLE, Keyword::TABLESPACE, Keyword::USER, Keyword::EVENT, Keyword::VIEW,215 Keyword::DEFINER, Keyword::ALGORITHM, Keyword::SQL216 );217 }218 case Keyword::ANALYZE:219 // ANALYZE220 return $this->factory->getTableMaintenanceCommandsParser()->parseAnalyzeTable($tokenList->rewind($start));221 case Keyword::BEGIN:222 // BEGIN223 return $this->factory->getTransactionCommandsParser()->parseStartTransaction($tokenList->rewind($start));224 case Keyword::BINLOG:225 // BINLOG226 return $this->factory->getBinlogCommandParser()->parseBinlog($tokenList->rewind($start));227 case Keyword::CACHE:228 // CACHE INDEX229 return $this->factory->getCacheCommandsParser()->parseCacheIndex($tokenList->rewind($start));230 case Keyword::CALL:231 // CALL232 return $this->factory->getCallCommandParser()->parseCall($tokenList->rewind($start));233 case Keyword::CHANGE:234 $second = $tokenList->expectAnyKeyword(Keyword::MASTER, Keyword::REPLICATION);235 if ($second === Keyword::MASTER) {236 // CHANGE MASTER TO237 return $this->factory->getReplicationCommandsParser()->parseChangeMasterTo($tokenList->rewind($start));238 } elseif ($second === Keyword::REPLICATION) {239 $third = $tokenList->expectAnyKeyword(Keyword::SOURCE, Keyword::FILTER);240 if ($third === Keyword::SOURCE) {241 // CHANGE REPLICATION SOURCE242 return $this->factory->getReplicationCommandsParser()->parseChangeReplicationSourceTo($tokenList->rewind($start));243 } elseif ($third === Keyword::FILTER) {244 // CHANGE REPLICATION FILTER245 return $this->factory->getReplicationCommandsParser()->parseChangeReplicationFilter($tokenList->rewind($start));246 }247 }248 case Keyword::CHECK:249 // CHECK TABLE250 return $this->factory->getTableMaintenanceCommandsParser()->parseCheckTable($tokenList->rewind($start));251 case Keyword::CHECKSUM:252 // CHECKSUM TABLE253 return $this->factory->getTableMaintenanceCommandsParser()->parseChecksumTable($tokenList->rewind($start));254 case Keyword::COMMIT:255 // COMMIT256 return $this->factory->getTransactionCommandsParser()->parseCommit($tokenList->rewind($start));257 case Keyword::CREATE:258 $second = $tokenList->expectKeyword();259 switch ($second) {260 case Keyword::DATABASE:261 case Keyword::SCHEMA:262 // CREATE {DATABASE | SCHEMA}263 return $this->factory->getSchemaCommandsParser()->parseCreateSchema($tokenList->rewind($start));264 case Keyword::LOGFILE:265 // CREATE LOGFILE GROUP266 return $this->factory->getLogfileGroupCommandsParser()->parseCreateLogfileGroup($tokenList->rewind($start));267 case Keyword::RESOURCE:268 // CREATE RESOURCE GROUP269 return $this->factory->getResourceCommandsParser()->parseCreateResourceGroup($tokenList->rewind($start));270 case Keyword::ROLE:271 // CREATE ROLE272 return $this->factory->getUserCommandsParser()->parseCreateRole($tokenList->rewind($start));273 case Keyword::SERVER:274 // CREATE SERVER275 return $this->factory->getServerCommandsParser()->parseCreateServer($tokenList->rewind($start));276 case Keyword::TABLESPACE:277 case Keyword::UNDO:278 // CREATE [UNDO] TABLESPACE279 return $this->factory->getTablespaceCommandsParser()->parseCreateTablespace($tokenList->rewind($start));280 case Keyword::USER:281 // CREATE USER282 return $this->factory->getUserCommandsParser()->parseCreateUser($tokenList->rewind($start));283 case Keyword::TEMPORARY:284 case Keyword::TABLE:285 // CREATE [TEMPORARY] TABLE286 return $this->factory->getTableCommandsParser()->parseCreateTable($tokenList->rewind($start));287 case Keyword::UNIQUE:288 case Keyword::FULLTEXT:289 case Keyword::INDEX:290 // CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX291 return $this->factory->getIndexCommandsParser()->parseCreateIndex($tokenList->rewind($start));292 case Keyword::SPATIAL:293 $third = $tokenList->expectAnyKeyword(Keyword::INDEX, Keyword::REFERENCE);294 if ($third === Keyword::INDEX) {295 // CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX296 return $this->factory->getIndexCommandsParser()->parseCreateIndex($tokenList->rewind($start));297 } else {298 // CREATE SPATIAL REFERENCE SYSTEM299 return $this->factory->getSpatialCommandsParser()->parseCreateSpatialReferenceSystem($tokenList->rewind($start));300 }301 }302 $tokenList->rewind(-1);303 if ($tokenList->hasKeywords(Keyword::OR, Keyword::REPLACE, Keyword::SPATIAL)) {304 // CREATE OR REPLACE SPATIAL REFERENCE SYSTEM305 return $this->factory->getSpatialCommandsParser()->parseCreateSpatialReferenceSystem($tokenList->rewind($start));306 }307 // deciding between CREATE FUNCTION and CREATE FUNCTION SONAME308 if ($tokenList->hasKeyword(Keyword::AGGREGATE)) {309 // CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL} SONAME310 return $this->factory->getCreateFunctionCommandParser()->parseCreateFunction($tokenList->rewind($start));311 }312 if ($tokenList->hasKeyword(Keyword::FUNCTION)) {313 if ($tokenList->hasKeyword(Keyword::IF)) {314 // CREATE ... FUNCTION [IF NOT EXISTS] sp_name ([func_parameter[, ...]]) RETURNS type315 return $this->factory->getRoutineCommandsParser()->parseCreateFunction($tokenList->rewind($start));316 }317 $tokenList->expectQualifiedName();318 if ($tokenList->hasSymbol('(')) {319 // CREATE ... FUNCTION ... sp_name ([func_parameter[, ...]]) RETURNS type320 return $this->factory->getRoutineCommandsParser()->parseCreateFunction($tokenList->rewind($start));321 }322 // CREATE ... FUNCTION function_name RETURNS {STRING|INTEGER|REAL|DECIMAL} SONAME323 return $this->factory->getCreateFunctionCommandParser()->parseCreateFunction($tokenList->rewind($start));324 }325 // eliminating unique prefixes for CREATE VIEW326 if ($tokenList->hasKeywords(Keyword::OR, Keyword::REPLACE)) {327 // CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW328 return $this->factory->getViewCommandsParser()->parseCreateView($tokenList->rewind($start));329 } elseif ($tokenList->hasKeyword(Keyword::ALGORITHM)) {330 // CREATE ... [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}] [DEFINER = { user | CURRENT_USER }] [SQL SECURITY { DEFINER | INVOKER }] VIEW331 return $this->factory->getViewCommandsParser()->parseCreateView($tokenList->rewind($start));332 }333 // get DEFINER out of the way334 if ($tokenList->hasKeyword(Keyword::DEFINER)) {335 $tokenList->passSymbol('=');336 if ($tokenList->hasKeyword(Keyword::CURRENT_USER)) {337 if ($tokenList->hasSymbol('(')) {338 $tokenList->passSymbol(')');339 }340 } else {341 $tokenList->expectUserName();342 }343 }344 if ($tokenList->hasKeyword(Keyword::EVENT)) {345 // CREATE ... EVENT346 return $this->factory->getEventCommandsParser()->parseCreateEvent($tokenList->rewind($start));347 } elseif ($tokenList->hasKeyword(Keyword::FUNCTION)) {348 // CREATE ... FUNCTION349 return $this->factory->getRoutineCommandsParser()->parseCreateFunction($tokenList->rewind($start));350 } elseif ($tokenList->hasKeyword(Keyword::PROCEDURE)) {351 // CREATE ... PROCEDURE352 return $this->factory->getRoutineCommandsParser()->parseCreateProcedure($tokenList->rewind($start));353 } elseif ($tokenList->hasKeyword(Keyword::TRIGGER)) {354 // CREATE ... TRIGGER355 return $this->factory->getTriggerCommandsParser()->parseCreateTrigger($tokenList->rewind($start));356 } elseif ($tokenList->seekKeyword(Keyword::VIEW, 5)) {357 // CREATE ... [SQL SECURITY { DEFINER | INVOKER }] VIEW358 return $this->factory->getViewCommandsParser()->parseCreateView($tokenList->rewind($start));359 }360 $tokenList->rewind($start)->missingAnyKeyword(361 Keyword::DATABASE, Keyword::SCHEMA, Keyword::LOGFILE, Keyword::ROLE, Keyword::SERVER,362 Keyword::TABLESPACE, Keyword::TABLE, Keyword::USER, Keyword::EVENT, Keyword::FUNCTION,363 Keyword::INDEX, Keyword::PROCEDURE, Keyword::TABLE, Keyword::TRIGGER, Keyword::VIEW, Keyword::DEFINER364 );365 case Keyword::DEALLOCATE:366 // {DEALLOCATE | DROP} PREPARE367 return $this->factory->getPreparedCommandsParser()->parseDeallocatePrepare($tokenList->rewind($start));368 case Keyword::DELETE:369 // DELETE370 return $this->factory->getDeleteCommandParser()->parseDelete($tokenList->rewind($start));371 case Keyword::DELIMITER:372 // DELIMITER373 return $this->factory->getDelimiterCommandParser()->parseDelimiter($tokenList->rewind($start));374 case Keyword::DESC:375 // DESC376 return $this->factory->getExplainCommandParser()->parseExplain($tokenList->rewind($start));377 case Keyword::DESCRIBE:378 // DESCRIBE379 return $this->factory->getExplainCommandParser()->parseExplain($tokenList->rewind($start));380 case Keyword::DO:381 // DO382 return $this->factory->getDoCommandParser()->parseDo($tokenList->rewind($start));383 case Keyword::DROP:384 $second = $tokenList->expectAnyKeyword(385 Keyword::DATABASE, Keyword::SCHEMA, Keyword::EVENT, Keyword::FUNCTION, Keyword::INDEX,386 Keyword::LOGFILE, Keyword::PREPARE, Keyword::PROCEDURE, Keyword::ROLE, Keyword::RESOURCE,387 Keyword::SERVER, Keyword::SPATIAL, Keyword::TABLE, Keyword::TABLES, Keyword::TEMPORARY,388 Keyword::TABLESPACE, Keyword::TRIGGER, Keyword::UNDO, Keyword::USER, Keyword::VIEW389 );390 switch ($second) {391 case Keyword::DATABASE:392 case Keyword::SCHEMA:393 // DROP {DATABASE | SCHEMA}394 return $this->factory->getSchemaCommandsParser()->parseDropSchema($tokenList->rewind($start));395 case Keyword::EVENT:396 // DROP EVENT397 return $this->factory->getEventCommandsParser()->parseDropEvent($tokenList->rewind($start));398 case Keyword::FUNCTION:399 // DROP {PROCEDURE | FUNCTION}400 return $this->factory->getRoutineCommandsParser()->parseDropFunction($tokenList->rewind($start));401 case Keyword::INDEX:402 // DROP INDEX403 return $this->factory->getIndexCommandsParser()->parseDropIndex($tokenList->rewind($start));404 case Keyword::LOGFILE:405 // DROP LOGFILE GROUP406 return $this->factory->getLogfileGroupCommandsParser()->parseDropLogfileGroup($tokenList->rewind($start));407 case Keyword::PREPARE:408 // {DEALLOCATE | DROP} PREPARE409 return $this->factory->getPreparedCommandsParser()->parseDeallocatePrepare($tokenList->rewind($start));410 case Keyword::PROCEDURE:411 // DROP {PROCEDURE | FUNCTION}412 return $this->factory->getRoutineCommandsParser()->parseDropProcedure($tokenList->rewind($start));413 case Keyword::RESOURCE:414 // DROP RESOURCE GROUP415 return $this->factory->getResourceCommandsParser()->parseDropResourceGroup($tokenList->rewind($start));416 case Keyword::ROLE:417 // DROP ROLE418 return $this->factory->getUserCommandsParser()->parseDropRole($tokenList->rewind($start));419 case Keyword::SERVER:420 // DROP SERVER421 return $this->factory->getServerCommandsParser()->parseDropServer($tokenList->rewind($start));422 case Keyword::SPATIAL:423 // DROP SPATIAL REFERENCE SYSTEM424 return $this->factory->getSpatialCommandsParser()->parseDropSpatialReferenceSystem($tokenList->rewind($start));425 case Keyword::TABLE:426 case Keyword::TABLES:427 case Keyword::TEMPORARY:428 // DROP [TEMPORARY] TABLE429 return $this->factory->getTableCommandsParser()->parseDropTable($tokenList->rewind($start));430 case Keyword::TABLESPACE:431 case Keyword::UNDO:432 // DROP [UNDO] TABLESPACE433 return $this->factory->getTablespaceCommandsParser()->parseDropTablespace($tokenList->rewind($start));434 case Keyword::TRIGGER:435 // DROP TRIGGER436 return $this->factory->getTriggerCommandsParser()->parseDropTrigger($tokenList->rewind($start));437 case Keyword::USER:438 // DROP USER439 return $this->factory->getUserCommandsParser()->parseDropUser($tokenList->rewind($start));440 case Keyword::VIEW:441 // DROP VIEW442 return $this->factory->getViewCommandsParser()->parseDropView($tokenList->rewind($start));443 }444 case Keyword::EXECUTE:445 // EXECUTE446 return $this->factory->getPreparedCommandsParser()->parseExecute($tokenList->rewind($start));447 case Keyword::EXPLAIN:448 // EXPLAIN449 return $this->factory->getExplainCommandParser()->parseExplain($tokenList->rewind($start));450 case Keyword::FLUSH:451 if ($tokenList->hasAnyKeyword(Keyword::TABLES, Keyword::TABLE)452 || $tokenList->hasKeywords(Keyword::LOCAL, Keyword::TABLES)453 || $tokenList->hasKeywords(Keyword::LOCAL, Keyword::TABLE)454 || $tokenList->hasKeywords(Keyword::NO_WRITE_TO_BINLOG, Keyword::TABLES)455 || $tokenList->hasKeywords(Keyword::NO_WRITE_TO_BINLOG, Keyword::TABLE)456 ) {457 // FLUSH TABLES458 return $this->factory->getFlushCommandParser()->parseFlushTables($tokenList->rewind($start));459 } else {460 // FLUSH461 return $this->factory->getFlushCommandParser()->parseFlush($tokenList->rewind($start));462 }463 case Keyword::GET:464 // GET DIAGNOSTICS465 return $this->factory->getCompoundStatementParser()->parseGetDiagnostics($tokenList->rewind($start));466 case Keyword::GRANT:467 // GRANT468 return $this->factory->getUserCommandsParser()->parseGrant($tokenList->rewind($start));469 case Keyword::HANDLER:470 // HANDLER471 $tokenList->expectQualifiedName();472 $keyword = $tokenList->expectAnyKeyword(Keyword::OPEN, Keyword::READ, Keyword::CLOSE);473 if ($keyword === Keyword::OPEN) {474 return $this->factory->getHandlerCommandParser()->parseHandlerOpen($tokenList->rewind($start));475 } elseif ($keyword === Keyword::READ) {476 return $this->factory->getHandlerCommandParser()->parseHandlerRead($tokenList->rewind($start));477 } else {478 return $this->factory->getHandlerCommandParser()->parseHandlerClose($tokenList->rewind($start));479 }480 case Keyword::HELP:481 // HELP482 return $this->factory->getHelpCommandParser()->parseHelp($tokenList->rewind($start));483 case Keyword::IMPORT:484 // IMPORT485 return $this->factory->getImportCommandParser()->parseImport($tokenList->rewind($start));486 case Keyword::INSERT:487 // INSERT488 return $this->factory->getInsertCommandParser()->parseInsert($tokenList->rewind($start));489 case Keyword::INSTALL:490 $second = $tokenList->expectAnyKeyword(Keyword::COMPONENT, Keyword::PLUGIN);491 if ($second === Keyword::COMPONENT) {492 // INSTALL COMPONENT493 return $this->factory->getComponentCommandsParser()->parseInstallComponent($tokenList->rewind($start));494 } else {495 // INSTALL PLUGIN496 return $this->factory->getPluginCommandsParser()->parseInstallPlugin($tokenList->rewind($start));497 }498 case Keyword::KILL:499 // KILL500 return $this->factory->getKillCommandParser()->parseKill($tokenList->rewind($start));501 case Keyword::LOCK:502 $second = $tokenList->expectAnyKeyword(Keyword::TABLE, Keyword::TABLES, Keyword::INSTANCE);503 if ($second === Keyword::INSTANCE) {504 // LOCK INSTANCE505 return $this->factory->getTransactionCommandsParser()->parseLockInstance($tokenList->rewind($start));506 } else {507 // LOCK TABLES508 return $this->factory->getTransactionCommandsParser()->parseLockTables($tokenList->rewind($start));509 }510 case Keyword::LOAD:511 $second = $tokenList->expectAnyKeyword(Keyword::DATA, Keyword::INDEX, Keyword::XML);512 if ($second === Keyword::DATA) {513 // LOAD DATA514 return $this->factory->getLoadCommandsParser()->parseLoadData($tokenList->rewind($start));515 } elseif ($second === Keyword::INDEX) {516 // LOAD INDEX INTO CACHE517 return $this->factory->getCacheCommandsParser()->parseLoadIndexIntoCache($tokenList->rewind($start));518 } else {519 // LOAD XML520 return $this->factory->getLoadCommandsParser()->parseLoadXml($tokenList->rewind($start));521 }522 case Keyword::OPTIMIZE:523 // OPTIMIZE TABLE524 return $this->factory->getTableMaintenanceCommandsParser()->parseOptimizeTable($tokenList->rewind($start));525 case Keyword::PREPARE:526 // PREPARE527 return $this->factory->getPreparedCommandsParser()->parsePrepare($tokenList->rewind($start));528 case Keyword::PURGE:529 // PURGE { BINARY | MASTER } LOGS530 return $this->factory->getReplicationCommandsParser()->parsePurgeBinaryLogs($tokenList->rewind($start));531 case Keyword::RELEASE:532 // RELEASE SAVEPOINT533 return $this->factory->getTransactionCommandsParser()->parseReleaseSavepoint($tokenList->rewind($start));534 case Keyword::RENAME:535 $second = $tokenList->expectAnyKeyword(Keyword::TABLE, Keyword::TABLES, Keyword::USER);536 if ($second === Keyword::TABLE || $second === Keyword::TABLES) {537 // RENAME TABLE538 return $this->factory->getTableCommandsParser()->parseRenameTable($tokenList->rewind($start));539 } else {540 // RENAME USER541 return $this->factory->getUserCommandsParser()->parseRenameUser($tokenList->rewind($start));542 }543 case Keyword::REPAIR:544 // REPAIR TABLE545 return $this->factory->getTableMaintenanceCommandsParser()->parseRepairTable($tokenList->rewind($start));546 case Keyword::REPLACE:547 // REPLACE548 return $this->factory->getInsertCommandParser()->parseReplace($tokenList->rewind($start));549 case Keyword::RESET:550 if ($tokenList->hasKeyword(Keyword::PERSIST)) {551 // RESET PERSIST552 return $this->factory->getSetCommandsParser()->parseResetPersist($tokenList->rewind($start));553 }554 $keyword = $tokenList->expectAnyKeyword(Keyword::MASTER, Keyword::REPLICA, Keyword::SLAVE, Keyword::QUERY);555 if ($keyword === Keyword::MASTER) {556 if ($tokenList->hasSymbol(',')) {557 // RESET MASTER, REPLICA, SLAVE, QUERY CACHE558 return $this->factory->getResetCommandParser()->parseReset($tokenList->rewind($start));559 }560 // RESET MASTER561 return $this->factory->getReplicationCommandsParser()->parseResetMaster($tokenList->rewind($start));562 } elseif ($keyword === Keyword::REPLICA) {563 if ($tokenList->hasSymbol(',')) {564 // RESET MASTER, REPLICA, SLAVE, QUERY CACHE565 return $this->factory->getResetCommandParser()->parseReset($tokenList->rewind($start));566 }567 // RESET REPLICA568 return $this->factory->getReplicationCommandsParser()->parseResetReplica($tokenList->rewind($start));569 } elseif ($keyword === Keyword::SLAVE) {570 if ($tokenList->hasSymbol(',')) {571 // RESET MASTER, REPLICA, SLAVE, QUERY CACHE572 return $this->factory->getResetCommandParser()->parseReset($tokenList->rewind($start));573 }574 // RESET SLAVE575 return $this->factory->getReplicationCommandsParser()->parseResetSlave($tokenList->rewind($start));576 } else {577 // RESET MASTER, REPLICA, SLAVE, QUERY CACHE578 return $this->factory->getResetCommandParser()->parseReset($tokenList->rewind($start));579 }580 case Keyword::RESIGNAL:581 // RESIGNAL582 return $this->factory->getCompoundStatementParser()->parseSignalResignal($tokenList->rewind($start));583 case Keyword::RESTART:584 // RESTART585 return $this->factory->getRestartCommandParser()->parseRestart($tokenList->rewind($start));586 case Keyword::REVOKE:587 // REVOKE588 return $this->factory->getUserCommandsParser()->parseRevoke($tokenList->rewind($start));589 case Keyword::ROLLBACK:590 // ROLLBACK591 if ($tokenList->seekKeyword(Keyword::TO, 3)) {592 return $this->factory->getTransactionCommandsParser()->parseRollbackToSavepoint($tokenList->rewind($start));593 } else {594 return $this->factory->getTransactionCommandsParser()->parseRollback($tokenList->rewind($start));595 }596 case Keyword::SAVEPOINT:597 // SAVEPOINT598 return $this->factory->getTransactionCommandsParser()->parseSavepoint($tokenList->rewind($start));599 case Keyword::SELECT:600 // SELECT601 return $this->factory->getQueryParser()->parseQuery($tokenList->rewind($start));602 case Keyword::SET:603 $second = $tokenList->getKeyword();604 switch ($second) {605 case Keyword::CHARACTER:606 case Keyword::CHARSET:607 // SET {CHARACTER SET | CHARSET}608 return $this->factory->getSetCommandsParser()->parseSetCharacterSet($tokenList->rewind($start));609 case Keyword::DEFAULT:610 // SET DEFAULT ROLE611 return $this->factory->getUserCommandsParser()->parseSetDefaultRole($tokenList->rewind($start));612 case Keyword::NAMES:613 // SET NAMES614 return $this->factory->getSetCommandsParser()->parseSetNames($tokenList->rewind($start));615 case Keyword::PASSWORD:616 // SET PASSWORD617 return $this->factory->getUserCommandsParser()->parseSetPassword($tokenList->rewind($start));618 case Keyword::RESOURCE:619 // SET RESOURCE GROUP620 return $this->factory->getResourceCommandsParser()->parseSetResourceGroup($tokenList->rewind($start));621 case Keyword::ROLE:622 // SET ROLE623 return $this->factory->getUserCommandsParser()->parseSetRole($tokenList->rewind($start));624 case Keyword::GLOBAL:625 case Keyword::SESSION:626 case Keyword::LOCAL:627 case Keyword::TRANSACTION:628 if ($second === Keyword::TRANSACTION || $tokenList->hasKeyword(Keyword::TRANSACTION)) {629 // SET [GLOBAL | SESSION | LOCAL] TRANSACTION630 return $this->factory->getTransactionCommandsParser()->parseSetTransaction($tokenList->rewind($start));631 } else {632 // SET633 return $this->factory->getSetCommandsParser()->parseSet($tokenList->rewind($start));634 }635 default:636 // SET637 return $this->factory->getSetCommandsParser()->parseSet($tokenList->rewind($start));638 }639 case Keyword::SHOW:640 // SHOW641 return $this->factory->getShowCommandsParser()->parseShow($tokenList->rewind($start));642 case Keyword::SHUTDOWN:643 // SHUTDOWN644 return $this->factory->getShutdownCommandParser()->parseShutdown($tokenList->rewind($start));645 case Keyword::SIGNAL:646 // SIGNAL647 return $this->factory->getCompoundStatementParser()->parseSignalResignal($tokenList->rewind($start));648 case Keyword::START:649 $second = $tokenList->expectAnyKeyword(Keyword::GROUP_REPLICATION, Keyword::SLAVE, Keyword::REPLICA, Keyword::TRANSACTION);650 if ($second === Keyword::GROUP_REPLICATION) {651 // START GROUP_REPLICATION652 return $this->factory->getReplicationCommandsParser()->parseStartGroupReplication($tokenList->rewind($start));653 } elseif ($second === Keyword::SLAVE || $second === Keyword::REPLICA) {654 // START SLAVE655 // START REPLICA656 return $this->factory->getReplicationCommandsParser()->parseStartReplicaOrSlave($tokenList->rewind($start));657 } else {658 // START TRANSACTION659 return $this->factory->getTransactionCommandsParser()->parseStartTransaction($tokenList->rewind($start));660 }661 case Keyword::STOP:662 $second = $tokenList->expectAnyKeyword(Keyword::GROUP_REPLICATION, Keyword::SLAVE, Keyword::REPLICA);663 if ($second === Keyword::GROUP_REPLICATION) {664 // STOP GROUP_REPLICATION665 return $this->factory->getReplicationCommandsParser()->parseStopGroupReplication($tokenList->rewind($start));666 } elseif ($second === Keyword::SLAVE) {667 // STOP SLAVE668 return $this->factory->getReplicationCommandsParser()->parseStopSlave($tokenList->rewind($start));669 } else {670 // STOP REPLICA671 return $this->factory->getReplicationCommandsParser()->parseStopReplica($tokenList->rewind($start));672 }673 case Keyword::TABLE:674 // TABLE675 return $this->factory->getQueryParser()->parseQuery($tokenList->rewind($start));676 case Keyword::TRUNCATE:677 // TRUNCATE [TABLE]678 return $this->factory->getTableCommandsParser()->parseTruncateTable($tokenList->rewind($start));679 case Keyword::UNINSTALL:680 $second = $tokenList->expectAnyKeyword(Keyword::COMPONENT, Keyword::PLUGIN);681 if ($second === Keyword::COMPONENT) {682 // UNINSTALL COMPONENT683 return $this->factory->getComponentCommandsParser()->parseUninstallComponent($tokenList->rewind($start));684 } else {685 // UNINSTALL PLUGIN686 return $this->factory->getPluginCommandsParser()->parseUninstallPlugin($tokenList->rewind($start));687 }688 case Keyword::UNLOCK:689 $second = $tokenList->expectAnyKeyword(Keyword::TABLE, Keyword::TABLES, Keyword::INSTANCE);690 if ($second === Keyword::INSTANCE) {691 // UNLOCK INSTANCE692 return $this->factory->getTransactionCommandsParser()->parseUnlockInstance($tokenList->rewind($start));693 } else {694 // UNLOCK TABLES695 return $this->factory->getTransactionCommandsParser()->parseUnlockTables($tokenList->rewind($start));696 }697 case Keyword::UPDATE:698 // UPDATE699 return $this->factory->getUpdateCommandParser()->parseUpdate($tokenList->rewind($start));700 case Keyword::USE:701 // USE702 return $this->factory->getUseCommandParser()->parseUse($tokenList->rewind($start));703 case Keyword::VALUES:704 // VALUES705 return $this->factory->getQueryParser()->parseQuery($tokenList->rewind($start));706 case Keyword::WITH:707 // WITH ... SELECT|UPDATE|DELETE708 return $this->factory->getWithParser()->parseWith($tokenList->rewind($start));709 case Keyword::XA:710 // XA {START|BEGIN}711 // XA END712 // XA PREPARE713 // XA COMMIT714 // XA ROLLBACK715 // XA RECOVER716 return $this->factory->getXaTransactionCommandsParser()->parseXa($tokenList->rewind($start));717 default:718 $tokenList->rewind($start)->missingAnyKeyword(...self::STARTING_KEYWORDS);719 }720 }721}...

Full Screen

Full Screen

MakeWellFormed.php

Source:MakeWellFormed.php Github

copy

Full Screen

...114 // only increment if we don't need to reprocess115 $reprocess ? $reprocess = false : $t++116 ) {117 118 // check for a rewind119 if (is_int($i) && $i >= 0) {120 // possibility: disable rewinding if the current token has a121 // rewind set on it already. This would offer protection from122 // infinite loop, but might hinder some advanced rewinding.123 $rewind_to = $this->injectors[$i]->getRewind();124 if (is_int($rewind_to) && $rewind_to < $t) {125 if ($rewind_to < 0) $rewind_to = 0;126 while ($t > $rewind_to) {127 $t--;128 $prev = $tokens[$t];129 // indicate that other injectors should not process this token,130 // but we need to reprocess it131 unset($prev->skip[$i]);132 $prev->rewind = $i;133 if ($prev instanceof HTMLPurifier_Token_Start) array_pop($this->stack);134 elseif ($prev instanceof HTMLPurifier_Token_End) $this->stack[] = $prev->start;135 }136 }137 $i = false;138 }139 140 // handle case of document end141 if (!isset($tokens[$t])) {142 // kill processing if stack is empty143 if (empty($this->stack)) break;144 145 // peek146 $top_nesting = array_pop($this->stack);147 $this->stack[] = $top_nesting;148 149 // send error150 if ($e && !isset($top_nesting->armor['MakeWellFormed_TagClosedError'])) {151 $e->send(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', $top_nesting);152 }153 154 // append, don't splice, since this is the end155 $tokens[] = new HTMLPurifier_Token_End($top_nesting->name);156 157 // punt!158 $reprocess = true;159 continue;160 }161 162 // if all goes well, this token will be passed through unharmed163 $token = $tokens[$t];164 165 //echo '<hr>';166 //printTokens($tokens, $t);167 //var_dump($this->stack);168 169 // quick-check: if it's not a tag, no need to process170 if (empty($token->is_tag)) {171 if ($token instanceof HTMLPurifier_Token_Text) {172 foreach ($this->injectors as $i => $injector) {173 if (isset($token->skip[$i])) continue;174 if ($token->rewind !== null && $token->rewind !== $i) continue;175 $injector->handleText($token);176 $this->processToken($token, $i);177 $reprocess = true;178 break;179 }180 }181 // another possibility is a comment182 continue;183 }184 185 if (isset($definition->info[$token->name])) {186 $type = $definition->info[$token->name]->child->type;187 } else {188 $type = false; // Type is unknown, treat accordingly189 }190 191 // quick tag checks: anything that's *not* an end tag192 $ok = false;193 if ($type === 'empty' && $token instanceof HTMLPurifier_Token_Start) {194 // claims to be a start tag but is empty195 $token = new HTMLPurifier_Token_Empty($token->name, $token->attr);196 $ok = true;197 } elseif ($type && $type !== 'empty' && $token instanceof HTMLPurifier_Token_Empty) {198 // claims to be empty but really is a start tag199 $this->swap(new HTMLPurifier_Token_End($token->name));200 $this->insertBefore(new HTMLPurifier_Token_Start($token->name, $token->attr));201 // punt (since we had to modify the input stream in a non-trivial way)202 $reprocess = true;203 continue;204 } elseif ($token instanceof HTMLPurifier_Token_Empty) {205 // real empty token206 $ok = true;207 } elseif ($token instanceof HTMLPurifier_Token_Start) {208 // start tag209 210 // ...unless they also have to close their parent211 if (!empty($this->stack)) {212 213 $parent = array_pop($this->stack);214 $this->stack[] = $parent;215 216 if (isset($definition->info[$parent->name])) {217 $elements = $definition->info[$parent->name]->child->getNonAutoCloseElements($config);218 $autoclose = !isset($elements[$token->name]);219 } else {220 $autoclose = false;221 }222 223 if ($autoclose) {224 if ($e) $e->send(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', $parent);225 // insert parent end tag before this tag226 $new_token = new HTMLPurifier_Token_End($parent->name);227 $new_token->start = $parent;228 $this->insertBefore($new_token);229 $reprocess = true;230 continue;231 }232 233 }234 $ok = true;235 }236 237 if ($ok) {238 foreach ($this->injectors as $i => $injector) {239 if (isset($token->skip[$i])) continue;240 if ($token->rewind !== null && $token->rewind !== $i) continue;241 $injector->handleElement($token);242 $this->processToken($token, $i);243 $reprocess = true;244 break;245 }246 if (!$reprocess) {247 // ah, nothing interesting happened; do normal processing248 $this->swap($token);249 if ($token instanceof HTMLPurifier_Token_Start) {250 $this->stack[] = $token;251 } elseif ($token instanceof HTMLPurifier_Token_End) {252 throw new HTMLPurifier_Exception('Improper handling of end tag in start code; possible error in MakeWellFormed');253 }254 }255 continue;256 }257 258 // sanity check: we should be dealing with a closing tag259 if (!$token instanceof HTMLPurifier_Token_End) {260 throw new HTMLPurifier_Exception('Unaccounted for tag token in input stream, bug in HTML Purifier');261 }262 263 // make sure that we have something open264 if (empty($this->stack)) {265 if ($escape_invalid_tags) {266 if ($e) $e->send(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');267 $this->swap(new HTMLPurifier_Token_Text(268 $generator->generateFromToken($token)269 ));270 } else {271 $this->remove();272 if ($e) $e->send(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed');273 }274 $reprocess = true;275 continue;276 }277 278 // first, check for the simplest case: everything closes neatly.279 // Eventually, everything passes through here; if there are problems280 // we modify the input stream accordingly and then punt, so that281 // the tokens get processed again.282 $current_parent = array_pop($this->stack);283 if ($current_parent->name == $token->name) {284 $token->start = $current_parent;285 foreach ($this->injectors as $i => $injector) {286 if (isset($token->skip[$i])) continue;287 if ($token->rewind !== null && $token->rewind !== $i) continue;288 $injector->handleEnd($token);289 $this->processToken($token, $i);290 $this->stack[] = $current_parent;291 $reprocess = true;292 break;293 }294 continue;295 }296 297 // okay, so we're trying to close the wrong tag298 299 // undo the pop previous pop300 $this->stack[] = $current_parent;301 ...

Full Screen

Full Screen

ChangeStreamIterator.php

Source:ChangeStreamIterator.php Github

copy

Full Screen

...37 * ChangeStreamIterator wraps a change stream's tailable cursor.38 *39 * This iterator tracks the size of each batch in order to determine when the40 * postBatchResumeToken is applicable. It also ensures that initial calls to41 * rewind() do not execute getMore commands.42 *43 * @internal44 */45class ChangeStreamIterator extends IteratorIterator implements CommandSubscriber46{47 /** @var integer */48 private $batchPosition = 0;49 /** @var integer */50 private $batchSize;51 /** @var boolean */52 private $isRewindNop;53 /** @var boolean */54 private $isValid = false;55 /** @var object|null */56 private $postBatchResumeToken;57 /** @var array|object|null */58 private $resumeToken;59 /** @var Server */60 private $server;61 /**62 * @internal63 * @param Cursor $cursor64 * @param integer $firstBatchSize65 * @param array|object|null $initialResumeToken66 * @param object|null $postBatchResumeToken67 */68 public function __construct(Cursor $cursor, $firstBatchSize, $initialResumeToken, $postBatchResumeToken)69 {70 if (! is_integer($firstBatchSize)) {71 throw InvalidArgumentException::invalidType('$firstBatchSize', $firstBatchSize, 'integer');72 }73 if (isset($initialResumeToken) && ! is_array($initialResumeToken) && ! is_object($initialResumeToken)) {74 throw InvalidArgumentException::invalidType('$initialResumeToken', $initialResumeToken, 'array or object');75 }76 if (isset($postBatchResumeToken) && ! is_object($postBatchResumeToken)) {77 throw InvalidArgumentException::invalidType('$postBatchResumeToken', $postBatchResumeToken, 'object');78 }79 parent::__construct($cursor);80 $this->batchSize = $firstBatchSize;81 $this->isRewindNop = ($firstBatchSize === 0);82 $this->postBatchResumeToken = $postBatchResumeToken;83 $this->resumeToken = $initialResumeToken;84 $this->server = $cursor->getServer();85 }86 /** @internal */87 final public function commandFailed(CommandFailedEvent $event)88 {89 }90 /** @internal */91 final public function commandStarted(CommandStartedEvent $event)92 {93 if ($event->getCommandName() !== 'getMore') {94 return;95 }96 $this->batchPosition = 0;97 $this->batchSize = null;98 $this->postBatchResumeToken = null;99 }100 /** @internal */101 final public function commandSucceeded(CommandSucceededEvent $event)102 {103 if ($event->getCommandName() !== 'getMore') {104 return;105 }106 $reply = $event->getReply();107 if (! isset($reply->cursor->nextBatch) || ! is_array($reply->cursor->nextBatch)) {108 throw new UnexpectedValueException('getMore command did not return a "cursor.nextBatch" array');109 }110 $this->batchSize = count($reply->cursor->nextBatch);111 if (isset($reply->cursor->postBatchResumeToken) && is_object($reply->cursor->postBatchResumeToken)) {112 $this->postBatchResumeToken = $reply->cursor->postBatchResumeToken;113 }114 }115 /**116 * @see https://php.net/iteratoriterator.current117 * @return mixed118 */119 #[ReturnTypeWillChange]120 public function current()121 {122 return $this->isValid ? parent::current() : null;123 }124 /**125 * Returns the resume token for the iterator's current position.126 *127 * Null may be returned if no change documents have been iterated and the128 * server did not include a postBatchResumeToken in its aggregate or getMore129 * command response.130 *131 * @return array|object|null132 */133 public function getResumeToken()134 {135 return $this->resumeToken;136 }137 /**138 * Returns the server the cursor is running on.139 */140 public function getServer(): Server141 {142 return $this->server;143 }144 /**145 * @see https://php.net/iteratoriterator.key146 * @return mixed147 */148 #[ReturnTypeWillChange]149 public function key()150 {151 return $this->isValid ? parent::key() : null;152 }153 /**154 * @see https://php.net/iteratoriterator.rewind155 * @return void156 */157 #[ReturnTypeWillChange]158 public function next()159 {160 /* Determine if advancing the iterator will execute a getMore command161 * (i.e. we are already positioned at the end of the current batch). If162 * so, rely on the APM callbacks to reset $batchPosition and update163 * $batchSize. Otherwise, we can forgo APM and manually increment164 * $batchPosition after calling next(). */165 $getMore = $this->isAtEndOfBatch();166 if ($getMore) {167 addSubscriber($this);168 }169 try {170 parent::next();171 $this->onIteration(! $getMore);172 } finally {173 if ($getMore) {174 removeSubscriber($this);175 }176 }177 }178 /**179 * @see https://php.net/iteratoriterator.rewind180 * @return void181 */182 #[ReturnTypeWillChange]183 public function rewind()184 {185 if ($this->isRewindNop) {186 return;187 }188 parent::rewind();189 $this->onIteration(false);190 }191 /**192 * @see https://php.net/iteratoriterator.valid193 * @return boolean194 */195 #[ReturnTypeWillChange]196 public function valid()197 {198 return $this->isValid;199 }200 /**201 * Extracts the resume token (i.e. "_id" field) from a change document.202 *203 * @param array|object $document Change document204 * @return array|object205 * @throws InvalidArgumentException206 * @throws ResumeTokenException if the resume token is not found or invalid207 */208 private function extractResumeToken($document)209 {210 if (! is_array($document) && ! is_object($document)) {211 throw InvalidArgumentException::invalidType('$document', $document, 'array or object');212 }213 if ($document instanceof Serializable) {214 return $this->extractResumeToken($document->bsonSerialize());215 }216 $resumeToken = is_array($document)217 ? ($document['_id'] ?? null)218 : ($document->_id ?? null);219 if (! isset($resumeToken)) {220 $this->isValid = false;221 throw ResumeTokenException::notFound();222 }223 if (! is_array($resumeToken) && ! is_object($resumeToken)) {224 $this->isValid = false;225 throw ResumeTokenException::invalidType($resumeToken);226 }227 return $resumeToken;228 }229 /**230 * Return whether the iterator is positioned at the end of the batch.231 *232 * @return boolean233 */234 private function isAtEndOfBatch()235 {236 return $this->batchPosition + 1 >= $this->batchSize;237 }238 /**239 * Perform housekeeping after an iteration event.240 *241 * @see https://github.com/mongodb/specifications/blob/master/source/change-streams/change-streams.rst#updating-the-cached-resume-token242 * @param boolean $incrementBatchPosition243 */244 private function onIteration($incrementBatchPosition)245 {246 $this->isValid = parent::valid();247 /* Disable rewind()'s NOP behavior once we advance to a valid position.248 * This will allow the driver to throw a LogicException if rewind() is249 * called after the cursor has advanced past its first element. */250 if ($this->isRewindNop && $this->isValid) {251 $this->isRewindNop = false;252 }253 if ($incrementBatchPosition && $this->isValid) {254 $this->batchPosition++;255 }256 /* If the iterator is positioned at the end of the batch, apply the257 * postBatchResumeToken if it's available. This handles both the case258 * where the current batch is empty (since onIteration() will be called259 * after a successful getMore) and when the iterator has advanced to the260 * last document in its current batch. Otherwise, extract a resume token261 * from the current document if possible. */262 if ($this->isAtEndOfBatch() && $this->postBatchResumeToken !== null) {...

Full Screen

Full Screen

EndRewindInjector.php

Source:EndRewindInjector.php Github

copy

Full Screen

...22 $prev->name == 'span'23 ) {24 $token = false;25 $prev->_InjectorTest_EndRewindInjector_delete = true;26 $this->rewindOffset(1);27 }28 }29}30// vim: et sw=4 sts=4...

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1$tokens = token_get_all(file_get_contents('1.php'));2foreach ($tokens as $token) {3 if (is_array($token)) {4 list($id, $text) = $token;5 echo token_name($id) . " => " . $text . "6";7 } else {8";9 }10}11T_OPEN_PARENTHESIS => (12T_OPEN_PARENTHESIS => (13T_SEMICOLON => ;14T_OPEN_PARENTHESIS => (

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1$token = new Token();2$token->rewind();3$token = new Token();4$token->next();5$token = new Token();6$token->key();7$token = new Token();8$token->valid();9$token = new Token();10$token->current();11$token = new Token();12$token->offsetExists(1);13$token = new Token();14$token->offsetGet(1);15$token = new Token();16$token->offsetSet(1);17$token = new Token();18$token->offsetUnset(1);19$token = new Token();20$token->count();21$token = new Token();22$token->getIterator();23$token = new Token();24$token->getChildren();25$token = new Token();26$token->hasChildren();27$token = new Token();28$token->seek(1);29$token = new Token();30$token->append(1);

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1$source = '<?php echo "Hello World"; ?>';2$tokens = token_get_all($source);3$token = new Token($tokens);4$token->rewind();5while ($token->valid()) {6var_dump($token->current());7$token->next();8}9PHP 5.3.0RC3 Development Version (cli) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0-dev, Copyright (c) 1998-2009 Zend Technologies10array(2) {11int(370)12string(5) "<?php"13}14array(2) {15int(307)16string(4) "echo"17}18array(2) {19int(311)20string(2) " "21}22array(2) {23int(370)24string(2) "\""25}26array(2) {27int(370)28string(11) "Hello World"29}30array(2) {31int(370)32string(2) "\""33}34array(2) {35int(311)36string(2) " "37}38array(2) {39int(370)40string(3) "?>"41}

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1$tokens = token_get_all('<?php echo "Hello World!"; ?>');2$tokens = new ArrayObject($tokens);3$tokens->rewind();4var_dump($tokens->current());5array(4) {6 int(379)7 string(5) "<?php"8 int(379)9 string(1) " "10}11Example #2 Token::valid() example12$tokens = token_get_all('<?php echo "Hello World!"; ?>');13$tokens = new ArrayObject($tokens);14$tokens->rewind();15var_dump($tokens->valid());16bool(true)17Example #3 Token::key() example18$tokens = token_get_all('<?php echo "Hello World!"; ?>');19$tokens = new ArrayObject($tokens);20$tokens->rewind();21var_dump($tokens->key());22int(0)23Example #4 Token::next() example24$tokens = token_get_all('<?php echo "Hello World!"; ?>');25$tokens = new ArrayObject($tokens);26$tokens->rewind();27$tokens->next();28var_dump($tokens->current());29array(4) {30 int(379)31 string(5) "<?php"32 int(379)33 string(1) " "34}35Example #5 Token::offsetExists() example36$tokens = token_get_all('<?php echo "Hello World!"; ?>');37$tokens = new ArrayObject($tokens);38var_dump($tokens->offsetExists(0));39bool(true)40Example #6 Token::offsetGet() example41$tokens = token_get_all('<?php echo "Hello World!"; ?>');42$tokens = new ArrayObject($tokens);

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1{2 public function bar()3 {4 echo "Hello World!";5 }6}7?>';8$tokens = token_get_all($code);9$token = new Token($tokens);10$token->rewind();11while($token->valid()){12 echo $token->current().PHP_EOL;13 $token->next();14}15 [1] => (16 [1] => {17 [1] => ;

Full Screen

Full Screen

rewind

Using AI Code Generation

copy

Full Screen

1$token = $tokenizer->getNextToken();2while ($token != null) {3 echo $token->getTokenString() . "4";5 $token = $tokenizer->getNextToken();6}7$token = $tokenizer->getNextToken();8while ($token != null) {9 echo $token->getTokenString() . "10";11 $token = $tokenizer->getNextToken();12}13$token = $tokenizer->getNextToken();14while ($token != null) {15 echo $token->getTokenString() . "16";17 $token = $tokenizer->getNextToken();18}19$token = $tokenizer->getNextToken();20while ($token != null) {21 echo $token->getTokenString() . "22";23 $token = $tokenizer->getNextToken();24}25$token = $tokenizer->getNextToken();26while ($token != null) {27 echo $token->getTokenString() . "28";29 $token = $tokenizer->getNextToken();30}31$token = $tokenizer->getNextToken();32while ($token != null) {33 echo $token->getTokenString() . "34";35 $token = $tokenizer->getNextToken();36}37$token = $tokenizer->getNextToken();38while ($token != null) {39 echo $token->getTokenString() . "40";41 $token = $tokenizer->getNextToken();42}43$token = $tokenizer->getNextToken();44while ($token != null) {45 echo $token->getTokenString() . "46";

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger rewind code on LambdaTest Cloud Grid

Execute automation tests with rewind on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful