<?php
// clears all extra horizontal whitespace from the line endings
// to prevent parsing issues
$comment = preg_replace('/\h*$/Sum', '', $comment);
/*
* Splits the docblock into a short description, long description and
* tags section
* - The short description is started from the first character until
* a dot is encountered followed by a newline OR
* two consecutive newlines (horizontal whitespace is taken into
* account to consider spacing errors)
* - The long description, any character until a new line is
* encountered followed by an @ and word characters (a tag).
* This is optional.
* - Tags; the remaining characters
*
* Big thanks to RichardJ for contributing this Regular Expression
*/
preg_match(
'/
(\#\@\+|\#\@\-)?
\A (
[^\n.]+
(?:
(?! \. \n | \n{2} ) # disallow the first seperator here
[\n.] (?! [ \t]* @\pL ) # disallow second seperator
[^\n.]+
)*
\.?
)
(?:
\s* # first seperator (actually newlines but it\'s all whitespace)
(?! @\pL ) # disallow the rest, to make sure this one doesn\'t match,
#if it doesn\'t exist
(
[^\n]+
(?: \n+
(?! [ \t]* @\pL ) # disallow second seperator (@param)
[^\n]+
)*
)
)?
(\s+ [\s\S]*)? # everything that follows
/ux',
$comment,
$matches
);
array_shift($matches);
var_dump($matches);
Warning: Undefined variable $comment in /in/pgbvq on line 4
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /in/pgbvq on line 4
array(0) {
}
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $comment in /in/pgbvq on line 4
array(0) {
}
Notice: Undefined variable: comment in /in/pgbvq on line 4
array(0) {
}
Output for 7.3.32 - 7.3.33, 7.4.26
array(0) {
}
Output for 5.0.4
Notice: Undefined variable: comment in /in/pgbvq on line 4
Warning: preg_match(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 170 in /in/pgbvq on line 48
array(0) {
}
Output for 4.3.11, 5.0.0 - 5.0.3
Notice: Undefined variable: comment in /in/pgbvq on line 4
Warning: preg_match(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 170 in /in/pgbvq on line 48
array(0) {
}
Output for 4.4.0 - 4.4.9
Notice: Undefined variable: comment in /in/pgbvq on line 4
array(0) {
}
Output for 4.3.0 - 4.3.10
Notice: Undefined variable: comment in /in/pgbvq on line 4
Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 170 in /in/pgbvq on line 48
array(0) {
}