예제 #1
0
 /**
  * Returns derivative method by name
  *
  * @param string $fullMethodName Full name of method
  * @param bool   $throwException Throw exception or return null
  *
  * @return Method|null          Method model, or =null if not found ($throwException = false)
  * @throws \Exception           If specified method not found ($throwException = true)
  */
 function getDerivativeMethodByName($fullMethodName, $throwException = false)
 {
     if ($method = Helper::value($this->derivativeMethods, $fullMethodName)) {
         return $method;
     } else {
         if ($throwException) {
             $this::throwException('[Method = "' . $this->name . '"] Not found derivative method with name = ' . $fullMethodName);
         } else {
             return null;
         }
     }
 }
예제 #2
0
 /**
  * Returns parsed method by basename
  *
  * @param string $methodBaseName basename of method (case insensitive)
  *
  * @return Method|null  Found model of method. If not found, returns =null.
  */
 function getMethodByBaseName($methodBaseName)
 {
     return Helper::value($this->getParsedMethods(), strtolower($methodBaseName));
 }
 /**
  * Returns arguments description for DocBlock of specified method
  *
  * @param Method $method
  *
  * @return string           Parts of DocBlock of specified method
  */
 protected function phpDocArguments(Method $method)
 {
     $phpDoc = [];
     // type + name of argument
     $maxLength = 0;
     foreach ($method->arguments as $argument) {
         $phpDoc[$argument->name] = '@param ' . $argument->type . '   $' . $argument->name . '  ';
         $maxLength = max($maxLength, strlen($phpDoc[$argument->name]));
     }
     // html link replace pairs
     $linkReplaces = ['locators' => '(see ' . static::linkToProperty('doc_Element_Locators', '', 'Element Locators') . ')', 'patterns' => '(see ' . static::linkToProperty('doc_String_match_Patterns', '', 'String match Patterns') . ')', 'storedVars' => '(see ' . static::linkToProperty('doc_Stored_Variables', '', 'Stored Variables') . ')'];
     // add formatted description for arguments (aligned for all arguments)
     $descriptionLength = self::DOC_BLOCK_WIDTH - $maxLength;
     $firstSpaces = str_repeat(' ', $maxLength);
     foreach ($method->arguments as $argument) {
         $argDescription = $argument->description === null ? Helper::value($this->manualArgumentDescription(), $argument->name, '') : $argument->description;
         // trace, if empty description
         if (!trim($argDescription)) {
             echo 'Warning [method = ' . $method->name . ']: argument has no description. Problem argument:' . $argument->name . Helper::EOL;
         }
         // direct replaces
         if ($argument->name === 'locator' && $argDescription === 'an element locator') {
             $argDescription = 'an <a href="#locators">element locator</a>';
         }
         // replace html link tags
         foreach ($linkReplaces as $linkHash => $linkPhpDoc) {
             $regExp = '/<a href="#' . $linkHash . '">([\\w ]+)<\\/a>/';
             if (preg_match($regExp, $argDescription)) {
                 $argDescription = preg_replace($regExp, '$1', $argDescription) . ' ' . $linkPhpDoc;
             }
         }
         $argDescription = Helper::formatAsHtml($argDescription);
         $argDescription = $this->_wordWrap($argDescription, $descriptionLength, Helper::EOL);
         $argDescription = $this->_fixPhpDocLinks($argDescription);
         $argDescription = trim($this->_addInLineBeginning($argDescription, $firstSpaces));
         $phpDoc[$argument->name] = str_pad($phpDoc[$argument->name], $maxLength) . $argDescription;
     }
     return join(Helper::EOL, $phpDoc);
 }