$stackPtr is not a class member var in \vendor\squizlabs\php_codesniffer\src\Files\File.php:1888. It is generally thrown when the parser doesn't find the matching brackets during sniff, however it can be confusing what is causing the issue.
In my case, it was php string interpolation with curly brackets.
$settings = \Drupal::config("tmgmt.translator.{$plugin_id}")->get('settings');
Opting for different way or simply commenting the line during sniff may fix the error.
If the number of files are too large to pin point the error causing file, we can print and check the $this->path above this line \vendor\squizlabs\php_codesniffer\src\Files\File.php:1888.