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