@@ -467,6 +467,9 @@ function bug11323(string $s): void {
467467 if (preg_match ('{([-\p{L}[\]*|\x03\a\b+?{}(?:)-]+[^[:digit:]?{}a-z0-9#-k]+)(a-z)} ' , $ s , $ matches )) {
468468 assertType ("array{string, non-falsy-string, 'a-z'} " , $ matches );
469469 }
470+ if (preg_match ('{(\d+)(?i)insensitive((?xs-i)case SENSITIVE here.+and dot matches new lines)} ' , $ s , $ matches )) {
471+ assertType ('array{string, numeric-string, non-falsy-string} ' , $ matches );
472+ }
470473 if (preg_match ('{(\d+)(?i)insensitive((?x-i)case SENSITIVE here(?i:insensitive non-capturing group))} ' , $ s , $ matches )) {
471474 assertType ('array{string, numeric-string, non-falsy-string} ' , $ matches );
472475 }
@@ -778,3 +781,121 @@ function testLtrimDelimiter (string $string): void {
778781 assertType ("array{string, 'x'} " , $ matches );
779782 }
780783}
784+
785+ function testUnescapeBackslash (string $ string ): void {
786+ if (preg_match (<<<'EOD'
787+ ~(\[)~
788+ EOD, $ string , $ matches )) {
789+ assertType ("array{string, '['} " , $ matches );
790+ }
791+
792+ if (preg_match (<<<'EOD'
793+ ~(\d)~
794+ EOD, $ string , $ matches )) {
795+ assertType ("array{string, numeric-string} " , $ matches );
796+ }
797+
798+ if (preg_match (<<<'EOD'
799+ ~(\\d)~
800+ EOD, $ string , $ matches )) {
801+ assertType ("array{string, ' \\\d'} " , $ matches );
802+ }
803+
804+ if (preg_match (<<<'EOD'
805+ ~(\\\d)~
806+ EOD, $ string , $ matches )) {
807+ assertType ("array{string, non-falsy-string} " , $ matches );
808+ }
809+
810+ if (preg_match (<<<'EOD'
811+ ~(\\\\d)~
812+ EOD, $ string , $ matches )) {
813+ assertType ("array{string, ' \\\\\\\d'} " , $ matches );
814+ }
815+ }
816+
817+ function testEscapedDelimiter (string $ string ): void {
818+ if (preg_match (<<<'EOD'
819+ /(\/)/
820+ EOD, $ string , $ matches )) {
821+ assertType ("array{string, '/'} " , $ matches );
822+ }
823+
824+ if (preg_match (<<<'EOD'
825+ ~(\~)~
826+ EOD, $ string , $ matches )) {
827+ assertType ("array{string, '~'} " , $ matches );
828+ }
829+
830+ if (preg_match (<<<'EOD'
831+ ~(\[2])~
832+ EOD, $ string , $ matches )) {
833+ assertType ("array{string, '[2]'} " , $ matches );
834+ }
835+
836+ if (preg_match (<<<'EOD'
837+ [(\[2\])]
838+ EOD, $ string , $ matches )) {
839+ assertType ("array{string, '[2]'} " , $ matches );
840+ }
841+
842+ if (preg_match (<<<'EOD'
843+ ~(\{2})~
844+ EOD, $ string , $ matches )) {
845+ assertType ("array{string, '{2}'} " , $ matches );
846+ }
847+
848+ if (preg_match (<<<'EOD'
849+ {(\{2\})}
850+ EOD, $ string , $ matches )) {
851+ assertType ("array{string, '{2}'} " , $ matches );
852+ }
853+
854+ if (preg_match (<<<'EOD'
855+ ~([a\]])~
856+ EOD, $ string , $ matches )) {
857+ assertType ("array{string, ']'|'a'} " , $ matches );
858+ }
859+
860+ if (preg_match (<<<'EOD'
861+ ~([a[])~
862+ EOD, $ string , $ matches )) {
863+ assertType ("array{string, '['|'a'} " , $ matches );
864+ }
865+
866+ if (preg_match (<<<'EOD'
867+ ~([a\]b])~
868+ EOD, $ string , $ matches )) {
869+ assertType ("array{string, ']'|'a'|'b'} " , $ matches );
870+ }
871+
872+ if (preg_match (<<<'EOD'
873+ ~([a[b])~
874+ EOD, $ string , $ matches )) {
875+ assertType ("array{string, '['|'a'|'b'} " , $ matches );
876+ }
877+
878+ if (preg_match (<<<'EOD'
879+ ~([a\[b])~
880+ EOD, $ string , $ matches )) {
881+ assertType ("array{string, '['|'a'|'b'} " , $ matches );
882+ }
883+
884+ if (preg_match (<<<'EOD'
885+ [([a\[b])]
886+ EOD, $ string , $ matches )) {
887+ assertType ("array{string, '['|'a'|'b'} " , $ matches );
888+ }
889+
890+ if (preg_match (<<<'EOD'
891+ {(x\\\{)|(y\\\\\})}
892+ EOD, $ string , $ matches )) {
893+ assertType ("array{string, '', 'y \\\\\\\}'}|array{string, 'x \\\{'} " , $ matches );
894+ }
895+ }
896+
897+ function bugUnescapedDashAfterRange (string $ string ): void {
898+ if (preg_match ('/([0-1-y])/ ' , $ string , $ matches )) {
899+ assertType ("array{string, non-empty-string} " , $ matches );
900+ }
901+ }
0 commit comments