I want to split strings produced by an older version of phpstan we are constrained to use (v0.9).
Each error string is separated by :
, but there are sometimes static calls marked with ::
which I want to ignore.
My code:
$error = '/path/to/file/namespace/filename:line_number:error message Namespace\ClassName::method().'
$output = preg_split('/:/', $error);
A var_dump
of $output
gives this:
Array
(
[0] => /path/to/file/namespace/filename
[1] => line_number
[2] => error message Namespace\ClassName
[3] =>
[4] => method().
)
The result I want is this:
Array
(
[0] => /path/to/file/namespace/filename
[1] => line_number
[2] => error message Namespace\ClassName::method().
)
I was hoping this could be solved with regex.
I have been reading similar questions and have tried variations of regex, none of which worked.