Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/atomizer/DivinerPHPAtomizer.php
| Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | private function parseParams(DivinerAtom $atom, AASTNode $func) { | ||||
| } else { | } else { | ||||
| $docs = array(); | $docs = array(); | ||||
| } | } | ||||
| if (count($docs)) { | if (count($docs)) { | ||||
| if (count($docs) < count($params)) { | if (count($docs) < count($params)) { | ||||
| $atom->addWarning( | $atom->addWarning( | ||||
| pht( | pht( | ||||
| 'This call takes %d parameters, but only %d are documented.', | 'This call takes %s parameter(s), but only %s are documented.', | ||||
| count($params), | new PhutilNumber(count($params)), | ||||
| count($docs))); | new PhutilNumber(count($docs)))); | ||||
| } | } | ||||
| } | } | ||||
| foreach ($params as $param) { | foreach ($params as $param) { | ||||
| $name = $param->getChildByIndex(1)->getConcreteString(); | $name = $param->getChildByIndex(1)->getConcreteString(); | ||||
| $dict = array( | $dict = array( | ||||
| 'type' => $param->getChildByIndex(0)->getConcreteString(), | 'type' => $param->getChildByIndex(0)->getConcreteString(), | ||||
| 'default' => $param->getChildByIndex(2)->getConcreteString(), | 'default' => $param->getChildByIndex(2)->getConcreteString(), | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if ($token) { | ||||
| } | } | ||||
| if ($prev && $prev->isComment()) { | if ($prev && $prev->isComment()) { | ||||
| $value = $prev->getValue(); | $value = $prev->getValue(); | ||||
| $matches = null; | $matches = null; | ||||
| if (preg_match('/@(return|param|task|author)/', $value, $matches)) { | if (preg_match('/@(return|param|task|author)/', $value, $matches)) { | ||||
| $atom->addWarning( | $atom->addWarning( | ||||
| pht( | pht( | ||||
| 'Atom "%s" is preceded by a comment containing "@%s", but the '. | 'Atom "%s" is preceded by a comment containing `%s`, but '. | ||||
| 'comment is not a documentation comment. Documentation '. | 'the comment is not a documentation comment. Documentation '. | ||||
| 'comments must begin with "%s", followed by a newline. Did '. | 'comments must begin with `%s`, followed by a newline. Did '. | ||||
| 'you mean to use a documentation comment? (As the comment is '. | 'you mean to use a documentation comment? (As the comment is '. | ||||
| 'not a documentation comment, it will be ignored.)', | 'not a documentation comment, it will be ignored.)', | ||||
| $atom->getName(), | $atom->getName(), | ||||
| $matches[1], | '@'.$matches[1], | ||||
| '/**')); | '/**')); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $atom->setDocblockRaw(''); | $atom->setDocblockRaw(''); | ||||
| return false; | return false; | ||||
| } | } | ||||
| Show All 13 Lines | if (!empty($split[1])) { | ||||
| // get rid of the `$num` part (which Diviner considers optional). If it | // get rid of the `$num` part (which Diviner considers optional). If it | ||||
| // is present and different from the declared name, raise a warning. | // is present and different from the declared name, raise a warning. | ||||
| $matches = null; | $matches = null; | ||||
| if (preg_match('/^(\\$\S+)\s+/', $docs, $matches)) { | if (preg_match('/^(\\$\S+)\s+/', $docs, $matches)) { | ||||
| if ($name !== null) { | if ($name !== null) { | ||||
| if ($matches[1] !== $name) { | if ($matches[1] !== $name) { | ||||
| $atom->addWarning( | $atom->addWarning( | ||||
| pht( | pht( | ||||
| 'Parameter "%s" is named "%s" in the documentation. The '. | 'Parameter "%s" is named "%s" in the documentation. '. | ||||
| 'documentation may be out of date.', | 'The documentation may be out of date.', | ||||
| $name, | $name, | ||||
| $matches[1])); | $matches[1])); | ||||
| } | } | ||||
| } | } | ||||
| $docs = substr($docs, strlen($matches[0])); | $docs = substr($docs, strlen($matches[0])); | ||||
| } | } | ||||
| $dict['docs'] = $docs; | $dict['docs'] = $docs; | ||||
| Show All 26 Lines | if ($atom->getName() == '__construct' && $atom->getType() == 'method') { | ||||
| $return_spec = array( | $return_spec = array( | ||||
| 'doctype' => 'this', | 'doctype' => 'this', | ||||
| 'docs' => '//Implicit.//', | 'docs' => '//Implicit.//', | ||||
| ); | ); | ||||
| if ($return) { | if ($return) { | ||||
| $atom->addWarning( | $atom->addWarning( | ||||
| pht( | pht( | ||||
| 'Method %s has explicitly documented %s. The %s method always '. | 'Method `%s` has explicitly documented `%s`. The `%s` method '. | ||||
| 'returns %s. Diviner documents this implicitly.', | 'always returns `%s`. Diviner documents this implicitly.', | ||||
| '__construct()', | '__construct()', | ||||
| '@return', | '@return', | ||||
| '__construct()', | '__construct()', | ||||
| '$this')); | '$this')); | ||||
| } | } | ||||
| } else if ($return) { | } else if ($return) { | ||||
| $split = preg_split('/(?<!,)\s+/', trim($return), 2); | $split = preg_split('/(?<!,)\s+/', trim($return), 2); | ||||
| if (!empty($split[0])) { | if (!empty($split[0])) { | ||||
| Show All 25 Lines | |||||