3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Drupal\Core\Database; interface StatementInterface extends \Traversable { //protected function __construct(Connection $dbh); public function execute($args = array(), $options = array()); public function getQueryString(); public function rowCount(); public function setFetchMode($mode, $a1 = NULL, $a2 = array()); public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL); public function fetchField($index = 0); public function fetchObject(); public function fetchAssoc(); public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL); public function fetchCol($index = 0); public function fetchAllKeyed($key_index = 0, $value_index = 1); public function fetchAllAssoc($key, $fetch = NULL); } class Statement extends \PDOStatement implements StatementInterface { public $dbh; public $allowRowCount = FALSE; protected function __construct(Connection $dbh) { $this->dbh = $dbh; $this->setFetchMode(\PDO::FETCH_OBJ); } public function execute($args = array(), $options = array()) { if (isset($options['fetch'])) { if (is_string($options['fetch'])) { // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties // are added to the object. $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']); } else { $this->setFetchMode($options['fetch']); } } $logger = $this->dbh->getLogger(); if (!empty($logger)) { $query_start = microtime(TRUE); } $return = parent::execute($args); if (!empty($logger)) { $query_end = microtime(TRUE); $logger->log($this, $args, $query_end - $query_start); } return $return; } public function getQueryString() { return $this->queryString; } public function fetchCol($index = 0) { return $this->fetchAll(\PDO::FETCH_COLUMN, $index); } public function fetchAllAssoc($key, $fetch = NULL) { $return = array(); if (isset($fetch)) { if (is_string($fetch)) { $this->setFetchMode(\PDO::FETCH_CLASS, $fetch); } else { $this->setFetchMode($fetch); } } foreach ($this as $record) { $record_key = is_object($record) ? $record->$key : $record[$key]; $return[$record_key] = $record; } return $return; } public function fetchAllKeyed($key_index = 0, $value_index = 1) { $return = array(); $this->setFetchMode(\PDO::FETCH_NUM); foreach ($this as $record) { $return[$record[$key_index]] = $record[$value_index]; } return $return; } public function fetchField($index = 0) { // Call \PDOStatement::fetchColumn to fetch the field. return $this->fetchColumn($index); } public function fetchAssoc() { // Call \PDOStatement::fetch to fetch the row. return $this->fetch(\PDO::FETCH_ASSOC); } /** * {@inheritdoc} */ public function rowCount() { // SELECT query should not use the method. if ($this->allowRowCount) { return parent::rowCount(); } else { throw new RowCountException(); } } /** * {@inheritdoc} */ public function setFetchMode($mode, $a1 = NULL, $a2 = array()) { parent::setFetchMode($mode); } /** * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { parent::fetchAll($mode, $column_index, $constructor_arguments); } } class Connection {}
Output for 8.0.7 - 8.0.11
Fatal error: Declaration of Drupal\Core\Database\Statement::fetchAll($mode = null, $column_index = null, $constructor_arguments = null) must be compatible with PDOStatement::fetchAll(int $mode = PDO::FETCH_DEFAULT, mixed ...$args) in /in/bTuOC on line 140
Process exited with code 255.
Output for 8.0.0 - 8.0.6
Fatal error: Declaration of Drupal\Core\Database\Statement::fetchAll($mode = null, $column_index = null, $constructor_arguments = null) must be compatible with PDOStatement::fetchAll(int $mode = PDO::FETCH_BOTH, mixed ...$args) in /in/bTuOC on line 140
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.30, 7.4.0 - 7.4.24
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/bTuOC on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/bTuOC on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/bTuOC on line 3
Process exited with code 255.

preferences:
209.26 ms | 401 KiB | 226 Q