Given the following piece of code in file src/issue-2421.php:
<?php
class Issue2421 {
/**
* Regular expression to check if a given identifier name is valid for use in PHP.
*
* @var string
*/
const PHP_LABEL_REGEX = '`^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$`';
}
with the following config:
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
configVersion="3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.phpdoc.org"
xsi:noNamespaceSchemaLocation="https://docs.phpdoc.org/latest/phpdoc.xsd"
>
<title>Demo</title>
<version number="latest">
<api format="php">
<source dsn=".">
<path>src</path>
</source>
</api>
</version>
<template name="default"/>
</phpdocumentor>
I'd expect to see the constant value to be displayed as declared in the code.
The slashes in the constant value are displayed as double slashed.

php -f /path/to/phpDocumentor/bin/phpdocInvestigated the issue and it seems to be related to the passing of this value into the templates and not with the template itself. As discussed with @jaapio, I am skipping any issue not related to the templates at the moment
This issue goes even deeper than phpDocumentor itself.
We are using the PrettyPrinter of PHP-Parser to convert values to there respective value.
This is also the reason why default values of properties are losing there newlines. The values are tokenized and parsed as they are normal statements. This means that we are not reading code but stringified tokens. Which do not have any newlines.
Fixing this could be tricky... I'm going to remove the slashes manually for now. This issue might return for other values. Which needs to be checked as well.
This issue should be fixed now for:
I didn't check if this issue also exists in docblock values since we are not using php-parser to print those.
@jaapio Thank you so much!
@jaapio Hmm.. just noticed... when a single backslash is used in a non-text string context, like when using a FQN constant \T_IF in a property declaration, that single backslash is now also removed...