mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
Improved performance, thanks to @nikic's new regex.
This commit is contained in:
@@ -62,36 +62,35 @@ class LongDescription implements \Reflector
|
|||||||
if (null === $this->parsedContents) {
|
if (null === $this->parsedContents) {
|
||||||
$this->parsedContents = preg_split(
|
$this->parsedContents = preg_split(
|
||||||
'/\{
|
'/\{
|
||||||
# We want the whole tag line, but without the inline tag
|
# "{@}" is not a valid inline tag. This ensures that
|
||||||
# delimiters.
|
# we do not treat it as one, but treat it literally.
|
||||||
|
(?!@\})
|
||||||
|
# We want to capture the whole tag line, but without the
|
||||||
|
# inline tag delimiters.
|
||||||
(\@
|
(\@
|
||||||
# The content should not be captured, or it will appear
|
# Match everything up to the next delimiter.
|
||||||
# in the result separately.
|
[^{}]*
|
||||||
|
# Nested inline tag content should not be captured, or
|
||||||
|
# it will appear in the result separately.
|
||||||
(?:
|
(?:
|
||||||
# Match nested inline tags.
|
# Match nested inline tags.
|
||||||
# Because we did not catch the tag delimiters
|
(?:
|
||||||
# earlier, we must be explicit with them here.
|
# Because we did not catch the tag delimiters
|
||||||
# Notice that this also matches "{}", as a way to
|
# earlier, we must be explicit with them here.
|
||||||
# later introduce it as an escape sequence.
|
# Notice that this also matches "{}", as a way
|
||||||
\{(?1)?\}
|
# to later introduce it as an escape sequence.
|
||||||
|
|
\{(?1)?\}
|
||||||
# "{@}" is not a valid inline tag. This ensures that
|
|
|
||||||
# having it occur inside an inline tag does not trip
|
# Make sure we match hanging "{".
|
||||||
# us up. While this is required in any event, notice
|
\{
|
||||||
# that this is also later an escape sequence.
|
)
|
||||||
\{\@\}
|
# Match content after the nested inline tag.
|
||||||
|
|
[^{}]*
|
||||||
# If we are not dealing with a nested inline tag,
|
)* # If there are more inline tags, match them as well.
|
||||||
# get the character, as long as it is not a closing
|
# We use "*" since there may not be any nested inline
|
||||||
# tag delimiter.
|
# tags.
|
||||||
# This is an alternative way of non-greedy matching.
|
|
||||||
[^\}]
|
|
||||||
)+ # We need to keep doing these checks for every
|
|
||||||
# character, since we never know where an inline tag
|
|
||||||
# is going to start at. The "+" ensures we are not
|
|
||||||
# treating "{@}" as a valid inline tag.
|
|
||||||
)
|
)
|
||||||
\}/xuS',
|
\}/Sux',
|
||||||
$this->contents,
|
$this->contents,
|
||||||
null,
|
null,
|
||||||
PREG_SPLIT_DELIM_CAPTURE
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
|||||||
Reference in New Issue
Block a user