From 48c557df316eb51d34539e77da77d23154802fc6 Mon Sep 17 00:00:00 2001 From: Micheal Mand Date: Mon, 31 Aug 2020 18:36:46 -0600 Subject: [PATCH 1/2] Allow PHP 7.4 Signed-off-by: Micheal Mand --- composer.json | 8 +- .../Http/Resources/DelegatesToResource.php | 134 ++++++++++++++++++ 2 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 overrides/Illuminate/Http/Resources/DelegatesToResource.php diff --git a/composer.json b/composer.json index 36cfe5941..f62aafba8 100644 --- a/composer.json +++ b/composer.json @@ -51,8 +51,12 @@ ], "psr-4": { "App\\": "app/", - "Modules\\": "Modules/" - } + "Modules\\": "Modules/", + "Illuminate\\Http\\Resources\\": "overrides/Illuminate/Http/Resources" + }, + "exclude-from-classmap": [ + "vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/overrides/Illuminate/Http/Resources/DelegatesToResource.php b/overrides/Illuminate/Http/Resources/DelegatesToResource.php new file mode 100644 index 000000000..036a14310 --- /dev/null +++ b/overrides/Illuminate/Http/Resources/DelegatesToResource.php @@ -0,0 +1,134 @@ +resource->getRouteKey(); + } + + /** + * Get the route key for the resource. + * + * @return string + */ + public function getRouteKeyName() + { + return $this->resource->getRouteKeyName(); + } + + /** + * Retrieve the model for a bound value. + * + * @param mixed $value + * @return void + * + * @throws \Exception + */ + public function resolveRouteBinding($value) + { + throw new Exception('Resources may not be implicitly resolved from route bindings.'); + } + + /** + * Determine if the given attribute exists. + * + * @param mixed $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->resource[$offset]); + } + + /** + * Get the value for a given offset. + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->resource[$offset]; + } + + /** + * Set the value for a given offset. + * + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + $this->resource[$offset] = $value; + } + + /** + * Unset the value for a given offset. + * + * @param mixed $offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->resource[$offset]); + } + + /** + * Determine if an attribute exists on the resource. + * + * @param string $key + * @return bool + */ + public function __isset($key) + { + return isset($this->resource->{$key}); + } + + /** + * Unset an attribute on the resource. + * + * @param string $key + * @return void + */ + public function __unset($key) + { + unset($this->resource->{$key}); + } + + /** + * Dynamically get properties from the underlying resource. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->resource->{$key}; + } + + /** + * Dynamically pass method calls to the underlying resource. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->forwardCallTo($this->resource, $method, $parameters); + } +} From 64e092b895ca9c0421c70890a70330ea49253d3e Mon Sep 17 00:00:00 2001 From: Micheal Mand Date: Wed, 2 Sep 2020 13:51:07 -0600 Subject: [PATCH 2/2] Add PHP 7.4 to Travis config Signed-off-by: Micheal Mand --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 51f5a4962..55db2dab7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4 cache: directories: @@ -23,4 +24,3 @@ before_script: script: vendor/bin/phpunit sudo: false -