What are some practical uses of PHP tokenizer?

后端 未结 8 1012
暖寄归人
暖寄归人 2021-02-02 11:25

What are practical and day-to-day usage examples of PHP Tokenizer ?

Has anyone used this?

8条回答
  •  梦如初夏
    2021-02-02 11:34

    Interesting question.

    I have not used the tokenizer in any production projects myself yet, but there are several questions on Stack Overflow to which the tokenizer is the (or at least, one) correct answer.

    • Automatically parsing PHP to separate PHP code from HTML - extracting comments out of PHP code, e.g. to build documentation (phpDocumentor works this way)

    • Class exists in an external file - analyzing code, seeing whether a class exists inside a file (e.g. for a plugin management system)

    • Permanently write variables to a php file with php - altering PHP source code files, e.g. to fill in configuration variables. Using the tokenizer woud be the first step to do this on a parser level.

    • How to create a list of all built-in PHP functions a project makes use of? - analyzing what functions are used in a PHP project

提交回复
热议问题