xref: /PHP-8.1/ext/opcache/tests/jit/bug81051.phpt (revision 010d6a49)
1--TEST--
2Bug #80839: PHP problem with JIT
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.jit_buffer_size=1M
9opcache.jit=1205
10--FILE--
11<?php
12class Binary{
13	public static function readUnsignedVarInt(string $buffer, int &$offset) : int{
14		$offset++;
15		return 0;
16	}
17}
18
19class BinaryStream{
20
21	private string $buffer;
22	private int $offset;
23
24	public function __construct(string $buffer, int $offset = 0){
25		$this->buffer = $buffer;
26		$this->offset = $offset;
27	}
28
29	public function getUnsignedVarInt() : int{
30		return Binary::readUnsignedVarInt($this->buffer, $this->offset);
31	}
32
33	public function get(int $len) : string{
34		return $len === 1 ? $this->buffer[$this->offset++] : substr($this->buffer, ($this->offset += $len) - $len, $len);
35	}
36}
37$stream = new BinaryStream(str_repeat("\x01a", 1000));
38var_dump($stream->getUnsignedVarInt());
39var_dump($stream->get(1));
40?>
41--EXPECT--
42int(0)
43string(1) "a"
44