Skip to content

Commit 54c2a17

Browse files
committed
Added case for fetchTable called from other object
1 parent af93cc0 commit 54c2a17

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/Type/BaseTraitExpressionTypeResolverExtension.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
declare(strict_types=1);
33

44
/**
5-
* Copyright 2020, Cake Development Corporation (https://www.cakedc.com)
5+
* Copyright 2024, Cake Development Corporation (https://www.cakedc.com)
66
*
77
* Licensed under The MIT License
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright 2020, Cake Development Corporation (https://www.cakedc.com)
10+
* @copyright Copyright 2024, Cake Development Corporation (https://www.cakedc.com)
1111
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
1212
*/
1313

@@ -59,12 +59,11 @@ public function getType(Expr $expr, Scope $scope): ?Type
5959
}
6060

6161
$callerType = $scope->getType($expr->var);
62-
63-
if (!$callerType instanceof ThisType) {
62+
if (!$callerType instanceof ThisType && !$callerType instanceof ObjectType) {
6463
return null;
6564
}
6665
$reflection = $callerType->getClassReflection();
67-
if (!$this->isFromTargetTrait($reflection)) {
66+
if ($reflection === null || !$this->isFromTargetTrait($reflection)) {
6867
return null;
6968
}
7069

tests/test_app/Model/Logic/Action/BlockUsers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace App\Model\Logic\Action;
1515

1616
/**
17-
* Class DeleteUsers
17+
* Class BlockUsers
1818
*
1919
* @package App\Model\Logic\Action
2020
*/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Copyright 2024, Cake Development Corporation (https://www.cakedc.com)
6+
*
7+
* Licensed under The MIT License
8+
* Redistributions of files must retain the above copyright notice.
9+
*
10+
* @copyright Copyright 2020, Cake Development Corporation (https://www.cakedc.com)
11+
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
12+
*/
13+
14+
namespace App\Model\Logic\Action;
15+
16+
/**
17+
* Class RunBlock
18+
*
19+
* @package App\Model\Logic\Action
20+
*/
21+
class RunBlock
22+
{
23+
/**
24+
* @throws \Exception
25+
* @return void
26+
*/
27+
public function process()
28+
{
29+
(new BlockUsers())->fetchTable()->blockOld();
30+
}
31+
}

0 commit comments

Comments
 (0)