Skip to content

5.x upgrade snippets

Mark Scherer edited this page Sep 22, 2023 · 13 revisions

CakePHP 5

src/

-public function beforeFind(EventInterface $event, Query $query, ArrayObject $options, bool $primary): void {
+public function beforeFind(EventInterface $event, \Cake\ORM\Select\SelectQuery $query, ArrayObject $options, bool $primary): void {

in model/behavior for all kind of event hooks

-public function findList(Query $query, array $options): Query {
+public function findList(\Cake\ORM\Select\SelectQuery $query, array $options): \Cake\ORM\Select\SelectQuery {
-protected function _initializeSchema(TableSchemaInterface $schema): TableSchemaInterface {
+public function getSchema(): TableSchemaInterface {
-	protected $middlewareEnabled = false;
+	protected bool $middlewareEnabled = false;

etc in Plugin

-Cake\Routing\Exception\RedirectException;
+Cake\Http\Exception\RedirectException;

tests/

-protected $fixtures = [
+protected array $fixtures = [

etc

-TableRegistry::clear();
+$this->getTableLocator()->clear();

Custom ones (e.g. my plugins)

-protected $order = [
+protected array $order = [

inside Table classes

Clone this wiki locally