Skip to content

Commit

Permalink
polyfill for PHP8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanLuLyf committed Jul 27, 2022
1 parent 1202111 commit 3d5e5f0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion BunnyPHP/BunnyPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
namespace BunnyPHP;
defined('BUNNY_PATH') or define('BUNNY_PATH', __DIR__);

include_once 'polyfill.php';

use ReflectionClass;
use ReflectionException;
use ReflectionMethod;

class BunnyPHP
{
const BUNNY_VERSION = '3.1.0';
const BUNNY_VERSION = '3.1.1';
const MODE_NORMAL = 0;
const MODE_API = 1;
const MODE_AJAX = 2;
Expand Down
4 changes: 4 additions & 0 deletions BunnyPHP/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace BunnyPHP;

use ArrayAccess;
use ReturnTypeWillChange;

class Language implements ArrayAccess
{
Expand Down Expand Up @@ -89,15 +90,18 @@ public function offsetExists($offset): bool
return isset($this->translation[$offset]);
}

#[ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->translation[$offset] ?? $offset;
}

#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
}

#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->translation[$offset]);
Expand Down
4 changes: 4 additions & 0 deletions BunnyPHP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace BunnyPHP;

use ArrayAccess;
use ReturnTypeWillChange;

class Request implements ArrayAccess
{
Expand Down Expand Up @@ -126,6 +127,7 @@ public function offsetExists($offset): bool
return isset($this->param[$offset]) || isset($this->query[$offset]);
}

#[ReturnTypeWillChange]
public function offsetGet($offset)
{
if (isset($this->param[$offset])) {
Expand All @@ -137,11 +139,13 @@ public function offsetGet($offset)
}
}

#[ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->param[$offset] = $value;
}

#[ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->param[$offset]);
Expand Down
10 changes: 10 additions & 0 deletions BunnyPHP/polyfill.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
if (PHP_VERSION_ID < 80100) {
#[Attribute(Attribute::TARGET_METHOD)]
final class ReturnTypeWillChange
{
public function __construct()
{
}
}
}

0 comments on commit 3d5e5f0

Please sign in to comment.