<?
<beginfold id='1'>/*</beginfold id='1'> This is a pseudo PHP file to test Kate's PHP syntax highlighting. <endfold id='1'>*/</endfold id='1'>
# TODO: this is incomplete, add more syntax examples!
# this is also a comment.
// Even this is a comment
<beginfold id='2'>/** </beginfold id='2'>\brief doxygen comment
<endfold id='2'>*/</endfold id='2'> <beginfold id='1'>/*</beginfold id='1'>normal comment<endfold id='1'>*/</endfold id='1'>
// comment ?> normal text <?php
function test($varname) <beginfold id='3'>{</beginfold id='3'>
	return "bla";	# this is also a comment
<endfold id='3'>}</endfold id='3'>
?>

<?php echo("hello test"); ?>

<html>
	<? print "<title>test</title>"; ?>

	<beginfold id='4'><!--</beginfold id='4'> CSS <endfold id='4'>--></endfold id='4'>
	<beginfold id='5'><style</beginfold id='5'>>
		.inputText <beginfold id='6'>{</beginfold id='6'>
			width: <?php echo $width; ?>px;
			text-indent: 10px;
		<endfold id='6'>}</endfold id='6'>
	<endfold id='5'></style</endfold id='5'>>

	<beginfold id='4'><!--</beginfold id='4'> JavaScript <endfold id='4'>--></endfold id='4'>
	<beginfold id='7'><script</beginfold id='7'>>
		var some_js_var = <?php echo $somevar; ?> ;
		<?php echo 'alert("Hello there.");'; ?>
	<endfold id='7'></script</endfold id='7'>>
	<beginfold id='4'><!--</beginfold id='4'> JavaScript React <endfold id='4'>--></endfold id='4'>
	<beginfold id='7'><script</beginfold id='7'> type="text/babel">
		<beginfold id='8'><Hello</beginfold id='8'>> <?php echo("Hello, hello!"); ?> </Hello<endfold id='8'>></endfold id='8'> <?php <beginfold id='1'>/*</beginfold id='1'> aaa <endfold id='1'>*/</endfold id='1'> ?> <beginfold id='9'><div</beginfold id='9'>></div<endfold id='9'>></endfold id='9'>
		function a(i) <beginfold id='10'>{</beginfold id='10'>
			<?php echo "var j = 1;"; ?>
			return <beginfold id='9'><p</beginfold id='9'>><beginfold id='11'>{</beginfold id='11'> i + j <endfold id='11'>}</endfold id='11'></p<endfold id='9'>></endfold id='9'>;
		<endfold id='10'>}</endfold id='10'>
	<endfold id='7'></script</endfold id='7'>>
	<beginfold id='4'><!--</beginfold id='4'> TypeScript <endfold id='4'>--></endfold id='4'>
	<beginfold id='7'><script</beginfold id='7'> type="text/typescript">
		<?php $timestamp = time(); ?>
		class DateTime <beginfold id='12'>{</beginfold id='12'>
			info: string;
			constructor() <beginfold id='12'>{</beginfold id='12'> this.info = <?php echo(date("F d, Y h:i:s", $timestamp)); ?>; <endfold id='12'>}</endfold id='12'>
			get() <beginfold id='12'>{</beginfold id='12'> return this.info; <endfold id='12'>}</endfold id='12'>
		<endfold id='12'>}</endfold id='12'>
	<endfold id='7'></script</endfold id='7'>>
	<beginfold id='4'><!--</beginfold id='4'> MustacheJS <endfold id='4'>--></endfold id='4'>
	<beginfold id='7'><script</beginfold id='7'> type="x-tmpl-mustache">
		<beginfold id='13'>{{!</beginfold id='13'> <?php print "comment"; ?> <endfold id='13'>}}</endfold id='13'>
		<beginfold id='14'>{{#movie</beginfold id='14'>}}
			<beginfold id='15'><div</beginfold id='15'>>
				<h1>{{title}}</h1>
				<img src="{{poster}}" alt="{{title}}"/>
				<?php echo $movierating; ?> - {{ratings.critics_rating}}
			<endfold id='15'></div</endfold id='15'>>
		<endfold id='14'>{{/movie}}</endfold id='14'>
	<endfold id='7'></script</endfold id='7'>>

</html>

<?php
$var = <beginfold id='16'><<<DOOH</beginfold id='16'>
This is the $string inside the variable (which seems to be rendered as a string)
It works well, I think.
<endfold id='16'>DOOH</endfold id='16'>

# bug 382527
throw new ParserException("Test {$this->some_var[$index]}\nin {$this->file} is missing.\nThis is bad.");

$arr = array();
foreach($arr as $i => $v)<beginfold id='17'>:</beginfold id='17'>
	echo($i);
<endfold id='17'>endforeach</endfold id='17'>

echo " $var {$var} ${var} ";
echo " $var[1] {$var[1]} ${var[1]} ";
echo " $var[-1] {$var[-1]} ${var[-1]} ";
echo " $var[i] {$var[i]} ${var[i]} ";
echo " $var[-i] {$var[-i]} ${var[-i]} ";
echo " $var[$i] {$var[$i]} ${var[$i]} ";
echo " $var[-$i] {$var[-$i]} ${var[-$i]} ";
echo " $var[$$i] {$var[$$i]} ${var[$$i]} ";
echo " $var[$x->i] {$var[$x->i]} ${var[$x->i]} ";
echo " $var[$x->$i] {$var[$x->$i]} ${var[$x->$i]} ";
echo " $$var {$$var} $${var} ";
echo " $$var[1] {$$var[1]} $${var[1]} ";
echo " $$var[$i] {$$var[$i]} $${var[$i]} ";
echo " $var[$i] {$var[$i]} ${var[$i]} ";
echo " $var[1+1] {$var[1+1]} ${var[1+1]} ";
echo " $var->mem {$var->mem} ${var->mem} ";
echo " $var->3 {$var->3} ${var->3} ";
echo " $var-> {$var->} ${var->} ";
echo " $var->$mem {$var->$mem} ${var->$mem} ";
echo " ${$x->{'mem'}} ";
echo "\n \t \\ \xff \x";

echo <beginfold id='16'><<<HTML</beginfold id='16'>
<p>bla $var \$var bla\'</p>
<endfold id='16'>HTML</endfold id='16'>;
echo <beginfold id='16'><<<"HTML"</beginfold id='16'>
<p>bla $var \$var bla\'</p>
<endfold id='16'>HTML</endfold id='16'>;
echo <beginfold id='18'><<<'HTML'</beginfold id='18'>
<p>bla $var \$var bla\'</p>
<endfold id='18'>HTML</endfold id='18'>;
echo <beginfold id='16'><<<DOC</beginfold id='16'>
<p>bla $var \$var bla\'</p>
<endfold id='16'>DOC</endfold id='16'>;
echo <beginfold id='16'><<<DOC</beginfold id='16'>
		<p>bla $var \$var bla\'</p>
<endfold id='16'>	DOC</endfold id='16'>;
echo <beginfold id='16'><<<DOC</beginfold id='16'>
    <p>bla $var \$var bla\'</p>
<endfold id='16'>  DOC</endfold id='16'>;

echo 123456 1_2_34_5 1__2 1_;
echo 0x12345af 0x1_2_3_45_a_f 0x1__2 0x_1 0x1_ 0x1g 0xg;
echo 0b1011 0b1_01_1 0b1__0 0b_1 0b1_ 0b12 0b2;
echo 01234 01_23_4 0_1 0__1 01_ 018 08;
echo 0o1234 0O1_23_4 0o1_1_ 0o1__1 0o_1;
echo 123. .45 123.45 1_23.4_5e1_2;
echo 123.e1 .45e1 123.45e1;
echo 123.e+1 .45e+1 123.45e+1;
echo 123.e++1 ._45e+1 123._45e+1; // bad float

echo 123...45;
echo add(...[1, 2])."\n";

function gen_three_nulls() <beginfold id='3'>{</beginfold id='3'>
    foreach (range(1, 3) as $i) <beginfold id='3'>{</beginfold id='3'>
        yield;
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

function &gen_reference() <beginfold id='3'>{</beginfold id='3'>
    $value = 3;

    while ($value > 0) <beginfold id='3'>{</beginfold id='3'>
        yield $value;
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

function gen() <beginfold id='3'>{</beginfold id='3'>
    yield 0; // key 0
    yield from inner(); // keys 0-2
    yield 4; // key 1
<endfold id='3'>}</endfold id='3'>

switch (1) <beginfold id='3'>{</beginfold id='3'>
    case 1: echo 'plop';
    case 1; echo 'plop';
    default: echo 'plop';
    default : echo 'plop';
<endfold id='3'>}</endfold id='3'>

class User
<beginfold id='3'>{</beginfold id='3'>
    public int $id;
    public ?string $name;

    public function __construct(int $id, ?string $name)  : void
    <beginfold id='3'>{</beginfold id='3'>
        $this->id = $id;
        $this->name = $name;
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

class MyClass <beginfold id='3'>{</beginfold id='3'>
    const CONST_VALUE = 'A constant value';
<endfold id='3'>}</endfold id='3'>

class OtherClass extends MyClass
<beginfold id='3'>{</beginfold id='3'>
    public static $my_static = 'static var';

    public static function doubleColon() <beginfold id='3'>{</beginfold id='3'>
        echo parent::CONST_VALUE . "\n";
        echo self::$my_static . "\n";
    <endfold id='3'>}</endfold id='3'>
<endfold id='3'>}</endfold id='3'>

$classname = 'MyClass';
echo $classname::CONST_VALUE;

echo MyClass::CONST_VALUE;

$classname = 'OtherClass';
$classname::doubleColon();

OtherClass::doubleColon();
new $classname::class;

$user = new User(1234, null);

$y = 1;
$fn1 = fn($x) => $x + $y;
$fn2 = function ($x) use ($y) <beginfold id='3'>{</beginfold id='3'>
    return $x + $y;
<endfold id='3'>}</endfold id='3'>;

$a = [1,2,3,'x'=>4];
$b = array(1,2,3,'x'=>4);

namespace A\B\C;
class Exception extends \Exception <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'>

$b = new \Exception('hi');
$x = new A\B\Foo('hi');
$n = \strlen($str) - 1;

$r = $x <=> $y and $z;

#[ExampleAttribute('Hello world', 42)]
class Foo <beginfold id='3'>{</beginfold id='3'><endfold id='3'>}</endfold id='3'>
function foo(#[TestAttr] $bar)<beginfold id='3'>{</beginfold id='3'>
<endfold id='3'>}</endfold id='3'>

enum Suit <beginfold id='3'>{</beginfold id='3'>
    case Clubs;
    case Diamonds;
<endfold id='3'>}</endfold id='3'>
?>

<?php if (n)<beginfold id='17'>:</beginfold id='17'> ?>
<p>bla ba</p>
<?php <endfold id='17'>endif</endfold id='17'> ?>
