<commit_before><?php
/**
 * PHP Version 5.4
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         CakePHP(tm) v 3.0.0
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
namespace Cake\Database\Statement;

class BufferedStatement extends StatementDecorator {

	protected $_count = 0;

	protected $_records = [];

	protected $_allFetched = true;

	protected $_counter = 0;

	public function execute($params = null) {
		$this->_count = $this->_counter = 0;
		$this->_records = [];
		$this->_allFetched = false;
		return parent::execute($params);
	}

	public function fetch($type = 'num') {
		if ($this->_allFetched) {
			$row = ($this->_counter < $this->_count) ? $this->_records[$this->_counter++] : false;
			$row = ($row && $type === 'num') ? array_values($row) : $row;
			return $row;
		}

		$this->_fetchType = $type;
		$record = parent::fetch($type);

		if ($record === false) {
			$this->_allFetched = true;
			$this->_counter = $this->_count + 1;
			return false;
		}

		$this->_count++;
		return $this->_records[] = $record;
	}

	public function fetchAll($type = 'num') {
		if ($this->_allFetched) {
			return $this->_records;
		}

		$this->_records = parent::fetchAll($type);
		$this->_count = count($this->_records);
		$this->_allFetched = true;
		return $this->_records;
	}

	public function rowCount() {
		if (!$this->_allFetched) {
			$counter = $this->_counter;
			while($this->fetch('assoc'));
			$this->_counter = $counter;
		}

		return $this->_count;
	}

	public function rewind() {
		$this->_counter = 0;
	}
}
<commit_msg>Making tests pass with MySQL<commit_after><?php
/**
 * PHP Version 5.4
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         CakePHP(tm) v 3.0.0
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
namespace Cake\Database\Statement;

class BufferedStatement extends StatementDecorator {

	protected $_count = 0;

	protected $_records = [];

	protected $_allFetched = true;

	protected $_counter = 0;

/**
 * Constructor
 *
 * @param Statement implementation such as PDOStatement
 * @return void
 */
	public function __construct($statement = null, $driver = null) {
		parent::__construct($statement, $driver);
		$this->_reset();
	}

	public function execute($params = null) {
		$this->_reset();
		return parent::execute($params);
	}

	public function fetch($type = 'num') {
		if ($this->_allFetched) {
			$row = ($this->_counter < $this->_count) ? $this->_records[$this->_counter++] : false;
			$row = ($row && $type === 'num') ? array_values($row) : $row;
			return $row;
		}

		$this->_fetchType = $type;
		$record = parent::fetch($type);

		if ($record === false) {
			$this->_allFetched = true;
			$this->_counter = $this->_count + 1;
			return false;
		}

		$this->_count++;
		return $this->_records[] = $record;
	}

	public function fetchAll($type = 'num') {
		if ($this->_allFetched) {
			return $this->_records;
		}

		$this->_records = parent::fetchAll($type);
		$this->_count = count($this->_records);
		$this->_allFetched = true;
		return $this->_records;
	}

	public function rowCount() {
		if (!$this->_allFetched) {
			$counter = $this->_counter;
			while($this->fetch('assoc'));
			$this->_counter = $counter;
		}

		return $this->_count;
	}

	public function rewind() {
		$this->_counter = 0;
	}

	public function _reset() {
		$this->_count = $this->_counter = 0;
		$this->_records = [];
		$this->_allFetched = false;
	}

}

{'fraction_non_alphanumeric': 0.1673601479426722, 'fraction_numerical': 0.004623208506703652, 'mean_word_length': 3.667745415318231, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1685083', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1375, 'n_words': 344}