Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Database / StatementEmpty.php
1 <?php
2
3 namespace Drupal\Core\Database;
4
5 /**
6  * Empty implementation of a database statement.
7  *
8  * This class satisfies the requirements of being a database statement/result
9  * object, but does not actually contain data.  It is useful when developers
10  * need to safely return an "empty" result set without connecting to an actual
11  * database.  Calling code can then treat it the same as if it were an actual
12  * result set that happens to contain no records.
13  *
14  * @see \Drupal\search\SearchQuery
15  */
16 class StatementEmpty implements \Iterator, StatementInterface {
17
18   /**
19    * Is rowCount() execution allowed.
20    *
21    * @var bool
22    */
23   public $allowRowCount = FALSE;
24
25   /**
26    * {@inheritdoc}
27    */
28   public function execute($args = [], $options = []) {
29     return FALSE;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function getQueryString() {
36     return '';
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function rowCount() {
43     if ($this->allowRowCount) {
44       return 0;
45     }
46     throw new RowCountException();
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function setFetchMode($mode, $a1 = NULL, $a2 = []) {
53     return;
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) {
60     return NULL;
61   }
62
63   /**
64    * {@inheritdoc}
65    */
66   public function fetchField($index = 0) {
67     return NULL;
68   }
69
70   /**
71    * {@inheritdoc}
72    */
73   public function fetchObject() {
74     return NULL;
75   }
76
77   /**
78    * {@inheritdoc}
79    */
80   public function fetchAssoc() {
81     return NULL;
82   }
83
84   /**
85    * {@inheritdoc}
86    */
87   public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) {
88     return [];
89   }
90
91   /**
92    * {@inheritdoc}
93    */
94   public function fetchCol($index = 0) {
95     return [];
96   }
97
98   /**
99    * {@inheritdoc}
100    */
101   public function fetchAllKeyed($key_index = 0, $value_index = 1) {
102     return [];
103   }
104
105   /**
106    * {@inheritdoc}
107    */
108   public function fetchAllAssoc($key, $fetch = NULL) {
109     return [];
110   }
111
112   /**
113    * {@inheritdoc}
114    */
115   public function current() {
116     return NULL;
117   }
118
119   /**
120    * {@inheritdoc}
121    */
122   public function key() {
123     return NULL;
124   }
125
126   /**
127    * {@inheritdoc}
128    */
129   public function rewind() {
130     // Nothing to do: our DatabaseStatement can't be rewound.
131   }
132
133   /**
134    * {@inheritdoc}
135    */
136   public function next() {
137     // Do nothing, since this is an always-empty implementation.
138   }
139
140   /**
141    * {@inheritdoc}
142    */
143   public function valid() {
144     return FALSE;
145   }
146
147 }