Chris@0: getFilename()) === 1) { Chris@0: // Drupal 7 style info file. Chris@0: $contents = file_get_contents($phpcsFile->getFilename()); Chris@17: $info = ClassFilesSniff::drupalParseInfoFormat($contents); Chris@0: } else if (preg_match('/\.info\.yml$/', $phpcsFile->getFilename()) === 1) { Chris@0: // Drupal 8 style info.yml file. Chris@0: $contents = file_get_contents($phpcsFile->getFilename()); Chris@0: try { Chris@0: $info = \Symfony\Component\Yaml\Yaml::parse($contents); Chris@0: } catch (\Symfony\Component\Yaml\Exception\ParseException $e) { Chris@0: // If the YAML is invalid we ignore this file. Chris@0: return ($phpcsFile->numTokens + 1); Chris@0: } Chris@0: } else { Chris@0: return ($phpcsFile->numTokens + 1); Chris@0: } Chris@0: Chris@0: if (isset($info['project']) === true) { Chris@0: $warning = 'Remove "project" from the info file, it will be added by drupal.org packaging automatically'; Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'Project'); Chris@0: } Chris@0: Chris@0: if (isset($info['timestamp']) === true) { Chris@0: $warning = 'Remove "timestamp" from the info file, it will be added by drupal.org packaging automatically'; Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'Timestamp'); Chris@0: } Chris@0: Chris@0: // "version" is special: we want to allow it in core, but not anywhere else. Chris@0: if (isset($info['version']) === true && strpos($phpcsFile->getFilename(), '/core/') === false) { Chris@0: $warning = 'Remove "version" from the info file, it will be added by drupal.org packaging automatically'; Chris@0: $phpcsFile->addWarning($warning, $stackPtr, 'Version'); Chris@0: } Chris@0: Chris@0: return ($phpcsFile->numTokens + 1); Chris@0: Chris@0: }//end process() Chris@0: Chris@0: Chris@0: }//end class