當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。