PHPackages                             funivan/php-tokenizer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. funivan/php-tokenizer

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

funivan/php-tokenizer
=====================

Wrapper around token\_get\_all. Easy to extract and modify php code.

0.3.0(6y ago)1238.5k2[1 PRs](https://github.com/funivan/PhpTokenizer/pulls)2MITPHPPHP &gt;=7.2

Since May 14Pushed 1y ago5 watchersCompare

[ Source](https://github.com/funivan/PhpTokenizer)[ Packagist](https://packagist.org/packages/funivan/php-tokenizer)[ Docs](https://github.com/funivan/PhpTokenizer)[ RSS](/packages/funivan-php-tokenizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (13)Used By (2)

PhpTokenizer
============

[](#phptokenizer)

[![GitHub tag](https://camo.githubusercontent.com/6ffb9f3013b4aa8456e47dffa62520bd39b365d40f8d7ad57c69a034bcb7d4a0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f66756e6976616e2f506870546f6b656e697a65722e7376673f7374796c653d666c61742d737175617265)](https://github.com/funivan/PhpTokenizer/tags)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/0e4a4771dd90c614ba0094048399095ef73fab08a85a0814798ebe7a79dd59ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66756e6976616e2f7068702d746f6b656e697a65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/funivan/php-tokenizer)

Wrapper around token\_get\_all. Easy to extract and modify tokens

Install
-------

[](#install)

Via Composer

```
composer require funivan/php-tokenizer
```

Usage
-----

[](#usage)

Reformat our code like PhpStorm. Lets create rule: place single spaces after `while`

```
  use Funivan\PhpTokenizer\Collection;
  use Funivan\PhpTokenizer\Pattern\PatternMatcher;
  use Funivan\PhpTokenizer\QuerySequence\QuerySequence;

  $source = "
