Skip to content

Instantly share code, notes, and snippets.

@olvlvl
Created February 6, 2015 09:49
Show Gist options
  • Save olvlvl/7788d6bd8a4e172bbc92 to your computer and use it in GitHub Desktop.
Save olvlvl/7788d6bd8a4e172bbc92 to your computer and use it in GitHub Desktop.
Create annotation from declared variables
<?php
$__a = "/**\n";
foreach (array_diff_key(get_defined_vars(), [ '__a' => true, '__k' => true, '__v' => true ]) as $__k => $__v)
{
$__v = is_object($__v) ? '\\' . get_class($__v) : gettype($__v);
$__a .= " * @var \$$__k $__v\n";
}
$__a .= " */";
@olvlvl
Copy link
Author

olvlvl commented Feb 6, 2015

This will output something like the following text. You might need to edit the output, since the type of NULL value cannot be determined.

/**
 * @var $mobile boolean
 * @var $isMobile boolean
 * @var $bodyClass array
 * @var $cms \Intlist\CMS\InMemoryBlock
 * @var $locale \Intlist\Environment\LocaleEnvironment
 * @var $description string
 * @var $keywords NULL
 * @var $metaRobots string
 * @var $currentUser NULL
 * @var $results array
 * @var $pagination \Intlist\Pagination\Pagination
 * @var $currentPage NULL
 * @var $ajaxTarget string
 * @var $mainLocations array
 * @var $categoryAttributesFilter string
 * @var $category \Intlist\Entity\RedisEntity\Category
 * @var $location NULL
 * @var $breadcrumb array
 * @var $t \Rocket\Phalcon\Localisation\Translate
 * @var $showSearchForm boolean
 * @var $mainLocation \Intlist\Entity\RedisEntity\Location
 * @var $assetGroup string
 * @var $clientModules string
 * @var $canonical string
 * @var $languageSelector \Intlist\Element\LanguageSelector
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment