Skip to content

Commit 3434ea8

Browse files
Merge pull request #9 from infoseci/cake4
Update to support CakePHP 4
2 parents fbd51c0 + 9e7208c commit 3434ea8

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ dist: trusty
55
sudo: false
66

77
php:
8-
- 5.6
9-
- 7.0
10-
- 7.1
8+
- 7.2
9+
- 7.3
10+
- 7.4
1111

1212
env:
1313
global:

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"type": "cakephp-plugin",
66
"license": "MIT",
77
"require": {
8-
"php": ">=5.6",
9-
"cakephp/orm": "~3.5"
8+
"php": ">=7.2.0",
9+
"cakephp/orm": "^4.0"
1010
},
1111
"require-dev": {
12-
"php": ">=5.6",
13-
"phpunit/phpunit": "<6.0",
14-
"cakephp/cakephp": "~3.5",
12+
"php": ">=7.2.0",
13+
"phpunit/phpunit": "^8.0",
14+
"cakephp/cakephp": "^4.0",
1515
"cakephp/cakephp-codesniffer": "@stable"
1616
},
1717
"autoload": {
@@ -24,5 +24,8 @@
2424
"Cake\\Test\\": "vendor/cakephp/cakephp/tests",
2525
"Robotusers\\TableInheritance\\Test\\": "tests"
2626
}
27+
},
28+
"scripts": {
29+
"test": "./vendor/bin/phpunit"
2730
}
2831
}

phpunit.xml.dist

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
colors="true"
55
processIsolation="false"
66
stopOnFailure="false"
7-
syntaxCheck="false"
87
bootstrap="./tests/bootstrap.php"
98
>
109
<php>
@@ -18,14 +17,13 @@
1817
</testsuite>
1918
</testsuites>
2019
<listeners>
21-
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
20+
<listener
21+
class="\Cake\TestSuite\Fixture\FixtureInjector">
2222
<arguments>
2323
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
2424
</arguments>
2525
</listener>
2626
</listeners>
27-
<php>
28-
</php>
2927
<filter>
3028
<whitelist>
3129
<directory suffix=".php">./src/</directory>

src/Model/Behavior/StiBehavior.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class StiBehavior extends Behavior
5151
* @param array $config Config.
5252
* @return void
5353
*/
54-
public function initialize(array $config)
54+
public function initialize(array $config): void
5555
{
5656
if ($this->_config['table'] !== null) {
5757
$this->_table->setTable($this->_config['table']);

src/Model/Behavior/StiParentBehavior.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace Robotusers\TableInheritance\Model\Behavior;
44

55
use ArrayAccess;
6-
use Cake\Event\Event;
6+
use Cake\Datasource\EntityInterface;
7+
use Cake\Event\EventInterface;
78
use Cake\ORM\Behavior;
89
use Cake\ORM\Locator\LocatorAwareTrait;
910
use Cake\ORM\Query;
@@ -122,13 +123,13 @@ public function newStiEntity($data = null, array $options = [])
122123
* @param \ArrayAccess $options Options.
123124
* @return void
124125
*/
125-
public function beforeFind(Event $event, Query $query, ArrayAccess $options)
126+
public function beforeFind(EventInterface $event, Query $query, ArrayAccess $options)
126127
{
127128
if (!$query->isHydrationEnabled()) {
128129
return;
129130
}
130131
$query->formatResults(function ($results) {
131-
return $results->map(function ($row) {
132+
return $results->map(function (EntityInterface $row) {
132133
if ($row instanceof CopyableEntityInterface) {
133134
$table = $this->stiTable($row);
134135
$entityClass = $table->getEntityClass();

src/Model/Entity/CopyableEntityTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ trait CopyableEntityTrait
1616
*/
1717
public function copyProperties()
1818
{
19-
return $this->_properties;
19+
return $this->_fields;
2020
}
2121
}

tests/TestCase/Model/Behavior/StiBehaviorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class StiBehaviorTest extends TestCase
1616
'plugin.Robotusers\TableInheritance.Users'
1717
];
1818

19-
public function tearDown()
19+
public function tearDown(): void
2020
{
2121
parent::tearDown();
2222

tests/TestCase/Model/Behavior/StiParentBehaviorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class StiParentBehaviorTest extends TestCase
2626
*/
2727
public $table;
2828

29-
public function setUp()
29+
public function setUp(): void
3030
{
3131
parent::setUp();
3232

@@ -100,7 +100,7 @@ public function testStiTable()
100100
}
101101
}
102102

103-
public function tearDown()
103+
public function tearDown(): void
104104
{
105105
parent::tearDown();
106106

0 commit comments

Comments
 (0)