Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Adapt to HHVM and HHAST 4.14
Browse files Browse the repository at this point in the history
  • Loading branch information
fredemmott committed Jul 17, 2019
1 parent c5f101a commit 1e88409
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: required
language: generic
services: docker
env:
- HHVM_VERSION=4.8-latest
- HHVM_VERSION=4.14-latest
- HHVM_VERSION=latest
- HHVM_VERSION=nightly
install:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"bin": [ "bin/hh-apidoc", "bin/hh-apidoc.hack" ],
"license": "MIT",
"require": {
"hhvm": "^4.8",
"hhvm": "^4.14",
"hhvm/hsl": "^4.0",
"facebook/fbmarkdown": "^1.0",
"facebook/hh-clilib": "^2.1.0",
"facebook/definition-finder": "^2.0.0",
"hhvm/hhast": "^4.8"
"hhvm/hhast": "^4.14"
},
"require-dev": {
"hhvm/hhvm-autoload": "^2.0"
Expand Down
6 changes: 3 additions & 3 deletions src/MarkdownExt/AutoLinkifyFilter.hack
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class AutoLinkifyFilter extends Markdown\RenderFilter {
Markdown\RenderContext $context,
Markdown\ASTNode $node,
): vec<Markdown\ASTNode> {
if (!$node instanceof CodeSpan) {
if (!$node is CodeSpan) {
return vec[$node];
}

Expand All @@ -55,7 +55,7 @@ final class AutoLinkifyFilter extends Markdown\RenderFilter {
}

invariant(
$context instanceof RenderContext,
$context is RenderContext,
'Expected render context to be a %s',
RenderContext::class,
);
Expand Down Expand Up @@ -129,7 +129,7 @@ final class AutoLinkifyFilter extends Markdown\RenderFilter {
}

$def = $context->getDocumentable()['definition'];
if ($def instanceof ScannedClassish) {
if ($def is ScannedClassish) {
$path = self::getPathForMethod($context, $def->getName(), $search);
if ($path !== null) {
return $path;
Expand Down
10 changes: 3 additions & 7 deletions src/MarkdownExt/SyntaxHighlightingFilter.hack
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ final class SyntaxHighlightingFilter extends Markdown\RenderFilter {
Markdown\RenderContext $context,
Markdown\ASTNode $node,
): vec<Markdown\ASTNode> {
if (!$node instanceof CodeBlock) {
if (!$node is CodeBlock) {
return vec[$node];
}
if ($context instanceof namespace\RenderContext) {
if ($context is namespace\RenderContext) {
if ($context->getOutputFormat() !== OutputFormat::HTML) {
return vec[$node];
}
Expand Down Expand Up @@ -65,10 +65,6 @@ final class SyntaxHighlightingFilter extends Markdown\RenderFilter {

/** Convert an HHAST FFP AST node into an HTML string. */
protected static function getHTML(HHAST\Node $node): string {
if ($node instanceof HHAST\Missing) {
return '';
}

if ($node->isTrivia() || $node->isToken()) {
$inner = \htmlspecialchars($node->getCode());
} else {
Expand All @@ -77,7 +73,7 @@ final class SyntaxHighlightingFilter extends Markdown\RenderFilter {
|> Str\join($$, '');
}

if ($node instanceof HHAST\NodeList ) {
if ($node is HHAST\NodeList<_> ) {
return $inner;
}

Expand Down
2 changes: 1 addition & 1 deletion src/PageSections/FunctionishParameters.hack
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class FunctionishParameters extends PageSection {
<<__Override>>
public function getMarkdown(): ?string {
$f = $this->definition;
if (!$f instanceof ScannedFunctionish) {
if (!$f is ScannedFunctionish) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/PageSections/FunctionishReturnValues.hack
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class FunctionishReturnValues extends PageSection {
<<__Override>>
public function getMarkdown(): ?string {
$f = $this->definition;
if (!$f instanceof ScannedFunctionish) {
if (!$f is ScannedFunctionish) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/PageSections/FunctionishSignature.hack
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class FunctionishSignature extends PageSection {
<<__Override>>
public function getMarkdown(): ?string {
$f = $this->definition;
if (!$f instanceof ScannedFunctionish) {
if (!$f is ScannedFunctionish) {
return null;
}

Expand Down
14 changes: 7 additions & 7 deletions src/PageSections/InterfaceSynopsis.hack
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class InterfaceSynopsis extends PageSection {
<<__Override>>
public function getMarkdown(): ?string {
$c = $this->definition;
if (!$c instanceof ScannedClassish) {
if (!$c is ScannedClassish) {
return null;
}

Expand Down Expand Up @@ -104,13 +104,13 @@ final class InterfaceSynopsis extends PageSection {
ScannedMethod $m,
): ?string {
$pp = $this->context->getPathProvider();
if ($c instanceof ScannedClass) {
if ($c is ScannedClass) {
return $pp->getPathForClassMethod($c->getName(), $m->getName());
}
if ($c instanceof ScannedInterface) {
if ($c is ScannedInterface) {
return $pp->getPathForInterfaceMethod($c->getName(), $m->getName());
}
if ($c instanceof ScannedTrait) {
if ($c is ScannedTrait) {
return $pp->getPathForTraitMethod($c->getName(), $m->getName());
}
invariant_violation("Don't know how to handle type %s", \get_class($c));
Expand All @@ -131,11 +131,11 @@ final class InterfaceSynopsis extends PageSection {
$ret .= 'final ';
}

if ($c instanceof ScannedClass) {
if ($c is ScannedClass) {
$ret .= 'class ';
} else if ($c instanceof ScannedInterface) {
} else if ($c is ScannedInterface) {
$ret .= 'interface ';
} else if ($c instanceof ScannedTrait) {
} else if ($c is ScannedTrait) {
$ret .= 'trait ';
} else {
invariant_violation("Don't know what a %s is.", \get_class($c));
Expand Down
2 changes: 1 addition & 1 deletion src/PageSections/NameHeading.hack
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class NameHeading extends PageSection {
$def = $this->definition;
$md .= $def->getName();

if ($def instanceof ScannedFunctionish) {
if ($def is ScannedFunctionish) {
$md .= '()';
}

Expand Down
2 changes: 1 addition & 1 deletion src/PageSections/ShapeFields.hack
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class ShapeFields extends PageSection {
public function getMarkdown(): ?string {
$t = $this->definition;
// Intentionally not documenting opaque type aliases
if (!$t instanceof ScannedType) {
if (!$t is ScannedType) {
return null;
}
$t = $t->getAliasedType();
Expand Down
6 changes: 3 additions & 3 deletions src/PageSections/TypeDeclaration.hack
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class TypeDeclaration extends PageSection {
<<__Override>>
public function getMarkdown(): ?string {
$t = $this->definition;
if (!$t instanceof ScannedTypeish) {
if (!$t is ScannedTypeish) {
return null;
}
return $this->getTypeDeclaration($t);
Expand All @@ -34,15 +34,15 @@ final class TypeDeclaration extends PageSection {
$code .= 'namespace '.$ns.";\n\n";
}

if ($t instanceof ScannedType) {
if ($t is ScannedType) {
$code .= 'type ';
} else {
$code .= 'newtype ';
}

$code .= _Private\ns_normalize_type($ns, $t->getName());

if ($t instanceof ScannedType) {
if ($t is ScannedType) {
$code .= ' = '.
_Private\stringify_typehint(
$t->getNamespaceName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function stringify_functionish_signature(
$name = $function->getName();
}

if ($function instanceof ScannedMethod) {
if ($function is ScannedMethod) {
if ($function->isAbstract()) {
$ret .= 'abstract ';
}
Expand Down
20 changes: 10 additions & 10 deletions src/create_index.hack
Original file line number Diff line number Diff line change
Expand Up @@ -38,61 +38,61 @@ function create_index(
$def = $what['definition'];
$name = $def->getName();

if ($def instanceof ScannedFunction) {
if ($def is ScannedFunction) {
$index['functions'][] = $name;
continue;
}
if ($def instanceof ScannedType) {
if ($def is ScannedType) {
$index['types'][] = $name;
continue;
}
if ($def instanceof ScannedNewtype) {
if ($def is ScannedNewtype) {
$index['newtypes'][] = $name;
continue;
}
if ($def instanceof ScannedClass) {
if ($def is ScannedClass) {
if (!C\contains_key($index['classes'], $name)) {
$index['classes'][$def->getName()] = keyset[];
}
continue;
}
if ($def instanceof ScannedInterface) {
if ($def is ScannedInterface) {
if (!C\contains_key($index['interfaces'], $name)) {
$index['interfaces'][$def->getName()] = keyset[];
}
continue;
}
if ($def instanceof ScannedTrait) {
if ($def is ScannedTrait) {
if (!C\contains_key($index['traits'], $name)) {
$index['traits'][$def->getName()] = keyset[];
}
continue;
}

invariant(
$def instanceof ScannedMethod,
$def is ScannedMethod,
"Can't handle class %s",
\get_class($def),
);

$p = $what['parent'];
invariant($p !== null, 'got a method with null parent');
$pn = $p->getName();
if ($p instanceof ScannedClass) {
if ($p is ScannedClass) {
if (!C\contains_key($index['classes'], $pn)) {
$index['classes'][$pn] = keyset[];
}
$index['classes'][$pn][] = $name;
continue;
}
if ($p instanceof ScannedInterface) {
if ($p is ScannedInterface) {
if (!C\contains_key($index['interfaces'], $pn)) {
$index['interfaces'][$pn] = keyset[];
}
$index['interfaces'][$pn][] = $name;
continue;
}
if ($p instanceof ScannedTrait) {
if ($p is ScannedTrait) {
if (!C\contains_key($index['traits'], $pn)) {
$index['traits'][$pn] = keyset[];
}
Expand Down
2 changes: 1 addition & 1 deletion src/from_parser.hack
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function from_parser(BaseParser $parser): vec<Documentable> {
$top_level,
$data ==> {
$class = $data['definition'];
if (!$class instanceof ScannedClassish) {
if (!$class is ScannedClassish) {
return vec[];
}

Expand Down
20 changes: 10 additions & 10 deletions src/get_path_for_documentable.hack
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@ function get_path_for_documentable(
Documentable $what,
): ?string {
$def = $what['definition'];
if ($def instanceof ScannedClass) {
if ($def is ScannedClass) {
return $provider->getPathForClass($def->getName());
}
if ($def instanceof ScannedInterface) {
if ($def is ScannedInterface) {
return $provider->getPathForInterface($def->getName());
}
if ($def instanceof ScannedTrait) {
if ($def is ScannedTrait) {
return $provider->getPathForTrait($def->getName());
}
if ($def instanceof ScannedFunction) {
if ($def is ScannedFunction) {
return $provider->getPathForFunction($def->getName());
}
if ($def instanceof ScannedType) {
if ($def is ScannedType) {
return $provider->getPathForTransparentTypeAlias($def->getName());
}
if ($def instanceof ScannedNewtype) {
if ($def is ScannedNewtype) {
return $provider->getPathForOpaqueTypeAlias($def->getName());
}
if ($def instanceof ScannedMethod) {
if ($def is ScannedMethod) {
$p = $what['parent'];
if ($p instanceof ScannedClass) {
if ($p is ScannedClass) {
return $provider->getPathForClassMethod($p->getName(), $def->getName());
}
if ($p instanceof ScannedInterface) {
if ($p is ScannedInterface) {
return
$provider->getPathForInterfaceMethod($p->getName(), $def->getName());
}
if ($p instanceof ScannedTrait) {
if ($p is ScannedTrait) {
return $provider->getPathForTraitMethod($p->getName(), $def->getName());
}
}
Expand Down

0 comments on commit 1e88409

Please sign in to comment.