diff --git a/.github/workflows/ci-scheduled.yml b/.github/workflows/ci-scheduled.yml
index df8460c..0189d76 100644
--- a/.github/workflows/ci-scheduled.yml
+++ b/.github/workflows/ci-scheduled.yml
@@ -1,18 +1,18 @@
name: CI (scheduled)
on:
schedule:
- - cron: 0 14 * * 0 # Sunday 2PM UTC = Monday 12AM AEST
+ - cron: * 14 * * 0 # Every day 2PM UTC = Monday 12AM AEST
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
- php: ['7.4', '8.0', '8.1']
+ php: ['8.2', '8.3', '8.4', '8.5']
name: PHP ${{ matrix.php }}
steps:
- name: Checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
@@ -22,13 +22,11 @@ jobs:
- name: Check PHP version
run: php -v
- name: Install dependencies
- run: make vendor
- - name: Make
- if: ${{ startsWith(matrix.php, '7.') }}
- run: make ci
- - name: Make
- if: ${{ startsWith(matrix.php, '8.') }}
- run: make artifacts/coverage/phpunit/clover.xml
+ run: composer install --no-interaction --prefer-dist
+ - name: Run tests with coverage
+ run: |
+ mkdir -p artifacts/test artifacts/coverage/phpunit
+ vendor/bin/phpunit -c phpunit.xml --coverage-clover artifacts/coverage/phpunit/clover.xml
- name: Publish coverage
if: success()
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@v4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1cfc297..671bc4c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,11 +8,11 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: ['7.4', '8.0', '8.1']
+ php: ['8.2', '8.3', '8.4', '8.5']
name: PHP ${{ matrix.php }}
steps:
- name: Checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
@@ -22,13 +22,11 @@ jobs:
- name: Check PHP version
run: php -v
- name: Install dependencies
- run: make vendor
- - name: Make
- if: ${{ startsWith(matrix.php, '7.') }}
- run: make ci
- - name: Make
- if: ${{ startsWith(matrix.php, '8.') }}
- run: make artifacts/coverage/phpunit/clover.xml
+ run: composer install --no-interaction --prefer-dist
+ - name: Run tests with coverage
+ run: |
+ mkdir -p artifacts/test artifacts/coverage/phpunit
+ vendor/bin/phpunit -c phpunit.xml --coverage-clover artifacts/coverage/phpunit/clover.xml
- name: Publish coverage
if: success()
- uses: codecov/codecov-action@v2
+ uses: codecov/codecov-action@v4
diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml
new file mode 100644
index 0000000..4ea9753
--- /dev/null
+++ b/.idea/phpunit.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 27cd915..df37efc 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,13 @@
-> # No longer maintained
->
-> This package is no longer maintained. See [this statement] for more info.
->
-> [this statement]: https://gist.github.com/ezzatron/713a548735febe3d76f8ca831bc895c0
-
# Pops
*PHP Object Proxy System.*
+This is a maintained fork of [eloquent/pops] originally created by Erin Millard.
+
## Installation and documentation
-* Available as [Composer] package [eloquent/pops].
+* Available as [Composer] package `vedavith/pops-fork` (maintained fork of `eloquent/pops`).
+* Requires PHP 8.2 or later.
## What is *Pops*?
@@ -45,12 +42,12 @@ use Eloquent\Pops\ProxyObject;
class UppercaseProxyObject extends ProxyObject
{
- public function popsCall($method, array &$arguments)
+ public function popsCall(string $method, array &$arguments): mixed
{
return strtoupper(parent::popsCall($method, $arguments));
}
- public function __get($property)
+ public function __get(string $property): mixed
{
return strtoupper(parent::__get($property));
}
@@ -148,7 +145,7 @@ class OutputEscaperProxyArray extends ProxyArray
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
@@ -170,7 +167,7 @@ class OutputEscaperProxyClass extends ProxyClass
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
@@ -192,7 +189,7 @@ class OutputEscaperProxyObject extends ProxyObject
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
@@ -214,7 +211,7 @@ class OutputEscaperProxyPrimitive extends ProxyPrimitive
*
* @return string The HTML-secaped version of this primitive.
*/
- public function __toString()
+ public function __toString(): string
{
return htmlspecialchars(
strval($this->popsValue()),
diff --git a/composer.json b/composer.json
index 5bd9680..8432aa5 100644
--- a/composer.json
+++ b/composer.json
@@ -1,24 +1,37 @@
{
- "name": "eloquent/pops",
- "description": "PHP object proxy system.",
+ "name": "vedavith/pops-fork",
+ "description": "Maintained fork of eloquent/pops, a PHP object proxy system.",
"keywords": ["object", "proxy", "method", "property"],
- "homepage": "https://github.com/eloquent/pops",
+ "homepage": "https://github.com/vedavith/pops-fork",
"license": "MIT",
+ "support": {
+ "issues": "https://github.com/vedavith/pops-fork/issues",
+ "source": "https://github.com/vedavith/pops-fork"
+ },
+ "replace": {
+ "eloquent/pops": "self.version"
+ },
"authors": [
{
"name": "Erin Millard",
"email": "ezzatron@gmail.com",
"homepage": "http://ezzatron.com/"
+ },
+ {
+ "name": "Vedavith Ravula",
+ "email": "veda_ravula@outlook.com"
}
],
"require": {
- "php": "^7.4 || ^8"
+ "php": "^8.2"
},
"require-dev": {
"eloquent/code-style": "^2",
"errors/exceptions": "^0.2",
"friendsofphp/php-cs-fixer": "^3",
- "phpunit/phpunit": "^9"
+ "phpunit/phpunit": "^11.3 || ^12",
+ "ext-mbstring": "*",
+ "phpunit/php-code-coverage": "^11 || ^12"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml b/phpunit.xml
index 1edbdca..2a29e12 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,12 +1,9 @@
@@ -18,11 +15,13 @@
+
+ src
-
+
diff --git a/src/AbstractProxy.php b/src/AbstractProxy.php
index 64c6d95..ae6f06e 100644
--- a/src/AbstractProxy.php
+++ b/src/AbstractProxy.php
@@ -23,7 +23,7 @@ abstract class AbstractProxy implements ProxyInterface
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- public function __construct($value)
+ public function __construct(mixed $value)
{
$this->setPopsValue($value);
}
@@ -35,7 +35,7 @@ public function __construct($value)
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- public function setPopsValue($value)
+ public function setPopsValue(mixed $value): void
{
$this->assertPopsValue($value);
@@ -47,7 +47,7 @@ public function setPopsValue($value)
*
* @return mixed The wrapped value.
*/
- public function popsValue()
+ public function popsValue(): mixed
{
return $this->value;
}
@@ -60,7 +60,7 @@ public function popsValue()
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- abstract protected function assertPopsValue($value);
+ abstract protected function assertPopsValue(mixed $value): void;
- private $value;
+ private mixed $value;
}
diff --git a/src/AbstractTraversableProxy.php b/src/AbstractTraversableProxy.php
index 445e3d9..5c33e16 100644
--- a/src/AbstractTraversableProxy.php
+++ b/src/AbstractTraversableProxy.php
@@ -27,7 +27,7 @@ abstract class AbstractTraversableProxy extends AbstractProxy implements
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- public function __construct($value, $isRecursive = null)
+ public function __construct(mixed $value, ?bool $isRecursive = null)
{
if (null === $isRecursive) {
$isRecursive = false;
@@ -43,7 +43,7 @@ public function __construct($value, $isRecursive = null)
*
* @return bool True if the wrapped value is recursively proxied.
*/
- public function isPopsRecursive()
+ public function isPopsRecursive(): bool
{
return $this->isPopsRecursive;
}
@@ -53,8 +53,7 @@ public function isPopsRecursive()
*
* @return mixed The current value.
*/
- #[\ReturnTypeWillChange]
- public function current()
+ public function current(): mixed
{
return $this->popsProxySubValue($this->popsInnerIterator()->current());
}
@@ -64,8 +63,7 @@ public function current()
*
* @return mixed The current key.
*/
- #[\ReturnTypeWillChange]
- public function key()
+ public function key(): mixed
{
return $this->popsInnerIterator()->key();
}
@@ -103,7 +101,7 @@ public function valid(): bool
*
* @return mixed The proxied value, or the untouched value.
*/
- protected function popsProxySubValue($value)
+ protected function popsProxySubValue(mixed $value): mixed
{
if ($this->isPopsRecursive()) {
$popsClass = static::popsProxyClass();
@@ -119,7 +117,7 @@ protected function popsProxySubValue($value)
*
* @return Iterator An iterator for the wrapped object.
*/
- protected function popsInnerIterator()
+ protected function popsInnerIterator(): Iterator
{
if (null === $this->popsInnerIterator) {
$this->popsInnerIterator = $this->popsCreateInnerIterator();
@@ -133,8 +131,8 @@ protected function popsInnerIterator()
*
* @return Iterator An iterator for the wrapped object.
*/
- abstract protected function popsCreateInnerIterator();
+ abstract protected function popsCreateInnerIterator(): Iterator;
- private $isPopsRecursive;
- private $popsInnerIterator;
+ private bool $isPopsRecursive;
+ private ?Iterator $popsInnerIterator = null;
}
diff --git a/src/ProxyArray.php b/src/ProxyArray.php
index 3dab6e0..176595e 100644
--- a/src/ProxyArray.php
+++ b/src/ProxyArray.php
@@ -27,7 +27,7 @@ class ProxyArray extends AbstractTraversableProxy implements ProxyArrayInterface
*
* @return array The wrapped array.
*/
- public function popsArray()
+ public function popsArray(): array
{
return $this->popsValue();
}
@@ -38,7 +38,7 @@ public function popsArray()
* @param int|string $index The index to set.
* @param mixed $value The new value.
*/
- public function offsetSet($index, $value): void
+ public function offsetSet(mixed $index, mixed $value): void
{
$array = $this->popsValue();
$array[$index] = $value;
@@ -53,8 +53,7 @@ public function offsetSet($index, $value): void
*
* @return mixed The value.
*/
- #[\ReturnTypeWillChange]
- public function offsetGet($index)
+ public function offsetGet(mixed $index): mixed
{
$array = $this->popsValue();
@@ -68,7 +67,7 @@ public function offsetGet($index)
*
* @return bool True if the index exists.
*/
- public function offsetExists($index): bool
+ public function offsetExists(mixed $index): bool
{
$array = $this->popsValue();
@@ -80,7 +79,7 @@ public function offsetExists($index): bool
*
* @param int|string $index The index to remove.
*/
- public function offsetUnset($index): void
+ public function offsetUnset(mixed $index): void
{
$array = $this->popsValue();
unset($array[$index]);
@@ -103,7 +102,7 @@ public function count(): int
*
* @return string The string representation.
*/
- public function __toString()
+ public function __toString(): string
{
return strval($this->popsProxySubValue(strval($this->popsValue())));
}
@@ -113,7 +112,7 @@ public function __toString()
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\Proxy';
}
@@ -126,7 +125,7 @@ protected static function popsProxyClass()
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- protected function assertPopsValue($value)
+ protected function assertPopsValue(mixed $value): void
{
if (!is_array($value)) {
throw new Exception\InvalidTypeException($value, 'array');
@@ -138,7 +137,7 @@ protected function assertPopsValue($value)
*
* @return Iterator An iterator for the wrapped object.
*/
- protected function popsCreateInnerIterator()
+ protected function popsCreateInnerIterator(): Iterator
{
return new ArrayIterator($this->popsValue());
}
diff --git a/src/ProxyClass.php b/src/ProxyClass.php
index b2443c5..62593c6 100644
--- a/src/ProxyClass.php
+++ b/src/ProxyClass.php
@@ -26,7 +26,7 @@ class ProxyClass extends AbstractProxy implements ProxyClassInterface
*
* @return mixed The result of the method call.
*/
- public static function __callStatic($method, array $arguments)
+ public static function __callStatic(string $method, array $arguments): mixed
{
return static::popsProxySubValue(
call_user_func_array(
@@ -42,7 +42,7 @@ public static function __callStatic($method, array $arguments)
*
* @return ProxyClass The non-static class proxy.
*/
- public static function popsProxy()
+ public static function popsProxy(): ProxyClass
{
$originalClass = static::$popsStaticOriginalClass;
if (null === $originalClass) {
@@ -73,10 +73,10 @@ public static function popsProxy()
* @return string The class name used for the proxy class.
*/
public static function popsGenerateStaticClassProxy(
- $class,
- $isRecursive = null,
- $proxyClass = null
- ) {
+ string $class,
+ ?bool $isRecursive = null,
+ ?string $proxyClass = null
+ ): string {
if (null === $isRecursive) {
$isRecursive = false;
}
@@ -99,7 +99,7 @@ public static function popsGenerateStaticClassProxy(
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- public function __construct($class, $isRecursive = null)
+ public function __construct(string $class, ?bool $isRecursive = null)
{
if (null === $isRecursive) {
$isRecursive = false;
@@ -118,7 +118,7 @@ public function __construct($class, $isRecursive = null)
*
* @return string The proxied class name.
*/
- public function popsClass()
+ public function popsClass(): string
{
return $this->popsValue();
}
@@ -128,7 +128,7 @@ public function popsClass()
*
* @return bool True if the wrapped class is recursively proxied.
*/
- public function isPopsRecursive()
+ public function isPopsRecursive(): bool
{
return $this->isPopsRecursive;
}
@@ -142,7 +142,7 @@ public function isPopsRecursive()
*
* @return mixed The result of the method call.
*/
- public function popsCall($method, array &$arguments)
+ public function popsCall(string $method, array &$arguments): mixed
{
return static::popsProxySubValue(
call_user_func_array(
@@ -161,7 +161,7 @@ public function popsCall($method, array &$arguments)
*
* @return mixed The result of the method call.
*/
- public function __call($method, array $arguments)
+ public function __call(string $method, array $arguments): mixed
{
return $this->popsCall($method, $arguments);
}
@@ -172,7 +172,7 @@ public function __call($method, array $arguments)
* @param string $property The name of the property to set.
* @param mixed $value The new value.
*/
- public function __set($property, $value)
+ public function __set(string $property, mixed $value): void
{
$class = $this->popsValue();
$class::$$property = $value;
@@ -185,7 +185,7 @@ public function __set($property, $value)
*
* @return mixed The value of the property.
*/
- public function __get($property)
+ public function __get(string $property): mixed
{
$class = $this->popsValue();
@@ -202,7 +202,7 @@ public function __get($property)
*
* @return bool True if the property exists.
*/
- public function __isset($property)
+ public function __isset(string $property): bool
{
$class = $this->popsValue();
@@ -214,7 +214,7 @@ public function __isset($property)
*
* @param string $property The name of the property to set.
*/
- public function __unset($property)
+ public function __unset(string $property): void
{
$class = $this->popsValue();
@@ -226,7 +226,7 @@ public function __unset($property)
*
* @return string The string representation.
*/
- public function __toString()
+ public function __toString(): string
{
return $this->popsValue();
}
@@ -236,7 +236,7 @@ public function __toString()
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\Proxy';
}
@@ -249,7 +249,7 @@ protected static function popsProxyClass()
*
* @return mixed The proxied value, or the untouched value.
*/
- protected static function popsProxySubValue($value, $isRecursive)
+ protected static function popsProxySubValue(mixed $value, bool $isRecursive): mixed
{
if ($isRecursive) {
$popsProxyClass = static::popsProxyClass();
@@ -263,17 +263,17 @@ protected static function popsProxySubValue($value, $isRecursive)
/**
* Generate a static class proxy definition.
*
- * @param string $class The name of the class to proxy.
+ * @param string $originalClass The name of the class to proxy.
* @param bool $isRecursive True if the proxy should be recursive.
* @param string|null &$proxyClass The class name to use for the proxy class.
*
* @return string The proxy class definition.
*/
protected static function popsStaticClassProxyDefinition(
- $originalClass,
- $isRecursive,
- &$proxyClass
- ) {
+ string $originalClass,
+ bool $isRecursive,
+ ?string &$proxyClass
+ ): string {
$proxyClass = static::popsStaticClassProxyDefinitionProxyClass(
$originalClass,
$proxyClass
@@ -298,9 +298,9 @@ protected static function popsStaticClassProxyDefinition(
* @return string The proxy class name.
*/
protected static function popsStaticClassProxyDefinitionProxyClass(
- $originalClass,
- $proxyClass
- ) {
+ string $originalClass,
+ ?string $proxyClass
+ ): string {
if (null === $proxyClass) {
$originalClassParts = explode('\\', $originalClass);
$proxyClassPrefix = array_pop($originalClassParts) . '_Pops_';
@@ -325,7 +325,7 @@ protected static function popsStaticClassProxyDefinitionProxyClass(
*
* @return string The static class proxy class header.
*/
- protected static function popsStaticClassProxyDefinitionHeader($proxyClass)
+ protected static function popsStaticClassProxyDefinitionHeader(string $proxyClass): string
{
$proxyClassParts = explode('\\', $proxyClass);
$proxyClass = array_pop($proxyClassParts);
@@ -356,12 +356,12 @@ protected static function popsStaticClassProxyDefinitionHeader($proxyClass)
* @return string The static class proxy class body.
*/
protected static function popsStaticClassProxyDefinitionBody(
- $originalClass,
- $isRecursive
- ) {
+ string $originalClass,
+ bool $isRecursive
+ ): string {
return sprintf(
- 'protected static $popsStaticOriginalClass = %s; ' .
- 'protected static $isPopsStaticRecursive = %s;',
+ 'protected static ?string $popsStaticOriginalClass = %s; ' .
+ 'protected static bool $isPopsStaticRecursive = %s;',
var_export($originalClass, true),
var_export($isRecursive, true)
);
@@ -375,15 +375,15 @@ protected static function popsStaticClassProxyDefinitionBody(
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- protected function assertPopsValue($value)
+ protected function assertPopsValue(mixed $value): void
{
if (!class_exists($value)) {
throw new Exception\InvalidTypeException($value, 'class name');
}
}
- protected static $popsStaticOriginalClass;
- protected static $isPopsStaticRecursive;
- private static $popsStaticProxies = [];
- private $isPopsRecursive;
+ protected static ?string $popsStaticOriginalClass = null;
+ protected static bool $isPopsStaticRecursive = false;
+ private static array $popsStaticProxies = [];
+ private bool $isPopsRecursive;
}
diff --git a/src/ProxyClassInterface.php b/src/ProxyClassInterface.php
index f60dda8..2beab83 100644
--- a/src/ProxyClassInterface.php
+++ b/src/ProxyClassInterface.php
@@ -21,7 +21,7 @@ interface ProxyClassInterface extends ProxyInterface
*
* @return bool True if the wrapped class is recursively proxied.
*/
- public function isPopsRecursive();
+ public function isPopsRecursive(): bool;
/**
* Call a static method on the proxied class with support for by-reference
@@ -32,7 +32,7 @@ public function isPopsRecursive();
*
* @return mixed The result of the method call.
*/
- public function popsCall($method, array &$arguments);
+ public function popsCall(string $method, array &$arguments): mixed;
/**
* Call a static method on the proxied class.
@@ -42,7 +42,7 @@ public function popsCall($method, array &$arguments);
*
* @return mixed The result of the method call.
*/
- public function __call($method, array $arguments);
+ public function __call(string $method, array $arguments): mixed;
/**
* Set the value of a static property on the proxied class.
@@ -50,7 +50,7 @@ public function __call($method, array $arguments);
* @param string $property The name of the property to set.
* @param mixed $value The new value.
*/
- public function __set($property, $value);
+ public function __set(string $property, mixed $value): void;
/**
* Get the value of a static property on the proxied class.
@@ -59,7 +59,7 @@ public function __set($property, $value);
*
* @return mixed The value of the property.
*/
- public function __get($property);
+ public function __get(string $property): mixed;
/**
* Returns true if the supplied static property exists on the proxied class.
@@ -68,12 +68,12 @@ public function __get($property);
*
* @return bool True if the property exists.
*/
- public function __isset($property);
+ public function __isset(string $property): bool;
/**
* Set the value of a static property on the proxied class to null.
*
* @param string $property The name of the property to set.
*/
- public function __unset($property);
+ public function __unset(string $property): void;
}
diff --git a/src/ProxyInterface.php b/src/ProxyInterface.php
index 8033e90..a34d889 100644
--- a/src/ProxyInterface.php
+++ b/src/ProxyInterface.php
@@ -23,19 +23,19 @@ interface ProxyInterface
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- public function setPopsValue($value);
+ public function setPopsValue(mixed $value): void;
/**
* Get the wrapped value.
*
* @return mixed The wrapped value.
*/
- public function popsValue();
+ public function popsValue(): mixed;
/**
* Get the string representation of this value.
*
* @return string The string representation.
*/
- public function __toString();
+ public function __toString(): string;
}
diff --git a/src/ProxyObject.php b/src/ProxyObject.php
index d5efeb8..d5d6d2e 100644
--- a/src/ProxyObject.php
+++ b/src/ProxyObject.php
@@ -29,7 +29,7 @@ class ProxyObject extends AbstractTraversableProxy implements
*
* @return object The wrapped object.
*/
- public function popsObject()
+ public function popsObject(): object
{
return $this->popsValue();
}
@@ -43,7 +43,7 @@ public function popsObject()
*
* @return mixed The result of the method call.
*/
- public function popsCall($method, array &$arguments)
+ public function popsCall(string $method, array &$arguments): mixed
{
return $this->popsProxySubValue(
call_user_func_array([$this->popsValue(), $method], $arguments)
@@ -58,7 +58,7 @@ public function popsCall($method, array &$arguments)
*
* @return mixed The result of the method call.
*/
- public function __call($method, array $arguments)
+ public function __call(string $method, array $arguments): mixed
{
return $this->popsCall($method, $arguments);
}
@@ -68,7 +68,7 @@ public function __call($method, array $arguments)
*
* @return mixed The result of invocation.
*/
- public function __invoke()
+ public function __invoke(): mixed
{
return $this->__call('__invoke', func_get_args());
}
@@ -79,7 +79,7 @@ public function __invoke()
* @param string $property The property name.
* @param mixed $value The new value.
*/
- public function __set($property, $value)
+ public function __set(string $property, mixed $value): void
{
$this->popsValue()->$property = $value;
}
@@ -91,7 +91,7 @@ public function __set($property, $value)
*
* @return mixed The property value.
*/
- public function __get($property)
+ public function __get(string $property): mixed
{
return $this->popsProxySubValue($this->popsValue()->$property);
}
@@ -103,7 +103,7 @@ public function __get($property)
*
* @return bool True if the property exists.
*/
- public function __isset($property)
+ public function __isset(string $property): bool
{
return isset($this->popsValue()->$property);
}
@@ -113,7 +113,7 @@ public function __isset($property)
*
* @param string $property The property name.
*/
- public function __unset($property)
+ public function __unset(string $property): void
{
unset($this->popsValue()->$property);
}
@@ -124,7 +124,7 @@ public function __unset($property)
* @param string $key The key to set.
* @param mixed $value The new value.
*/
- public function offsetSet($key, $value): void
+ public function offsetSet(mixed $key, mixed $value): void
{
$this->__call('offsetSet', func_get_args());
}
@@ -136,8 +136,7 @@ public function offsetSet($key, $value): void
*
* @return mixed The value.
*/
- #[\ReturnTypeWillChange]
- public function offsetGet($key)
+ public function offsetGet(mixed $key): mixed
{
return $this->__call('offsetGet', func_get_args());
}
@@ -150,7 +149,7 @@ public function offsetGet($key)
*
* @return bool True if the key exists.
*/
- public function offsetExists($key): bool
+ public function offsetExists(mixed $key): bool
{
return $this->__call('offsetExists', func_get_args());
}
@@ -160,7 +159,7 @@ public function offsetExists($key): bool
*
* @param string $key The key to remove.
*/
- public function offsetUnset($key): void
+ public function offsetUnset(mixed $key): void
{
$this->__call('offsetUnset', func_get_args());
}
@@ -180,7 +179,7 @@ public function count(): int
*
* @return string The string representation.
*/
- public function __toString()
+ public function __toString(): string
{
return strval($this->__call('__toString', []));
}
@@ -190,7 +189,7 @@ public function __toString()
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\Proxy';
}
@@ -203,7 +202,7 @@ protected static function popsProxyClass()
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- protected function assertPopsValue($value)
+ protected function assertPopsValue(mixed $value): void
{
if (!is_object($value)) {
throw new Exception\InvalidTypeException($value, 'object');
@@ -215,7 +214,7 @@ protected function assertPopsValue($value)
*
* @return Iterator An iterator for the wrapped object.
*/
- protected function popsCreateInnerIterator()
+ protected function popsCreateInnerIterator(): Iterator
{
if ($this->popsValue() instanceof Iterator) {
$iterator = $this->popsValue();
diff --git a/src/ProxyObjectInterface.php b/src/ProxyObjectInterface.php
index 2cc7217..46b05fc 100644
--- a/src/ProxyObjectInterface.php
+++ b/src/ProxyObjectInterface.php
@@ -33,7 +33,7 @@ interface ProxyObjectInterface extends
*
* @return mixed The result of the method call.
*/
- public function popsCall($method, array &$arguments);
+ public function popsCall(string $method, array &$arguments): mixed;
/**
* Call a method on the wrapped object.
@@ -43,14 +43,14 @@ public function popsCall($method, array &$arguments);
*
* @return mixed The result of the method call.
*/
- public function __call($method, array $arguments);
+ public function __call(string $method, array $arguments): mixed;
/**
* Invoke this object.
*
* @return mixed The result of invocation.
*/
- public function __invoke();
+ public function __invoke(): mixed;
/**
* Set the value of a property on the wrapped object.
@@ -58,7 +58,7 @@ public function __invoke();
* @param string $property The property name.
* @param mixed $value The new value.
*/
- public function __set($property, $value);
+ public function __set(string $property, mixed $value): void;
/**
* Get the value of a property from the wrapped object.
@@ -67,7 +67,7 @@ public function __set($property, $value);
*
* @return mixed The property value.
*/
- public function __get($property);
+ public function __get(string $property): mixed;
/**
* Returns true if the property exists on the wrapped object.
@@ -76,12 +76,12 @@ public function __get($property);
*
* @return bool True if the property exists.
*/
- public function __isset($property);
+ public function __isset(string $property): bool;
/**
* Unset a property from the wrapped object.
*
* @param string $property The property name.
*/
- public function __unset($property);
+ public function __unset(string $property): void;
}
diff --git a/src/ProxyPrimitive.php b/src/ProxyPrimitive.php
index 2da59b4..6ac9fb2 100644
--- a/src/ProxyPrimitive.php
+++ b/src/ProxyPrimitive.php
@@ -24,7 +24,7 @@ class ProxyPrimitive extends AbstractProxy implements ProxyPrimitiveInterface
*
* @return scalar|null The wrapped value.
*/
- public function popsPrimitive()
+ public function popsPrimitive(): mixed
{
return $this->popsValue();
}
@@ -34,7 +34,7 @@ public function popsPrimitive()
*
* @return string The string representation.
*/
- public function __toString()
+ public function __toString(): string
{
return strval($this->popsValue());
}
@@ -47,7 +47,7 @@ public function __toString()
*
* @throws Exception\InvalidTypeException If the supplied value is not the correct type.
*/
- protected function assertPopsValue($value)
+ protected function assertPopsValue(mixed $value): void
{
if (!is_scalar($value)) {
throw new Exception\InvalidTypeException($value, 'scalar|null');
diff --git a/src/Safe/SafeProxyArray.php b/src/Safe/SafeProxyArray.php
index 48ea6ba..61f17a4 100644
--- a/src/Safe/SafeProxyArray.php
+++ b/src/Safe/SafeProxyArray.php
@@ -23,7 +23,7 @@ class SafeProxyArray extends ProxyArray implements SafeInterface
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\SafeProxy';
}
diff --git a/src/Safe/SafeProxyClass.php b/src/Safe/SafeProxyClass.php
index 652eefc..7ebb562 100644
--- a/src/Safe/SafeProxyClass.php
+++ b/src/Safe/SafeProxyClass.php
@@ -23,7 +23,7 @@ class SafeProxyClass extends ProxyClass implements SafeInterface
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\SafeProxy';
}
diff --git a/src/Safe/SafeProxyObject.php b/src/Safe/SafeProxyObject.php
index 9dfe705..75f3672 100644
--- a/src/Safe/SafeProxyObject.php
+++ b/src/Safe/SafeProxyObject.php
@@ -23,7 +23,7 @@ class SafeProxyObject extends ProxyObject implements SafeInterface
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\SafeProxy';
}
diff --git a/src/TraversableProxyInterface.php b/src/TraversableProxyInterface.php
index 7e24210..bea971d 100644
--- a/src/TraversableProxyInterface.php
+++ b/src/TraversableProxyInterface.php
@@ -21,5 +21,5 @@ interface TraversableProxyInterface extends ProxyInterface
*
* @return bool True if the wrapped value is recursively proxied.
*/
- public function isPopsRecursive();
+ public function isPopsRecursive(): bool;
}
diff --git a/test/src/OutputEscaper/OutputEscaperProxyArray.php b/test/src/OutputEscaper/OutputEscaperProxyArray.php
index 80caa88..4e746c9 100644
--- a/test/src/OutputEscaper/OutputEscaperProxyArray.php
+++ b/test/src/OutputEscaper/OutputEscaperProxyArray.php
@@ -23,7 +23,7 @@ class OutputEscaperProxyArray extends ProxyArray
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
diff --git a/test/src/OutputEscaper/OutputEscaperProxyClass.php b/test/src/OutputEscaper/OutputEscaperProxyClass.php
index f6eb419..f32109a 100644
--- a/test/src/OutputEscaper/OutputEscaperProxyClass.php
+++ b/test/src/OutputEscaper/OutputEscaperProxyClass.php
@@ -23,7 +23,7 @@ class OutputEscaperProxyClass extends ProxyClass
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
diff --git a/test/src/OutputEscaper/OutputEscaperProxyObject.php b/test/src/OutputEscaper/OutputEscaperProxyObject.php
index 17a2f53..ef8601e 100644
--- a/test/src/OutputEscaper/OutputEscaperProxyObject.php
+++ b/test/src/OutputEscaper/OutputEscaperProxyObject.php
@@ -23,7 +23,7 @@ class OutputEscaperProxyObject extends ProxyObject
*
* @return string The proxy class.
*/
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\OutputEscaperProxy';
}
diff --git a/test/src/OutputEscaper/OutputEscaperProxyPrimitive.php b/test/src/OutputEscaper/OutputEscaperProxyPrimitive.php
index e7bbd66..5f1c420 100644
--- a/test/src/OutputEscaper/OutputEscaperProxyPrimitive.php
+++ b/test/src/OutputEscaper/OutputEscaperProxyPrimitive.php
@@ -23,7 +23,7 @@ class OutputEscaperProxyPrimitive extends ProxyPrimitive
*
* @return string The HTML-secaped version of this primitive.
*/
- public function __toString()
+ public function __toString(): string
{
return htmlspecialchars(
strval($this->popsValue()),
diff --git a/test/src/Test/Fixture/ArrayAccess.php b/test/src/Test/Fixture/ArrayAccess.php
index 545469f..f4fbbe1 100644
--- a/test/src/Test/Fixture/ArrayAccess.php
+++ b/test/src/Test/Fixture/ArrayAccess.php
@@ -15,23 +15,22 @@
class ArrayAccess extends Obj implements ArrayAccessInterface
{
- public function offsetSet($property, $value): void
+ public function offsetSet(mixed $property, mixed $value): void
{
$this->values[$property] = $value;
}
- #[\ReturnTypeWillChange]
- public function offsetGet($property)
+ public function offsetGet(mixed $property): mixed
{
return $this->values[$property];
}
- public function offsetExists($property): bool
+ public function offsetExists(mixed $property): bool
{
return array_key_exists($property, $this->values);
}
- public function offsetUnset($property): void
+ public function offsetUnset(mixed $property): void
{
unset($this->values[$property]);
}
diff --git a/test/src/Test/Fixture/Iterator.php b/test/src/Test/Fixture/Iterator.php
index b50aadf..c90108f 100644
--- a/test/src/Test/Fixture/Iterator.php
+++ b/test/src/Test/Fixture/Iterator.php
@@ -22,14 +22,12 @@ public function __construct(array $values)
$this->iterator = new ArrayIterator($this->values);
}
- #[\ReturnTypeWillChange]
- public function current()
+ public function current(): mixed
{
return $this->iterator->current();
}
- #[\ReturnTypeWillChange]
- public function key()
+ public function key(): mixed
{
return $this->iterator->key();
}
diff --git a/test/src/Test/Fixture/Uppercase/UppercaseProxyArray.php b/test/src/Test/Fixture/Uppercase/UppercaseProxyArray.php
index b7106a3..c330d62 100644
--- a/test/src/Test/Fixture/Uppercase/UppercaseProxyArray.php
+++ b/test/src/Test/Fixture/Uppercase/UppercaseProxyArray.php
@@ -15,7 +15,7 @@
class UppercaseProxyArray extends ProxyArray
{
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\UppercaseProxy';
}
diff --git a/test/src/Test/Fixture/Uppercase/UppercaseProxyClass.php b/test/src/Test/Fixture/Uppercase/UppercaseProxyClass.php
index ad52261..f0aaa3e 100644
--- a/test/src/Test/Fixture/Uppercase/UppercaseProxyClass.php
+++ b/test/src/Test/Fixture/Uppercase/UppercaseProxyClass.php
@@ -15,7 +15,7 @@
class UppercaseProxyClass extends ProxyClass
{
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\UppercaseProxy';
}
diff --git a/test/src/Test/Fixture/Uppercase/UppercaseProxyObject.php b/test/src/Test/Fixture/Uppercase/UppercaseProxyObject.php
index bbb3464..7c7f84c 100644
--- a/test/src/Test/Fixture/Uppercase/UppercaseProxyObject.php
+++ b/test/src/Test/Fixture/Uppercase/UppercaseProxyObject.php
@@ -15,7 +15,7 @@
class UppercaseProxyObject extends ProxyObject
{
- protected static function popsProxyClass()
+ protected static function popsProxyClass(): string
{
return __NAMESPACE__ . '\UppercaseProxy';
}
diff --git a/test/src/Test/Fixture/Uppercase/UppercaseProxyPrimitive.php b/test/src/Test/Fixture/Uppercase/UppercaseProxyPrimitive.php
index 2922a7b..53fdc6e 100644
--- a/test/src/Test/Fixture/Uppercase/UppercaseProxyPrimitive.php
+++ b/test/src/Test/Fixture/Uppercase/UppercaseProxyPrimitive.php
@@ -15,7 +15,7 @@
class UppercaseProxyPrimitive extends ProxyPrimitive
{
- public function __toString()
+ public function __toString(): string
{
return mb_strtoupper(strval($this->popsValue()));
}
diff --git a/test/src/UppercaseProxyObject.php b/test/src/UppercaseProxyObject.php
index f45ca68..a5d7b68 100644
--- a/test/src/UppercaseProxyObject.php
+++ b/test/src/UppercaseProxyObject.php
@@ -9,16 +9,18 @@
* file that was distributed with this source code.
*/
+namespace Eloquent\Pops;
+
use Eloquent\Pops\ProxyObject;
class UppercaseProxyObject extends ProxyObject
{
- public function popsCall($method, array &$arguments)
+ public function popsCall(string $method, array &$arguments): mixed
{
return strtoupper(parent::popsCall($method, $arguments));
}
- public function __get($property)
+ public function __get(string $property): mixed
{
return strtoupper(parent::__get($property));
}
diff --git a/test/suite/FunctionalTest.php b/test/suite/FunctionalTest.php
index b9da520..a53dbc7 100644
--- a/test/suite/FunctionalTest.php
+++ b/test/suite/FunctionalTest.php
@@ -11,6 +11,7 @@
use Eloquent\Pops\Proxy;
use Eloquent\Pops\Safe\SafeProxy;
+use Eloquent\Pops\UppercaseProxyObject;
use OutputEscaper\OutputEscaperProxy;
use PHPUnit\Framework\TestCase;