Skip to content

Commit

Permalink
Fix PHP 8.1 deprecations (#243)
Browse files Browse the repository at this point in the history
* Fix PHP 8.1 deprecations

* Add 8.1 codeception test

* Fix PHP 8.0: Deprecate required parameters after optional parameters in function/method signatures
  • Loading branch information
blankse committed Dec 22, 2021
1 parent 89421b4 commit 8b7a45b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 77 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/codeception_pimcore_x.yml
Expand Up @@ -30,6 +30,7 @@ jobs:
matrix:
include:
- { php-version: 8.0, database: "mariadb:10.5", server_version: "5.5.5-10.5.0-MariaDB-0+deb10u1-log", dependencies: highest, experimental: false }
- { php-version: 8.1, database: "mariadb:10.5", server_version: "5.5.5-10.5.0-MariaDB-0+deb10u1-log", dependencies: highest, experimental: false }
# - { php-version: 8.0, database: "mariadb:10.3", dependencies: lowest, experimental: false }
# - { php-version: 8.0, database: "mysql:5.7", dependencies: lowest, experimental: false }
# - { php-version: 8.0, database: "mysql:8.0", dependencies: lowest, experimental: false }
Expand Down Expand Up @@ -88,4 +89,4 @@ jobs:
bin/console doctrine:migrations:sync-metadata-storage -vvv
- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --json"
run: "vendor/bin/codecept run -c . -vvv --json"
46 changes: 31 additions & 15 deletions src/ActionTrigger/RuleEnvironment.php
Expand Up @@ -49,69 +49,85 @@ public function get($name, $default = null)
}

/**
* @inheritDoc
* @return \ArrayIterator
*/
public function getIterator()
#[\ReturnTypeWillChange]
public function getIterator()/* : \ArrayIterator */
{
return new \ArrayIterator($this->data);
}

/**
* @inheritDoc
* @return bool
*/
public function offsetExists($offset): bool
{
return isset($this->data[$offset]);
}

/**
* @inheritDoc
* @return mixed
*/
public function offsetGet($offset)
#[\ReturnTypeWillChange]
public function offsetGet($offset)/* : mixed */
{
if (isset($this->data[$offset])) {
return $this->data[$offset];
}

return null;
}

/**
* @inheritDoc
* @param mixed $offset
* @param mixed $value
*
* @return void
*/
public function offsetSet($offset, $value)
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)/* : void */
{
$this->data[$offset] = $value;
}

/**
* @inheritDoc
* @param mixed $offset
*
* @return void
*/
public function offsetUnset($offset)
#[\ReturnTypeWillChange]
public function offsetUnset($offset)/* : void */
{
if (isset($this->data[$offset])) {
unset($this->data[$offset]);
}
}

/**
* @inheritDoc
* @return string
*/
public function serialize()
#[\ReturnTypeWillChange]
public function serialize()/* : string */
{
return serialize($this->data);
}

/**
* @inheritDoc
* @param string $serialized
*
* @return void
*/
public function unserialize($serialized)
#[\ReturnTypeWillChange]
public function unserialize($serialized)/* : void */
{
$this->data = unserialize($serialized);
}

/**
* @inheritDoc
* @return array
*/
public function jsonSerialize()
#[\ReturnTypeWillChange]
public function jsonSerialize()/* : array */
{
return $this->data;
}
Expand Down
75 changes: 21 additions & 54 deletions src/Model/ActivityList/DefaultMariaDbActivityList.php
Expand Up @@ -106,17 +106,10 @@ public function getItems($offset, $itemCountPerPage)
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Count elements of an object
*
* @link http://php.net/manual/en/countable.count.php
*
* @return int The custom count as an integer.
* </p>
* <p>
* The return value is cast to an integer.
* @return int
*/
public function count()
#[\ReturnTypeWillChange]
public function count()/* : int */
{
if ($this->totalCount === null) {
$this->totalCount = $this->dao->getCount();
Expand All @@ -134,77 +127,51 @@ public function getPaginatorAdapter()
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Return the current element
*
* @link http://php.net/manual/en/iterator.current.php
*
* @return mixed Can return any type.
* @return ActivityInterface|false
*/
public function current()
#[\ReturnTypeWillChange]
public function current()/* : ActivityInterface|false */
{
$this->getActivities();
$var = current($this->activities);

return $var;
return current($this->activities);
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Move forward to next element
*
* @link http://php.net/manual/en/iterator.next.php
*
* @return void Any returned value is ignored.
* @return void
*/
public function next()
#[\ReturnTypeWillChange]
public function next()/* : void */
{
$this->getActivities();
next($this->activities);
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Return the key of the current element
*
* @link http://php.net/manual/en/iterator.key.php
*
* @return \scalar scalar on success, integer
* 0 on failure.
* @return int|null
*/
public function key()
#[\ReturnTypeWillChange]
public function key()/* : int|null */
{
$this->getActivities();
$var = key($this->activities);

return $var;
return key($this->activities);
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Checks if current position is valid
*
* @link http://php.net/manual/en/iterator.valid.php
*
* @return bool The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
* @return bool
*/
public function valid()
#[\ReturnTypeWillChange]
public function valid()/* : bool */
{
$var = $this->current() !== false;

return $var;
return $this->current() !== false;
}

/**
* (PHP 5 &gt;= 5.1.0)<br/>
* Rewind the Iterator to the first element
*
* @link http://php.net/manual/en/iterator.rewind.php
*
* @return void Any returned value is ignored.
* @return void
*/
public function rewind()
#[\ReturnTypeWillChange]
public function rewind()/* : void */
{
$this->getActivities();
reset($this->activities);
Expand Down
2 changes: 1 addition & 1 deletion src/Newsletter/ProviderHandler/Mailchimp.php
Expand Up @@ -117,7 +117,7 @@ class Mailchimp implements NewsletterProviderHandlerInterface
*
* @throws \Exception
*/
public function __construct($shortcut, $listId, array $statusMapping = [], array $reverseStatusMapping = [], array $mergeFieldMapping = [], array $fieldTransformers = [], SegmentExporter $segmentExporter, SegmentManagerInterface $segmentManager, MailChimpExportService $exportService)
public function __construct($shortcut, $listId, array $statusMapping, array $reverseStatusMapping, array $mergeFieldMapping, array $fieldTransformers, SegmentExporter $segmentExporter, SegmentManagerInterface $segmentManager, MailChimpExportService $exportService)
{
if (!strlen($shortcut) || !File::getValidFilename($shortcut)) {
throw new \Exception('Please provide a valid newsletter provider handler shortcut.');
Expand Down
Expand Up @@ -28,11 +28,6 @@ class CliSyncProcessor
{
use ApplicationLoggerAware;

/**
* @var string|null
*/
protected $pimcoreUserName;

/**
* @var CustomerProviderInterface
*/
Expand All @@ -48,7 +43,7 @@ class CliSyncProcessor
*/
protected $newsletterManager;

public function __construct($pimcoreUserName = null, CustomerProviderInterface $customerProvider, UpdateFromMailchimpProcessor $updateFromMailchimpProcessor, NewsletterManagerInterface $newsletterManager)
public function __construct($pimcoreUserName, CustomerProviderInterface $customerProvider, UpdateFromMailchimpProcessor $updateFromMailchimpProcessor, NewsletterManagerInterface $newsletterManager)
{
$this->setLoggerComponent('NewsletterSync');

Expand Down

0 comments on commit 8b7a45b

Please sign in to comment.