The PHP Token Streams library provides an easy-to-use tokenising stream library that you can quickly drop into your own project to save you time and effort.
Run this command to add php-token-streams to your composer.json
file:
composer require ganbarodigita/php-token-streams