当前位置: 首页>>代码示例>>PHP>>正文


PHP PHP_CodeSniffer::process方法代码示例

本文整理汇总了PHP中PHP_CodeSniffer::process方法的典型用法代码示例。如果您正苦于以下问题:PHP PHP_CodeSniffer::process方法的具体用法?PHP PHP_CodeSniffer::process怎么用?PHP PHP_CodeSniffer::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHP_CodeSniffer的用法示例。


在下文中一共展示了PHP_CodeSniffer::process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Sets up this unit test.
  *
  * @return void
  */
 protected function setUp()
 {
     if (self::$phpcs === null) {
         self::$phpcs = new PHP_CodeSniffer();
     }
     PHP_CodeSniffer::setConfigData('testVersion', null, true);
     self::$phpcs->process(array(), 'PHPCompatibility');
     self::$phpcs->setIgnorePatterns(array());
 }
开发者ID:tierra,项目名称:PHPCompatibility,代码行数:14,代码来源:BaseSniffTest.php

示例2: setUp

 /**
  * Sets up this unit test.
  *
  * @return void
  */
 protected function setUp()
 {
     if (self::$phpcs === null) {
         self::$phpcs = new PHP_CodeSniffer();
     }
     PHP_CodeSniffer::setConfigData('testVersion', null, true);
     if (method_exists('PHP_CodeSniffer_CLI', 'setCommandLineValues')) {
         // For PHPCS 2.x
         self::$phpcs->cli->setCommandLineValues(array('-p', '--colors'));
     }
     self::$phpcs->process(array(), __DIR__ . '/../');
     self::$phpcs->setIgnorePatterns(array());
 }
开发者ID:christopheg,项目名称:PHPCompatibility,代码行数:18,代码来源:BaseSniffTest.php

示例3: runTest

 /**
  * Tests the extending classes Sniff class.
  *
  * @test
  * @return void
  * @throws PHPUnit_Framework_Error
  */
 public final function runTest()
 {
     // Skip this test if we can't run in this environment.
     if ($this->shouldSkipTest() === true) {
         $this->markTestSkipped();
     }
     if (!defined('TEST_PATH') || realpath(TEST_PATH) === false) {
         throw new \Exception('TEST_PATH is not defined');
     }
     $testClassFile = (new ReflectionClass(get_class($this)))->getFileName();
     $testClassFile = realpath($testClassFile);
     $testFile = dirname($testClassFile) . '/' . basename($testClassFile, '.php') . '.inc';
     if (!is_file($testFile)) {
         $this->fail("Required file [{$testFile}] not found");
     }
     self::$phpcs->process(array(), $this->getStandardName(), array($this->getSniffCode()));
     self::$phpcs->setIgnorePatterns(array());
     try {
         $phpcsFile = self::$phpcs->processFile($testFile);
     } catch (Exception $e) {
         $this->fail('An unexpected exception has been caught: ' . $e->getMessage());
     }
     $failureMessages = $this->generateFailureMessages($phpcsFile);
     if (empty($failureMessages) === false) {
         $this->fail(implode(PHP_EOL, $failureMessages));
     }
 }
开发者ID:chr0n1x,项目名称:php_codesniffer_tests,代码行数:34,代码来源:AbstractSniffUnitTest.php

示例4: execute

 public function execute()
 {
     require_once $this->mooshDir . "/includes/codesniffer_cli.php";
     require_once $this->mooshDir . "/includes/coderepair/CodeRepair.php";
     $moodle_sniffs = $this->mooshDir . "/vendor/moodlerooms/moodle-coding-standard/moodle";
     $options = $this->expandedOptions;
     $interactive = $options['interactive'];
     if (isset($options['path'])) {
         $this->checkDirArg($options['path']);
         $path = $options['path'];
     } else {
         $path = $this->cwd;
     }
     $files = $this->_get_files($path);
     if ($options['repair'] === true) {
         $code_repair = new \CodeRepair($files);
         $code_repair->drymode = false;
         $code_repair->start();
     }
     $phpcscli = new \codesniffer_cli();
     $phpcs = new \PHP_CodeSniffer(1, 0, 'utf-8', (bool) $interactive);
     $phpcs->setCli($phpcscli);
     $phpcs->process($files, $moodle_sniffs);
     $phpcs->reporting->printReport('full', false, $phpcscli->getCommandLineValues(), null);
 }
开发者ID:tmuras,项目名称:moosh,代码行数:25,代码来源:ToolsCodeCheck.php

示例5: process

 /**
  * Process analysis with framework standard
  * 
  * @param  string $file
  * @see    parent::process()
  * 
  * @return bool
  */
 function process($file)
 {
     $root_dir = CAppUI::conf("root_dir");
     $file = "{$root_dir}/{$file}";
     $standard = $this->getStandardDir();
     parent::process($file, $standard);
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:15,代码来源:CMbCodeSniffer.class.php

示例6: validate

 /**
  * Validate the current check
  *
  * Validate the check on the specified repository. Returns an array of 
  * found issues.
  * 
  * @param pchRepository $repository 
  * @return void
  */
 public function validate(pchRepository $repository)
 {
     $cs = new PHP_CodeSniffer();
     $cs->process(array(), $this->standard);
     foreach ($this->getChangedFiles($repository) as $file) {
         $cs->processFile($file, stream_get_contents($this->getFileContents($repository, $file)));
     }
     $issues = array();
     foreach ($cs->getFilesErrors() as $file => $messages) {
         foreach ($messages['errors'] as $errors) {
             foreach ($errors as $line => $lineErrors) {
                 foreach ($lineErrors as $error) {
                     $issues[] = new pchIssue(E_ERROR, $file, $line, $error['source'] . ': ' . $error['message']);
                 }
             }
         }
         foreach ($messages['warnings'] as $errors) {
             foreach ($errors as $line => $lineErrors) {
                 foreach ($lineErrors as $error) {
                     $issues[] = new pchIssue(E_WARNING, $file, $line, $error['source'] . ': ' . $error['message']);
                 }
             }
         }
     }
     return $issues;
 }
开发者ID:kore,项目名称:php-commit-hooks,代码行数:35,代码来源:code_sniffer.php

示例7: execute

 public function execute()
 {
     require_once $this->mooshDir . "/includes/codesniffer/CodeSniffer.php";
     require_once $this->mooshDir . "/includes/codesniffer/lib.php";
     require_once $this->mooshDir . "/includes/coderepair/CodeRepair.php";
     $moodle_sniffs = $this->mooshDir . "/includes/codesniffer/moodle";
     $options = $this->expandedOptions;
     $interactive = $options['interactive'];
     if (isset($options['path'])) {
         $this->checkFileArg($options['path']);
         $path = $options['path'];
     } else {
         $path = $this->cwd;
     }
     $files = $this->_get_files($path);
     if ($options['repair'] === true) {
         $code_repair = new \CodeRepair($files);
         $code_repair->drymode = false;
         $code_repair->start();
     }
     $phpcs = new \PHP_CodeSniffer(1, 0, 'utf-8', false);
     $phpcs->setCli(new \codesniffer_cli());
     $numerrors = $phpcs->process($files, $moodle_sniffs);
     $phpcs->reporting->printReport('full', false, null);
 }
开发者ID:dariogs,项目名称:moosh,代码行数:25,代码来源:ToolsCodeCheck.php

示例8: runTest

 /**
  * Tests the extending classes Sniff class.
  *
  * @return void
  * @throws PHPUnit_Framework_Error
  */
 protected final function runTest()
 {
     // Skip this test if we can't run in this environment.
     if ($this->shouldSkipTest() === true) {
         $this->markTestSkipped();
     }
     // The basis for determining file locations.
     $basename = substr(get_class($this), 0, -8);
     // The name of the coding standard we are testing.
     $standardName = substr($basename, 0, strpos($basename, '_'));
     // The class name of the sniff we are testing.
     $sniffClass = str_replace('_Tests_', '_Sniffs_', $basename) . 'Sniff';
     if (is_file(dirname(__FILE__) . '/../../CodeSniffer.php') === true) {
         // We have not been installed.
         $standardsDir = realpath(dirname(__FILE__) . '/../../CodeSniffer/Standards');
         $testFileBase = $standardsDir . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $basename) . 'UnitTest.';
     } else {
         // The name of the dummy file we are testing.
         $testFileBase = dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $basename) . 'UnitTest.';
     }
     // Get a list of all test files to check. These will have the same base
     // name but different extensions. We ignore the .php file as it is the
     // class.
     $testFiles = array();
     $dir = substr($testFileBase, 0, strrpos($testFileBase, DIRECTORY_SEPARATOR));
     $di = new DirectoryIterator($dir);
     foreach ($di as $file) {
         $path = $file->getPathname();
         if (substr($path, 0, strlen($testFileBase)) === $testFileBase) {
             if ($path !== $testFileBase . 'php') {
                 $testFiles[] = $path;
             }
         }
     }
     // Get them in order.
     sort($testFiles);
     self::$phpcs->process(array(), $standardName, array($sniffClass));
     self::$phpcs->setIgnorePatterns(array());
     $failureMessages = array();
     foreach ($testFiles as $testFile) {
         try {
             self::$phpcs->processFile($testFile);
         } catch (Exception $e) {
             $this->fail('An unexpected exception has been caught: ' . $e->getMessage());
         }
         $files = self::$phpcs->getFiles();
         if (empty($files) === true) {
             // File was skipped for some reason.
             echo "Skipped: {$testFile}\n";
             $this->markTestSkipped();
         }
         $file = array_pop($files);
         $failures = $this->generateFailureMessages($file);
         $failureMessages = array_merge($failureMessages, $failures);
     }
     //end foreach
     if (empty($failureMessages) === false) {
         $this->fail(implode(PHP_EOL, $failureMessages));
     }
 }
开发者ID:austinpapp,项目名称:push-notifications-temp,代码行数:66,代码来源:AbstractSniffUnitTest.php

示例9: it_generates_the_expected_warnings_and_errors

 /**
  * @test
  * @dataProvider fixturesProvider
  */
 public function it_generates_the_expected_warnings_and_errors($file, array $expectedErrors, array $expectedWarnings)
 {
     $codeSniffer = new \PHP_CodeSniffer();
     $codeSniffer->process(array(), $this->getRulesetXmlPath(), array($this->getRuleName()));
     $sniffedFile = $codeSniffer->processFile($file);
     $this->fileHasExpectedErrors($sniffedFile, $expectedErrors);
     $this->fileHasExpectedWarnings($sniffedFile, $expectedWarnings);
 }
开发者ID:matthiasnoback,项目名称:php-coding-standard,代码行数:12,代码来源:AbstractSniffTest.php

示例10: executeOnPHPFile

 protected function executeOnPHPFile(File $file)
 {
     $code_sniffer = new \PHP_CodeSniffer($this->phpcs_verbosity, $this->phpcs_tab_width, $this->phpcs_encoding, self::PHPCS_NOT_INTERACTIVE_MODE);
     //Load the standard
     $code_sniffer->process(array(), $this->standard, array());
     $file_result = $code_sniffer->processFile($file->getPath(), $file->getContent());
     if ($file_result->getErrorCount()) {
         $this->handlePHPCSErrors($file, $file_result);
     }
 }
开发者ID:polishdeveloper,项目名称:stark,代码行数:10,代码来源:PHPCS.php

示例11: getCodeSniffer

 /**
  * Create PHP_CodeSniffer instance
  *
  * @param array $restrictions Restrictions
  *
  * @return \PHP_CodeSniffer
  */
 protected function getCodeSniffer(array $restrictions)
 {
     $codeSniffer = new \PHP_CodeSniffer();
     $codeSniffer->cli->setCommandLineValues(array("--report=summary"));
     $infoReporting = $codeSniffer->reporting->factory("summary");
     /** @var \PHP_CodeSniffer_Reports_Info $infoReporting */
     $infoReporting->recordErrors = true;
     $codeSniffer->process(array(), __DIR__ . "/..", $restrictions);
     $codeSniffer->setIgnorePatterns(array());
     return $codeSniffer;
 }
开发者ID:apnet,项目名称:coding-standard,代码行数:18,代码来源:CodeSnifferTestCase.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->outputHeading($output, 'Moodle Code Checker on %s');
     $files = $this->plugin->getFiles($this->finder);
     if (count($files) === 0) {
         return $this->outputSkip($output);
     }
     $sniffer = new \PHP_CodeSniffer();
     $sniffer->setCli(new CodeSnifferCLI(['reports' => ['full' => null], 'colors' => true, 'encoding' => 'utf-8', 'showProgress' => true, 'reportWidth' => 120]));
     $sniffer->process($files, $this->standard);
     $results = $sniffer->reporting->printReport('full', false, $sniffer->cli->getCommandLineValues(), null, 120);
     return $results['errors'] > 0 ? 1 : 0;
 }
开发者ID:gjb2048,项目名称:moodle-plugin-ci,代码行数:13,代码来源:CodeCheckerCommand.php

示例13: runTest

 /**
  * Tests the extending classes Sniff class.
  *
  * @return void
  * @throws PHPUnit_Framework_Error
  * @test
  */
 public final function runTest()
 {
     self::$_phpcs->process([], 'DWS', [$this->_getSniffName()]);
     self::$_phpcs->setIgnorePatterns([]);
     $testFile = dirname(__DIR__) . '/tests/' . str_replace('_', '/', get_class($this)) . '.inc';
     if (!file_exists($testFile)) {
         $this->markTestSkipped();
         return;
     }
     try {
         self::$_phpcs->processFile($testFile);
     } catch (Exception $e) {
         $this->fail("An unexpected exception has been caught: {$e->getMessage()}");
     }
     $files = self::$_phpcs->getFiles();
     if ($files === []) {
         echo "Skipped: {$testFile}\n";
         $this->markTestSkipped();
     }
     $failureMessages = $this->generateFailureMessages($files[0]);
     if (count($failureMessages) > 0) {
         $this->fail(implode("\n", $failureMessages));
     }
 }
开发者ID:ezzy1337,项目名称:dws-coding-standard,代码行数:31,代码来源:AbstractSniffUnitTest.php

示例14: testSniff

 /**
  * Tests the extending classes Sniff class.
  */
 public final function testSniff()
 {
     // Skip this test if we can't run in this environment.
     if ($this->shouldSkipTest() === true) {
         $this->markTestSkipped();
     }
     $testFiles = $this->getTestFiles();
     $sniffCodes = $this->getSniffCodes();
     self::$phpcs->process(array(), 'coder_sniffer/Drupal', $sniffCodes);
     $failureMessages = array();
     foreach ($testFiles as $testFile) {
         try {
             $phpcsFile = self::$phpcs->processFile($testFile);
         } catch (Exception $e) {
             $this->fail('An unexpected exception has been caught: ' . $e->getMessage());
         }
         $failures = $this->generateFailureMessages($phpcsFile);
         $failureMessages = array_merge($failureMessages, $failures);
     }
     //end foreach
     if (empty($failureMessages) === false) {
         $this->fail(implode(PHP_EOL, $failureMessages));
     }
 }
开发者ID:MODCDE,项目名称:CDE_SS,代码行数:27,代码来源:CoderSniffUnitTest.php

示例15: run

 /**
  * Run the task.
  *
  * @param array &$options Additional options.
  *
  * @return integer Number of errors.
  */
 public function run(&$options)
 {
     $old_dir = getcwd();
     $lib = realpath($this->_config->getPath() . '/lib');
     $argv = $_SERVER['argv'];
     $argc = $_SERVER['argv'];
     $_SERVER['argv'] = array();
     $_SERVER['argc'] = 0;
     define('PHPCS_DEFAULT_WARN_SEV', 0);
     $phpcs = new PHP_CodeSniffer();
     $phpcs->process($lib, Components_Constants::getDataDirectory() . '/qc_standards/phpcs.xml');
     $_SERVER['argv'] = $argv;
     $_SERVER['argc'] = $argc;
     chdir($old_dir);
     return $phpcs->reporting->printReport('emacs', false, null);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:23,代码来源:Cs.php


注:本文中的PHP_CodeSniffer::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。