Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
$pathParts = pathinfo($phpcsFile->getFilename());
// Search for an info file.
$dir = $pathParts['dirname'];
This assumes that the $phpcsFile object has a filename to work with. This is not necessarily the case if you're running a string through a pipe to the phpcs command, or calling the PHPCS code directly with a string.
Comments