Skip to content

Commit 8b7a45b

Browse files
authored
Fix PHP 8.1 deprecations (#243)
* Fix PHP 8.1 deprecations * Add 8.1 codeception test * Fix PHP 8.0: Deprecate required parameters after optional parameters in function/method signatures
1 parent 89421b4 commit 8b7a45b

File tree

5 files changed

+56
-77
lines changed

5 files changed

+56
-77
lines changed

.github/workflows/codeception_pimcore_x.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
matrix:
3131
include:
3232
- { php-version: 8.0, database: "mariadb:10.5", server_version: "5.5.5-10.5.0-MariaDB-0+deb10u1-log", dependencies: highest, experimental: false }
33+
- { php-version: 8.1, database: "mariadb:10.5", server_version: "5.5.5-10.5.0-MariaDB-0+deb10u1-log", dependencies: highest, experimental: false }
3334
# - { php-version: 8.0, database: "mariadb:10.3", dependencies: lowest, experimental: false }
3435
# - { php-version: 8.0, database: "mysql:5.7", dependencies: lowest, experimental: false }
3536
# - { php-version: 8.0, database: "mysql:8.0", dependencies: lowest, experimental: false }
@@ -88,4 +89,4 @@ jobs:
8889
bin/console doctrine:migrations:sync-metadata-storage -vvv
8990
9091
- name: "Run Codeception"
91-
run: "vendor/bin/codecept run -c . -vvv --json"
92+
run: "vendor/bin/codecept run -c . -vvv --json"

src/ActionTrigger/RuleEnvironment.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,69 +49,85 @@ public function get($name, $default = null)
4949
}
5050

5151
/**
52-
* @inheritDoc
52+
* @return \ArrayIterator
5353
*/
54-
public function getIterator()
54+
#[\ReturnTypeWillChange]
55+
public function getIterator()/* : \ArrayIterator */
5556
{
5657
return new \ArrayIterator($this->data);
5758
}
5859

5960
/**
60-
* @inheritDoc
61+
* @return bool
6162
*/
6263
public function offsetExists($offset): bool
6364
{
6465
return isset($this->data[$offset]);
6566
}
6667

6768
/**
68-
* @inheritDoc
69+
* @return mixed
6970
*/
70-
public function offsetGet($offset)
71+
#[\ReturnTypeWillChange]
72+
public function offsetGet($offset)/* : mixed */
7173
{
7274
if (isset($this->data[$offset])) {
7375
return $this->data[$offset];
7476
}
77+
78+
return null;
7579
}
7680

7781
/**
78-
* @inheritDoc
82+
* @param mixed $offset
83+
* @param mixed $value
84+
*
85+
* @return void
7986
*/
80-
public function offsetSet($offset, $value)
87+
#[\ReturnTypeWillChange]
88+
public function offsetSet($offset, $value)/* : void */
8189
{
8290
$this->data[$offset] = $value;
8391
}
8492

8593
/**
86-
* @inheritDoc
94+
* @param mixed $offset
95+
*
96+
* @return void
8797
*/
88-
public function offsetUnset($offset)
98+
#[\ReturnTypeWillChange]
99+
public function offsetUnset($offset)/* : void */
89100
{
90101
if (isset($this->data[$offset])) {
91102
unset($this->data[$offset]);
92103
}
93104
}
94105

95106
/**
96-
* @inheritDoc
107+
* @return string
97108
*/
98-
public function serialize()
109+
#[\ReturnTypeWillChange]
110+
public function serialize()/* : string */
99111
{
100112
return serialize($this->data);
101113
}
102114

103115
/**
104-
* @inheritDoc
116+
* @param string $serialized
117+
*
118+
* @return void
105119
*/
106-
public function unserialize($serialized)
120+
#[\ReturnTypeWillChange]
121+
public function unserialize($serialized)/* : void */
107122
{
108123
$this->data = unserialize($serialized);
109124
}
110125

111126
/**
112-
* @inheritDoc
127+
* @return array
113128
*/
114-
public function jsonSerialize()
129+
#[\ReturnTypeWillChange]
130+
public function jsonSerialize()/* : array */
115131
{
116132
return $this->data;
117133
}

src/Model/ActivityList/DefaultMariaDbActivityList.php

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,10 @@ public function getItems($offset, $itemCountPerPage)
106106
}
107107

108108
/**
109-
* (PHP 5 &gt;= 5.1.0)<br/>
110-
* Count elements of an object
111-
*
112-
* @link http://php.net/manual/en/countable.count.php
113-
*
114-
* @return int The custom count as an integer.
115-
* </p>
116-
* <p>
117-
* The return value is cast to an integer.
109+
* @return int
118110
*/
119-
public function count()
111+
#[\ReturnTypeWillChange]
112+
public function count()/* : int */
120113
{
121114
if ($this->totalCount === null) {
122115
$this->totalCount = $this->dao->getCount();
@@ -134,77 +127,51 @@ public function getPaginatorAdapter()
134127
}
135128

136129
/**
137-
* (PHP 5 &gt;= 5.1.0)<br/>
138-
* Return the current element
139-
*
140-
* @link http://php.net/manual/en/iterator.current.php
141-
*
142-
* @return mixed Can return any type.
130+
* @return ActivityInterface|false
143131
*/
144-
public function current()
132+
#[\ReturnTypeWillChange]
133+
public function current()/* : ActivityInterface|false */
145134
{
146135
$this->getActivities();
147-
$var = current($this->activities);
148136

149-
return $var;
137+
return current($this->activities);
150138
}
151139

152140
/**
153-
* (PHP 5 &gt;= 5.1.0)<br/>
154-
* Move forward to next element
155-
*
156-
* @link http://php.net/manual/en/iterator.next.php
157-
*
158-
* @return void Any returned value is ignored.
141+
* @return void
159142
*/
160-
public function next()
143+
#[\ReturnTypeWillChange]
144+
public function next()/* : void */
161145
{
162146
$this->getActivities();
163147
next($this->activities);
164148
}
165149

166150
/**
167-
* (PHP 5 &gt;= 5.1.0)<br/>
168-
* Return the key of the current element
169-
*
170-
* @link http://php.net/manual/en/iterator.key.php
171-
*
172-
* @return \scalar scalar on success, integer
173-
* 0 on failure.
151+
* @return int|null
174152
*/
175-
public function key()
153+
#[\ReturnTypeWillChange]
154+
public function key()/* : int|null */
176155
{
177156
$this->getActivities();
178-
$var = key($this->activities);
179157

180-
return $var;
158+
return key($this->activities);
181159
}
182160

183161
/**
184-
* (PHP 5 &gt;= 5.1.0)<br/>
185-
* Checks if current position is valid
186-
*
187-
* @link http://php.net/manual/en/iterator.valid.php
188-
*
189-
* @return bool The return value will be casted to boolean and then evaluated.
190-
* Returns true on success or false on failure.
162+
* @return bool
191163
*/
192-
public function valid()
164+
#[\ReturnTypeWillChange]
165+
public function valid()/* : bool */
193166
{
194-
$var = $this->current() !== false;
195-
196-
return $var;
167+
return $this->current() !== false;
197168
}
198169

199170
/**
200-
* (PHP 5 &gt;= 5.1.0)<br/>
201-
* Rewind the Iterator to the first element
202-
*
203-
* @link http://php.net/manual/en/iterator.rewind.php
204-
*
205-
* @return void Any returned value is ignored.
171+
* @return void
206172
*/
207-
public function rewind()
173+
#[\ReturnTypeWillChange]
174+
public function rewind()/* : void */
208175
{
209176
$this->getActivities();
210177
reset($this->activities);

src/Newsletter/ProviderHandler/Mailchimp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class Mailchimp implements NewsletterProviderHandlerInterface
117117
*
118118
* @throws \Exception
119119
*/
120-
public function __construct($shortcut, $listId, array $statusMapping = [], array $reverseStatusMapping = [], array $mergeFieldMapping = [], array $fieldTransformers = [], SegmentExporter $segmentExporter, SegmentManagerInterface $segmentManager, MailChimpExportService $exportService)
120+
public function __construct($shortcut, $listId, array $statusMapping, array $reverseStatusMapping, array $mergeFieldMapping, array $fieldTransformers, SegmentExporter $segmentExporter, SegmentManagerInterface $segmentManager, MailChimpExportService $exportService)
121121
{
122122
if (!strlen($shortcut) || !File::getValidFilename($shortcut)) {
123123
throw new \Exception('Please provide a valid newsletter provider handler shortcut.');

src/Newsletter/ProviderHandler/Mailchimp/CliSyncProcessor.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ class CliSyncProcessor
2828
{
2929
use ApplicationLoggerAware;
3030

31-
/**
32-
* @var string|null
33-
*/
34-
protected $pimcoreUserName;
35-
3631
/**
3732
* @var CustomerProviderInterface
3833
*/
@@ -48,7 +43,7 @@ class CliSyncProcessor
4843
*/
4944
protected $newsletterManager;
5045

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

0 commit comments

Comments
 (0)