Skip to content

Commit

Permalink
Merge pull request #9 from infoseci/cake4
Browse files Browse the repository at this point in the history
Update to support CakePHP 4
  • Loading branch information
robertpustulka committed Nov 20, 2020
2 parents fbd51c0 + 9e7208c commit 3434ea8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ dist: trusty
sudo: false

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

env:
global:
Expand Down
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=5.6",
"cakephp/orm": "~3.5"
"php": ">=7.2.0",
"cakephp/orm": "^4.0"
},
"require-dev": {
"php": ">=5.6",
"phpunit/phpunit": "<6.0",
"cakephp/cakephp": "~3.5",
"php": ">=7.2.0",
"phpunit/phpunit": "^8.0",
"cakephp/cakephp": "^4.0",
"cakephp/cakephp-codesniffer": "@stable"
},
"autoload": {
Expand All @@ -24,5 +24,8 @@
"Cake\\Test\\": "vendor/cakephp/cakephp/tests",
"Robotusers\\TableInheritance\\Test\\": "tests"
}
},
"scripts": {
"test": "./vendor/bin/phpunit"
}
}
6 changes: 2 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
colors="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
Expand All @@ -18,14 +17,13 @@
</testsuite>
</testsuites>
<listeners>
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<listener
class="\Cake\TestSuite\Fixture\FixtureInjector">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<php>
</php>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Behavior/StiBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class StiBehavior extends Behavior
* @param array $config Config.
* @return void
*/
public function initialize(array $config)
public function initialize(array $config): void
{
if ($this->_config['table'] !== null) {
$this->_table->setTable($this->_config['table']);
Expand Down
7 changes: 4 additions & 3 deletions src/Model/Behavior/StiParentBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
namespace Robotusers\TableInheritance\Model\Behavior;

use ArrayAccess;
use Cake\Event\Event;
use Cake\Datasource\EntityInterface;
use Cake\Event\EventInterface;
use Cake\ORM\Behavior;
use Cake\ORM\Locator\LocatorAwareTrait;
use Cake\ORM\Query;
Expand Down Expand Up @@ -122,13 +123,13 @@ public function newStiEntity($data = null, array $options = [])
* @param \ArrayAccess $options Options.
* @return void
*/
public function beforeFind(Event $event, Query $query, ArrayAccess $options)
public function beforeFind(EventInterface $event, Query $query, ArrayAccess $options)
{
if (!$query->isHydrationEnabled()) {
return;
}
$query->formatResults(function ($results) {
return $results->map(function ($row) {
return $results->map(function (EntityInterface $row) {
if ($row instanceof CopyableEntityInterface) {
$table = $this->stiTable($row);
$entityClass = $table->getEntityClass();
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Entity/CopyableEntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ trait CopyableEntityTrait
*/
public function copyProperties()
{
return $this->_properties;
return $this->_fields;
}
}
2 changes: 1 addition & 1 deletion tests/TestCase/Model/Behavior/StiBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class StiBehaviorTest extends TestCase
'plugin.Robotusers\TableInheritance.Users'
];

public function tearDown()
public function tearDown(): void
{
parent::tearDown();

Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Model/Behavior/StiParentBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class StiParentBehaviorTest extends TestCase
*/
public $table;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -100,7 +100,7 @@ public function testStiTable()
}
}

public function tearDown()
public function tearDown(): void
{
parent::tearDown();

Expand Down

0 comments on commit 3434ea8

Please sign in to comment.