private static function Kint::_removeAllButCode in Devel 8
Same name and namespace in other branches
- 8.2 kint/kint/Kint.class.php \Kint::_removeAllButCode()
* removes comments and zaps whitespace & <?php tags from php code, makes for easier further parsing * *
Parameters
string $source: * * @return string
1 call to Kint::_removeAllButCode()
- Kint::_getCalleeInfo in kint/
kint/ Kint.class.php - * returns parameter names that the function was passed, as well as any predefined symbols before function * call (modifiers) * *
File
- kint/
kint/ Kint.class.php, line 559
Class
Code
private static function _removeAllButCode($source) {
$commentTokens = array(
T_COMMENT => true,
T_INLINE_HTML => true,
T_DOC_COMMENT => true,
);
$whiteSpaceTokens = array(
T_WHITESPACE => true,
T_CLOSE_TAG => true,
T_OPEN_TAG => true,
T_OPEN_TAG_WITH_ECHO => true,
);
$cleanedSource = '';
foreach (token_get_all($source) as $token) {
if (is_array($token)) {
if (isset($commentTokens[$token[0]])) {
continue;
}
if (isset($whiteSpaceTokens[$token[0]])) {
$token = "\7";
}
else {
$token = $token[1];
}
}
elseif ($token === ';') {
$token = "\7";
}
$cleanedSource .= $token;
}
return $cleanedSource;
}