Skip to content

Commit 25cfd27

Browse files
committed
ResultSet::fetchField() removed argument (BC break)
1 parent d1e6f53 commit 25cfd27

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/Database/IRowContainer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ function fetch(): ?IRow;
2323

2424
/**
2525
* Fetches single field.
26-
* @param int|string
2726
* @return mixed
2827
*/
29-
function fetchField($column = 0);
28+
function fetchField();
3029

3130
/**
3231
* Fetches all rows as associative array.

src/Database/ResultSet.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ public function fetch(): ?IRow
252252
*/
253253
public function fetchField($column = 0)
254254
{
255+
if (func_num_args()) {
256+
trigger_error(__METHOD__ . '() argument is deprecated.', E_USER_DEPRECATED);
257+
}
255258
$row = $this->fetch();
256259
return $row ? $row[$column] : null;
257260
}

src/Database/Table/Selection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ public function fetch(): ?Nette\Database\IRow
209209
* Fetches single field.
210210
* @param string|null
211211
* @return mixed
212+
* @deprecated
212213
*/
213-
public function fetchField($column = null)
214+
public function fetchField(string $column = null)
214215
{
215216
if ($column) {
216217
$this->select($column);

tests/Database/ResultSet.fetchField().phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ test(function () use ($connection) {
1818
$res = $connection->query('SELECT name, id FROM author ORDER BY id');
1919

2020
Assert::same('Jakub Vrana', $res->fetchField());
21-
Assert::same(12, $res->fetchField(1));
22-
Assert::same('Geek', $res->fetchField('name'));
2321
});
2422

2523

0 commit comments

Comments
 (0)