googlearchive / code-prettify

An embeddable script that makes source-code snippets in HTML prettier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docblock highlighting in PHP sometimes doesn't work

filips123 opened this issue · comments

Docblock highlighting in PHP sometimes doesn't work.

Highlighting works:

<?php

### OTHER CODE ###

/**
 * Call middleware stack
 *
 * @param  ServerRequestInterface $request A request object
 * @param  ResponseInterface      $response A response object
 *
 * @return ResponseInterface
 */
public function callMiddlewareStack(ServerRequestInterface $request, ResponseInterface $response)
{
    if (is_null($this->tip)) {
        $this->seedMiddlewareStack();
    }
    /** @var callable $start */
    $start = $this->tip;
    $this->middlewareLock = true;
    $response = $start($request, $response);
    $this->middlewareLock = false;
    return $response;
}

### OTHER CODE ###

highlighting-works

Highlighting also works:

<?php

### OTHER CODE ###

/**
 * Run route
 *
 * This method traverses the middleware stack, including the route's callable
 * and captures the resultant HTTP response object. It then sends the response
 * back to the Application.
 *
 * @param ServerRequestInterface $request
 * @param ResponseInterface      $response
 *
 * @return ResponseInterface
 */
public function run(ServerRequestInterface $request, ResponseInterface $response)
{
    // Finalise route now that we are about to run it
    $this->finalize();

    // Traverse middleware stack and fetch updated response
    return $this->callMiddlewareStack($request, $response);
}

### OTHER CODE ###

highlighting-also-works

Highlighting doesn't work:

<?php

### OTHER CODE ###

/**
 * Invoke a route callable with request, response, and all route parameters
 * as an array of arguments.
 *
 * @param array|callable         $callable
 * @param ServerRequestInterface $request
 * @param ResponseInterface      $response
 * @param array                  $routeArguments
 *
 * @return mixed
 */
public function __invoke(
    callable $callable,
    ServerRequestInterface $request,
    ResponseInterface $response,
    array $routeArguments
) {
    foreach ($routeArguments as $k => $v) {
        $request = $request->withAttribute($k, $v);
    }

    return call_user_func($callable, $request, $response, $routeArguments);
}

### OTHER CODE ###

highlighting-doesnt-work

I am using Whoops error handler for PHP which uses Prettify for highlighting.
Maybe the problem is that docblock is not complete and only section of it is displayed.

commented

Maybe the problem is that docblock is not complete and only section of it is displayed.

if that's the case then yeah; when you cut in the middle, the start of the comment block /* is not seen therefore section is not marked as comment.

This seems like an issue in the Whoops framework not code-prettify.