/**
  * Process the subpackage tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $package = $this->commentParser->getSubpackage();
     if ($package !== null) {
         $content = $package->getContent();
         if ($content !== '') {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 $newContent = str_replace(' ', '_', $content);
                 $nameBits = explode('_', $newContent);
                 $firstBit = array_shift($nameBits);
                 $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                 foreach ($nameBits as $bit) {
                     $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $error = 'Subpackage name "%s" is not valid; consider "%s" instead';
                 $validName = trim($newName, '_');
                 $data = array($content, $validName);
                 $this->currentFile->addError($error, $errorPos, 'InvalidSubpackage', $data);
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->currentFile->addError($error, $errorPos, 'EmptySubpackage');
         }
     }
 }
Example #2
0
 /**
  * The subpackage name must be camel-cased.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $subpackage = $this->commentParser->getSubpackage();
     if ($subpackage !== null) {
         $content = $subpackage->getContent();
         if (empty($content) === true) {
             $error = 'Content missing for @subpackage tag in file comment';
             $this->currentFile->addError($error, $errorPos);
         } else {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 // Subpackage name must be properly camel-cased.
                 $nameBits = explode('_', $content);
                 $firstBit = array_shift($nameBits);
                 $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                 foreach ($nameBits as $bit) {
                     $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $validName = trim($newName, '_');
                 $error = "Subpackage name \"{$content}\" is not valid; ";
                 $error .= "consider \"{$validName}\" instead";
                 $this->currentFile->addError($error, $errorPos);
             }
         }
     }
 }
Example #3
0
	/**
	 * Process the subpackage tag.
	 *
	 * @param int $errorPos The line number where the error occurs.
	 *
	 * @return void
	 */
	protected function processSubpackage($errorPos)
	{
		$package = $this->commentParser->getSubpackage();
		if ($package !== null) {
			$content = $package->getContent();
			if ($content !== '') {
				if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
					// Ignore..
				}
			} else {
				$error = '@subpackage tag must contain a name';
				$this->currentFile->addError($error, $errorPos);
			}
		}

	}//end processSubpackage()
Example #4
0
 /**
  * Process the subpackage tag.
  *
  * @param int $errorPos The line number where the error occurs.
  *
  * @return void
  */
 protected function processSubpackage($errorPos)
 {
     $tag = $this->commentParser->getSubpackage();
     if ($tag !== null) {
         $content = $tag->getContent();
         if ($content !== '') {
             list($isValid, $validName) = $this->checkSubpackage($content);
             if (!$isValid) {
                 $error = "Subpackage name \"{$content}\" is not valid; consider \"{$validName}\" instead";
                 $this->currentFile->addError($this->getReqPrefix($this->getReqCode($this->reqCodesWrongFormat, 'subpackage')) . $error, $errorPos);
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->currentFile->addError($this->getReqPrefix($this->reqCodeEmpty) . $error, $errorPos);
         }
     }
 }
Example #5
0
 /**
  * Process the subpackage tag.
  *
  * @param int $errorpos The line number where the error occurs.
  *
  * @return void
  */
 protected function processsubpackage($errorpos)
 {
     $package = $this->commentparser->getSubpackage();
     if ($package !== null) {
         $content = $package->getcontent();
         if ($content !== '') {
             if (PHP_CodeSniffer::isUnderscorename($content) !== true) {
                 $newcontent = str_replace(' ', '_', $content);
                 $namebits = explode('_', $newcontent);
                 $firstbit = array_shift($namebits);
                 $newname = strtoupper($firstbit[0]) . substr($firstbit, 1) . '_';
                 foreach ($namebits as $bit) {
                     $newname .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $validname = trim($newname, '_');
                 $error = "Subpackage name \"{$content}\" is not valid; consider \"{$validname}\" instead";
                 // $this->currentfile->adderror($error, $errorpos);
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->currentfile->adderror($error, $errorpos);
         }
     }
 }
 /**
  * Process the subpackage tag
  *
  * @param  integer $errorPos The line number where the error occurs
  * @return void
  */
 protected function _processSubpackage($errorPos)
 {
     $package = $this->_commentParser->getSubpackage();
     if ($package !== null) {
         $content = $package->getContent();
         if ($content !== '') {
             if (PHP_CodeSniffer::isUnderscoreName($content) !== true) {
                 $newContent = str_replace(' ', '_', $content);
                 $nameBits = explode('_', $newContent);
                 $firstBit = array_shift($nameBits);
                 $newName = strtoupper($firstBit[0]) . substr($firstBit, 1) . '_';
                 foreach ($nameBits as $bit) {
                     $newName .= strtoupper($bit[0]) . substr($bit, 1) . '_';
                 }
                 $validName = trim($newName, '_');
                 $error = "Subpackage name \"{$content}\" is not valid; consider \"{$validName}\" instead";
                 $this->_currentFile->addError($error, $errorPos, 'SubPackageNameFileComment');
             }
         } else {
             $error = '@subpackage tag must contain a name';
             $this->_currentFile->addError($error, $errorPos, 'SubTagMustContainNameFileComment');
         }
     }
 }