sql-parser
sql-parser copied to clipboard
Need to explicitely set $parser->list->idx = 0;
Hello devs,
Thanks for this excellent validating parser.
Trying to iterate over the list of Tokens, it does not work as assumed: I first need to explicitely set
$parser->list->idx = 0;
Only then the iteration is working (for me):
while ( NULL !== $token = $parser->list->getNextOfType(PhpMyAdmin\SqlParser\Token::TYPE_COMMENT) ) {
[...]
}
Bug or feature? Did I wrongly assume a different behaviour?
The docs don't specify anything in that regard (nor much on anything else). Any intention to improve on documentation besides "Use the Source..
"?
Thank you for clarification.
Hello @corbolais
Thank you !
This is a good question, maybe @ibennetch or @devenbansod would have the answer ?
That said a code sample would help me search for you an answer
The docs don't specify anything in that regard (nor much on anything else). Any intention to improve on documentation besides "Use the Source.."?
We are open for propositions to improve our documentation ;)
I unfortunately don't know the answer off the top of my head, but we will try to get an answer for you.
About the documentation, I agree that it needs to be improved. It hasn't been much of a priority, in part because we haven't realized the project has gained some usage outside of phpMyAdmin. This is something we can work towards improving.
Hi @corbolais What where you trying to do ? Can you provide a full example ?
Hi @williamdes
I remember trying to solve an issue that involved iterating over a list. The document stated the obvious, the rest I glimpsed from the source.
There was an error thrown however and to solve this it was required to initialize the index like so:
$parser->list->idx = 0;
I wanted to let you guys know this, just in case.
Of the top off my head I'm ignoring whether the requirement to init the index was due to some specific PHP version.
Cheers and greetings to Brittany, France!
A la prochaine..
Bonjour @corbolais 👋🏻 That you for letting us know, I think we should better document such specific things But maybe it could be pre initialized to 0
/cc @iifawzi I think you also did have this issue
I have had this issue in mind for a while, we need to double-check why and if this's happening. we need to investigate more, I will try to find some time to figure this out later