Skip to content

Commit 2b2d173

Browse files
committed
PHP 8.1 > internal_method_return_types
https://wiki.php.net/rfc/internal_method_return_types PHP 8.0 added return type for abstract methods on Iterator, ArrayAccess, Countable, IteratorAggregate PHP 8.1 made non implementation as a Deprecated Warning PHP 9.0 (no release date at this moment) will drop the support. Temporary Fix : adding this Attribute #[\ReturnTypeWillChange] Will drop the Deprecated warning. Adding return type will break compatibility before PHP 7.4, Return type has been added on PHP 7.0, but "mixed" special type is required, and it has been added on PHP 7.4. In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4 Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment. Add missing Annotation
1 parent 85c07e7 commit 2b2d173

File tree

12 files changed

+33
-7
lines changed

12 files changed

+33
-7
lines changed

lib/Doctrine/Access.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function __isset($name)
8989
* @param string $name
9090
* @return void
9191
*/
92+
#[\ReturnTypeWillChange]
9293
public function __unset($name)
9394
{
9495
return $this->remove($name);
@@ -100,6 +101,7 @@ public function __unset($name)
100101
* @param mixed $offset
101102
* @return boolean Whether or not this object contains $offset
102103
*/
104+
#[\ReturnTypeWillChange]
103105
public function offsetExists($offset)
104106
{
105107
return $this->contains($offset);
@@ -112,6 +114,7 @@ public function offsetExists($offset)
112114
* @param mixed $offset
113115
* @return mixed
114116
*/
117+
#[\ReturnTypeWillChange]
115118
public function offsetGet($offset)
116119
{
117120
// array notation with no index was causing 'undefined variable: $offset' notices in php7,
@@ -131,6 +134,7 @@ public function offsetGet($offset)
131134
* @param mixed $value
132135
* @return void
133136
*/
137+
#[\ReturnTypeWillChange]
134138
public function offsetSet($offset, $value)
135139
{
136140
if ( ! isset($offset)) {
@@ -146,6 +150,7 @@ public function offsetSet($offset, $value)
146150
* @see set, offsetSet, __set
147151
* @param mixed $offset
148152
*/
153+
#[\ReturnTypeWillChange]
149154
public function offsetUnset($offset)
150155
{
151156
return $this->remove($offset);

lib/Doctrine/Collection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ public function getKeys()
456456
*
457457
* @return integer
458458
*/
459+
#[\ReturnTypeWillChange]
459460
public function count()
460461
{
461462
return count($this->data);
@@ -1060,6 +1061,7 @@ public function free($deep = false)
10601061
*
10611062
* @return Iterator
10621063
*/
1064+
#[\ReturnTypeWillChange]
10631065
public function getIterator()
10641066
{
10651067
$data = $this->data;

lib/Doctrine/Connection.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ public function getTables()
11781178
*
11791179
* @return ArrayIterator SPL ArrayIterator object
11801180
*/
1181+
#[\ReturnTypeWillChange]
11811182
public function getIterator()
11821183
{
11831184
return new ArrayIterator($this->tables);
@@ -1188,6 +1189,7 @@ public function getIterator()
11881189
*
11891190
* @return integer
11901191
*/
1192+
#[\ReturnTypeWillChange]
11911193
public function count()
11921194
{
11931195
return $this->_count;

lib/Doctrine/Connection/Profiler.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public function __construct() {
6868
* @return boolean
6969
*/
7070
public function setFilterQueryType() {
71-
72-
}
71+
72+
}
7373
/**
7474
* method overloader
7575
* this method is used for invoking different listeners, for the full
@@ -109,7 +109,7 @@ public function __call($m, $a)
109109
* @param mixed $key
110110
* @return Doctrine_Event
111111
*/
112-
public function get($key)
112+
public function get($key)
113113
{
114114
if (isset($this->events[$key])) {
115115
return $this->events[$key];
@@ -123,7 +123,7 @@ public function get($key)
123123
*
124124
* @return array all events in an array
125125
*/
126-
public function getAll()
126+
public function getAll()
127127
{
128128
return $this->events;
129129
}
@@ -134,17 +134,19 @@ public function getAll()
134134
*
135135
* @return ArrayIterator
136136
*/
137+
#[\ReturnTypeWillChange]
137138
public function getIterator()
138139
{
139140
return new ArrayIterator($this->events);
140141
}
141142

142143
/**
143144
* count
144-
*
145+
*
145146
* @return integer
146147
*/
147-
public function count()
148+
#[\ReturnTypeWillChange]
149+
public function count()
148150
{
149151
return count($this->events);
150152
}
@@ -154,7 +156,7 @@ public function count()
154156
*
155157
* @return Doctrine_Event
156158
*/
157-
public function pop()
159+
public function pop()
158160
{
159161
$event = array_pop($this->events);
160162
if ($event !== null)

lib/Doctrine/Manager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ public function contains($key)
638638
*
639639
* @return integer
640640
*/
641+
#[\ReturnTypeWillChange]
641642
public function count()
642643
{
643644
return count($this->_connections);
@@ -648,6 +649,7 @@ public function count()
648649
*
649650
* @return ArrayIterator
650651
*/
652+
#[\ReturnTypeWillChange]
651653
public function getIterator()
652654
{
653655
return new ArrayIterator($this->_connections);

lib/Doctrine/Query.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,7 @@ public function getCountSqlQuery()
21342134
* @param array $params an array of prepared statement parameters
21352135
* @return integer the count of this query
21362136
*/
2137+
#[\ReturnTypeWillChange]
21372138
public function count($params = array())
21382139
{
21392140
$q = $this->getCountSqlQuery();

lib/Doctrine/Record.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,7 @@ public function getPrepared(array $array = array())
18861886
*
18871887
* @return integer the number of columns in this record
18881888
*/
1889+
#[\ReturnTypeWillChange]
18891890
public function count()
18901891
{
18911892
return count($this->_data);
@@ -2183,6 +2184,7 @@ public function hasRelation($fieldName)
21832184
* implements IteratorAggregate interface
21842185
* @return Doctrine_Record_Iterator iterator through data
21852186
*/
2187+
#[\ReturnTypeWillChange]
21862188
public function getIterator()
21872189
{
21882190
return new Doctrine_Record_Iterator($this);

lib/Doctrine/Record/Iterator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static function initNullObject(Doctrine_Null $null)
6868
*
6969
* @return mixed
7070
*/
71+
#[\ReturnTypeWillChange]
7172
public function current()
7273
{
7374
$value = parent::current();

lib/Doctrine/Relation.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ public function isEqual()
169169
return $this->definition['equal'];
170170
}
171171

172+
#[\ReturnTypeWillChange]
172173
public function offsetExists($offset)
173174
{
174175
return isset($this->definition[$offset]);
175176
}
176177

178+
#[\ReturnTypeWillChange]
177179
public function offsetGet($offset)
178180
{
179181
if (isset($this->definition[$offset])) {
@@ -183,13 +185,15 @@ public function offsetGet($offset)
183185
return null;
184186
}
185187

188+
#[\ReturnTypeWillChange]
186189
public function offsetSet($offset, $value)
187190
{
188191
if (isset($this->definition[$offset])) {
189192
$this->definition[$offset] = $value;
190193
}
191194
}
192195

196+
#[\ReturnTypeWillChange]
193197
public function offsetUnset($offset)
194198
{
195199
$this->definition[$offset] = false;

lib/Doctrine/Table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,7 @@ final public function applyInheritance($where)
19821982
*
19831983
* @return integer number of records in the table
19841984
*/
1985+
#[\ReturnTypeWillChange]
19851986
public function count()
19861987
{
19871988
return $this->createQuery()->count();

0 commit comments

Comments
 (0)