Skip to content

Commit ce8abc6

Browse files
authored
Merge pull request #891 from cakephp/cake5-updates
Update as per updates to ORM
2 parents 2f80749 + 3ab01b6 commit ce8abc6

7 files changed

Lines changed: 26 additions & 27 deletions

File tree

src/DebugSql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public static function sqld(
174174
*
175175
* @return bool
176176
*/
177-
protected static function isCli()
177+
protected static function isCli(): bool
178178
{
179179
return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
180180
}

src/Model/Behavior/TimedBehavior.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
namespace DebugKit\Model\Behavior;
1717

18-
use Cake\Event\Event;
18+
use Cake\Event\EventInterface;
1919
use Cake\ORM\Behavior;
20-
use Cake\ORM\Query;
20+
use Cake\ORM\Query\SelectQuery;
2121
use DebugKit\DebugTimer;
2222

2323
/**
@@ -28,11 +28,11 @@ class TimedBehavior extends Behavior
2828
/**
2929
* beforeFind, starts a timer for a find operation.
3030
*
31-
* @param \Cake\Event\Event $event The beforeFind event
32-
* @param \Cake\ORM\Query $query Query
33-
* @return \Cake\ORM\Query
31+
* @param \Cake\Event\EventInterface $event The beforeFind event
32+
* @param \Cake\ORM\Query\SelectQuery $query SelectQuery
33+
* @return \Cake\ORM\Query\SelectQuery
3434
*/
35-
public function beforeFind(Event $event, Query $query): Query
35+
public function beforeFind(EventInterface $event, SelectQuery $query): SelectQuery
3636
{
3737
$alias = $event->getSubject()->getAlias();
3838
DebugTimer::start($alias . '_find', $alias . '->find()');
@@ -47,10 +47,10 @@ public function beforeFind(Event $event, Query $query): Query
4747
/**
4848
* beforeSave, starts a time before a save is initiated.
4949
*
50-
* @param \Cake\Event\Event $event The beforeSave event
50+
* @param \Cake\Event\EventInterface $event The beforeSave event
5151
* @return void
5252
*/
53-
public function beforeSave(Event $event): void
53+
public function beforeSave(EventInterface $event): void
5454
{
5555
$alias = $event->getSubject()->getAlias();
5656
DebugTimer::start($alias . '_save', $alias . '->save()');
@@ -59,10 +59,10 @@ public function beforeSave(Event $event): void
5959
/**
6060
* afterSave, stop the timer started from a save.
6161
*
62-
* @param \Cake\Event\Event $event The afterSave event
62+
* @param \Cake\Event\EventInterface $event The afterSave event
6363
* @return void
6464
*/
65-
public function afterSave(Event $event): void
65+
public function afterSave(EventInterface $event): void
6666
{
6767
$alias = $event->getSubject()->getAlias();
6868
DebugTimer::stop($alias . '_save');

src/Model/Table/PanelsTable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
namespace DebugKit\Model\Table;
1616

17-
use Cake\ORM\Query;
17+
use Cake\ORM\Query\SelectQuery;
1818
use Cake\ORM\Table;
1919
use RuntimeException;
2020

@@ -50,12 +50,12 @@ public function initialize(array $config): void
5050
/**
5151
* Find panels by requestid
5252
*
53-
* @param \Cake\ORM\Query $query The query
53+
* @param \Cake\ORM\Query\SelectQuery $query The query
5454
* @param array $options The options to use.
55-
* @return \Cake\ORM\Query The query.
55+
* @return \Cake\ORM\Query\SelectQuery The query.
5656
* @throws \RuntimeException
5757
*/
58-
public function findByRequest(Query $query, array $options): Query
58+
public function findByRequest(SelectQuery $query, array $options): SelectQuery
5959
{
6060
if (empty($options['requestId'])) {
6161
throw new RuntimeException(__d('debug_kit', 'Missing request id in {0}.', 'findByRequest()'));

src/Model/Table/RequestsTable.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Cake\Core\Configure;
1818
use Cake\Database\Driver\Sqlite;
1919
use Cake\Log\Log;
20-
use Cake\ORM\Query;
20+
use Cake\ORM\Query\SelectQuery;
2121
use Cake\ORM\Table;
2222
use PDOException;
2323

@@ -69,11 +69,11 @@ public static function defaultConnectionName(): string
6969
/**
7070
* Finder method to get recent requests as a simple array
7171
*
72-
* @param \Cake\ORM\Query $query The query
72+
* @param \Cake\ORM\Query\SelectQuery $query The query
7373
* @param array $options The options
74-
* @return \Cake\ORM\Query The query.
74+
* @return \Cake\ORM\Query\SelectQuery The query.
7575
*/
76-
public function findRecent(Query $query, array $options): Query
76+
public function findRecent(SelectQuery $query, array $options): SelectQuery
7777
{
7878
return $query->order(['Requests.requested_at' => 'DESC'])
7979
->limit(10);
@@ -118,14 +118,12 @@ public function gc(): void
118118
return;
119119
}
120120

121-
$query = $this->Panels->query()
122-
->delete()
121+
$query = $this->Panels->deleteQuery()
123122
->where(['request_id NOT IN' => $noPurge]);
124123
$statement = $query->execute();
125124
$statement->closeCursor();
126125

127-
$query = $this->query()
128-
->delete()
126+
$query = $this->deleteQuery()
129127
->where(['id NOT IN' => $noPurge]);
130128

131129
$statement = $query->execute();

src/Panel/PanelRegistry.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
/**
2626
* Registry object for panels.
27+
*
28+
* @extends \Cake\Core\ObjectRegistry<\DebugKit\DebugPanel>
2729
*/
2830
class PanelRegistry extends ObjectRegistry implements EventDispatcherInterface
2931
{
@@ -73,11 +75,10 @@ protected function _throwMissingClassError(string $class, ?string $plugin): void
7375
*
7476
* Part of the template method for Cake\Utility\ObjectRegistry::load()
7577
*
76-
* @param string $class The classname to create.
78+
* @param \DebugKit\DebugPanel|class-string<\DebugKit\DebugPanel> $class The classname to create.
7779
* @param string $alias The alias of the panel.
7880
* @param array $config An array of config to use for the panel.
7981
* @return \DebugKit\DebugPanel The constructed panel class.
80-
* @psalm-param class-string<\DebugKit\DebugPanel> $class
8182
*/
8283
protected function _create(object|string $class, string $alias, array $config): DebugPanel
8384
{

tests/TestCase/Panel/VariablesPanelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testShutdown()
6666
$result = $requests->find()->all();
6767
$unbufferedQuery = $requests->find('all');
6868
$unbufferedQuery->toArray(); //toArray call would normally happen somewhere in View, usually implicitly
69-
$update = $requests->query()->update();
69+
$update = $requests->updateQuery();
7070
$debugInfoException = $requests->query()->contain('NonExistentAssociation');
7171

7272
$unserializable = new stdClass();

tests/test_app/Stub/DebugSqlStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class DebugSqlStub extends DebugSql
99
{
1010
public static $isCli = true;
1111

12-
protected static function isCli()
12+
protected static function isCli(): bool
1313
{
1414
return static::$isCli;
1515
}

0 commit comments

Comments
 (0)