PHP Classes

File: Library/vendor/phpdocumentor/reflection-docblock/examples/playing-with-descriptions/02-escaping.php

Recommend this page to a friend!
  Classes of Duong Huynh Nghia   Lego PHP   Library/vendor/phpdocumentor/reflection-docblock/examples/playing-with-descriptions/02-escaping.php   Download  
File: Library/vendor/phpdocumentor/reflection-docblock/examples/playing-with-descriptions/02-escaping.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Lego PHP
Blog and shopping cart system
Author: By
Last change:
Date: 7 years ago
Size: 1,737 bytes
 

Contents

Class file image Download
<?php

require_once(__DIR__ . '/../../vendor/autoload.php');

use
phpDocumentor\Reflection\DocBlockFactory;

$docComment = <<<DOCCOMMENT
/**
 * This is an example of a summary.
 *
 * You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
 * inline tag by adding an opening brace in front of it like this: {}.
 *
 * Here are example texts where you can see how they could be used in a real life situation:
 *
 * This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
 * Or an {@internal inline tag with a literal {{@}link{} in it}.
 *
 * Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
 */
DOCCOMMENT;

$factory = DocBlockFactory::createInstance();
$docblock = $factory->create($docComment);

// Escaping is automatic so this happens in the DescriptionFactory.
$description = $docblock->getDescription();

// This is the rendition that we will receive of the Description.
$receivedDocComment = <<<DOCCOMMENT
/**
 * This is an example of a summary.
 *
 * You can escape the @-sign by surrounding it with braces, for example: {@}. And escape a closing brace within an
 * inline tag by adding an opening brace in front of it like this: {}.
 *
 * Here are example texts where you can see how they could be used in a real life situation:
 *
 * This is a text with an {@internal inline tag where a closing brace ({}) is shown}.
 * Or an {@internal inline tag with a literal {{@}link{} in it}.
 *
 * Do note that an {@internal inline tag that has an opening brace ({) does not break out}.
 */
DOCCOMMENT;

// Render it using the default PassthroughFormatter
$foundDescription = $description->render();