The current constant
const HEADER_REGEX = '^(==+)\h*([^=].*)\h*\1$';
would ignore headings such as
=== moep ==
(which should be equivalent to == = moep ==)
For this reason, i recommend to use
const HEADER_REGEX = '(?m:^(==+)\h*(.*?)\h*\1$)';
instead.
This has another advantage: The code
// The \A means the regex must match at the beginning of the string. // This is slightly different than ^ which matches beginning of each // line in multiline mode. $startSection = preg_match( '/\A' . self::HEADER_REGEX . '/um', $content );
could be simply replaced by
$startSection = preg_match( '/^' . self::HEADER_REGEX . '/u', $content );