Skip to content

Commit

Permalink
Fix php 8.1 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Jul 21, 2021
1 parent 5da0c38 commit a73e056
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Gd/Drawer.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ public function polygon(array $coordinates, ColorInterface $color, $fill = false
throw new RuntimeException('Draw polygon operation failed');
}

if (false === $callback($this->resource, $points, count($coordinates), $this->getColor($color))) {
if (false === (
PHP_VERSION_ID < 80000
? $callback($this->resource, $points, count($coordinates), $this->getColor($color))
: $callback($this->resource, $points, $this->getColor($color))
)) {
imagealphablending($this->resource, false);
throw new RuntimeException('Draw polygon operation failed');
}
Expand Down
10 changes: 10 additions & 0 deletions src/Gd/Layers.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function animate($format, $delay, $loops)
*
* @see \Iterator::current()
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->getClassFactory()->createImage(ClassFactoryInterface::HANDLE_GD, $this->resource, $this->palette, new MetadataBag());
Expand All @@ -104,6 +105,7 @@ public function current()
*
* @see \Iterator::key()
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->offset;
Expand All @@ -114,6 +116,7 @@ public function key()
*
* @see \Iterator::next()
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->offset;
Expand All @@ -124,6 +127,7 @@ public function next()
*
* @see \Iterator::rewind()
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->offset = 0;
Expand All @@ -134,6 +138,7 @@ public function rewind()
*
* @see \Iterator::valid()
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->offset < 1;
Expand All @@ -144,6 +149,7 @@ public function valid()
*
* @see \Countable::count()
*/
#[\ReturnTypeWillChange]
public function count()
{
return 1;
Expand All @@ -154,6 +160,7 @@ public function count()
*
* @see \ArrayAccess::offsetExists()
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return 0 === $offset;
Expand All @@ -164,6 +171,7 @@ public function offsetExists($offset)
*
* @see \ArrayAccess::offsetGet()
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (0 === $offset) {
Expand All @@ -178,6 +186,7 @@ public function offsetGet($offset)
*
* @see \ArrayAccess::offsetSet()
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
throw new NotSupportedException('GD does not support layer set');
Expand All @@ -188,6 +197,7 @@ public function offsetSet($offset, $value)
*
* @see \ArrayAccess::offsetUnset()
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
throw new NotSupportedException('GD does not support layer unset');
Expand Down
10 changes: 10 additions & 0 deletions src/Gmagick/Layers.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function animate($format, $delay, $loops)
*
* @see \Iterator::current()
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->extractAt($this->offset);
Expand Down Expand Up @@ -163,6 +164,7 @@ private function extractAt($offset)
*
* @see \Iterator::key()
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->offset;
Expand All @@ -173,6 +175,7 @@ public function key()
*
* @see \Iterator::next()
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->offset;
Expand All @@ -183,6 +186,7 @@ public function next()
*
* @see \Iterator::rewind()
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->offset = 0;
Expand All @@ -193,6 +197,7 @@ public function rewind()
*
* @see \Iterator::valid()
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->offset < count($this);
Expand All @@ -203,6 +208,7 @@ public function valid()
*
* @see \Countable::count()
*/
#[\ReturnTypeWillChange]
public function count()
{
try {
Expand All @@ -217,6 +223,7 @@ public function count()
*
* @see \ArrayAccess::offsetExists()
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return is_int($offset) && $offset >= 0 && $offset < count($this);
Expand All @@ -227,6 +234,7 @@ public function offsetExists($offset)
*
* @see \ArrayAccess::offsetGet()
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->extractAt($offset);
Expand All @@ -237,6 +245,7 @@ public function offsetGet($offset)
*
* @see \ArrayAccess::offsetSet()
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $image)
{
if (!$image instanceof Image) {
Expand Down Expand Up @@ -290,6 +299,7 @@ public function offsetSet($offset, $image)
*
* @see \ArrayAccess::offsetUnset()
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
try {
Expand Down
1 change: 1 addition & 0 deletions src/Image/Histogram/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function add($value)
/**
* @return int the number of elements in the bucket
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->count;
Expand Down
6 changes: 6 additions & 0 deletions src/Image/Metadata/MetadataBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function get($key, $default = null)
*
* @see \Countable::count()
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->data);
Expand All @@ -57,6 +58,7 @@ public function count()
*
* @see \IteratorAggregate::getIterator()
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new \ArrayIterator($this->data);
Expand All @@ -67,6 +69,7 @@ public function getIterator()
*
* @see \ArrayAccess::offsetExists()
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return array_key_exists($offset, $this->data);
Expand All @@ -77,6 +80,7 @@ public function offsetExists($offset)
*
* @see \ArrayAccess::offsetSet()
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->data[$offset] = $value;
Expand All @@ -87,6 +91,7 @@ public function offsetSet($offset, $value)
*
* @see \ArrayAccess::offsetUnset()
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->data[$offset]);
Expand All @@ -97,6 +102,7 @@ public function offsetUnset($offset)
*
* @see \ArrayAccess::offsetGet()
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($offset);
Expand Down
10 changes: 10 additions & 0 deletions src/Imagick/Layers.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function coalesce()
*
* @see \Iterator::current()
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->extractAt($this->offset);
Expand Down Expand Up @@ -174,6 +175,7 @@ private function extractAt($offset)
*
* @see \Iterator::key()
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->offset;
Expand All @@ -184,6 +186,7 @@ public function key()
*
* @see \Iterator::next()
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->offset;
Expand All @@ -194,6 +197,7 @@ public function next()
*
* @see \Iterator::rewind()
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->offset = 0;
Expand All @@ -204,6 +208,7 @@ public function rewind()
*
* @see \Iterator::valid()
*/
#[\ReturnTypeWillChange]
public function valid()
{
return $this->offset < count($this);
Expand All @@ -214,6 +219,7 @@ public function valid()
*
* @see \Countable::count()
*/
#[\ReturnTypeWillChange]
public function count()
{
try {
Expand All @@ -228,6 +234,7 @@ public function count()
*
* @see \ArrayAccess::offsetExists()
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return is_int($offset) && $offset >= 0 && $offset < count($this);
Expand All @@ -238,6 +245,7 @@ public function offsetExists($offset)
*
* @see \ArrayAccess::offsetGet()
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->extractAt($offset);
Expand All @@ -248,6 +256,7 @@ public function offsetGet($offset)
*
* @see \ArrayAccess::offsetSet()
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $image)
{
if (!$image instanceof Image) {
Expand Down Expand Up @@ -290,6 +299,7 @@ public function offsetSet($offset, $image)
*
* @see \ArrayAccess::offsetUnset()
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
try {
Expand Down

0 comments on commit a73e056

Please sign in to comment.