Skip to content

Commit

Permalink
Merge pull request #173 from lilHermit/php8-support
Browse files Browse the repository at this point in the history
PHP 8.1 support
  • Loading branch information
markstory authored Aug 30, 2022
2 parents a1a2291 + a8704f0 commit 3eae9a9
Show file tree
Hide file tree
Showing 18 changed files with 432 additions and 179 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"source": "https://github.com/cakephp/acl"
},
"require": {
"php": "^7.2",
"php": ">=7.2",
"cakephp/cakephp": "^4.0",
"cakephp/plugin-installer": "^1.2"
},
Expand Down
11 changes: 4 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<ini name="memory_limit" value="-1"/>
<ini name="apc.enable_cli" value="1"/>

<env name="FIXTURE_SCHEMA_METADATA" value="./tests/schema.php"/>
<!-- SQLite
<env name="db_class" value="Cake\Database\Driver\Sqlite"/>
<env name="db_dsn" value="sqlite:///:memory:"/>
Expand All @@ -30,13 +31,9 @@
<directory>./tests/TestCase/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Cake\TestSuite\Fixture\FixtureInjector" file="./vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php">
<arguments>
<object class="\Cake\TestSuite\Fixture\FixtureManager" />
</arguments>
</listener>
</listeners>
<extensions>
<extension class="\Cake\TestSuite\Fixture\PHPUnitExtension" />
</extensions>

<filter>
<whitelist>
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/AclNodesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function node($ref = null)

if (empty($ref)) {
return null;
} elseif (is_int($ref) || ctype_digit($ref)) {
} elseif (is_int($ref) || (is_string($ref) && ctype_digit($ref))) {
$ref = [
'id' => $ref,
];
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Table/PermissionsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ public function getAclLink($aro, $aco)
if (empty($obj['Aro']) || empty($obj['Aco'])) {
return false;
}
$aro = $obj['Aro']->extract('id')->toArray();
$aco = $obj['Aco']->extract('id')->toArray();
$aro = $obj['Aro']->all()->extract('id')->toArray();
$aco = $obj['Aco']->all()->extract('id')->toArray();
$aro = current($aro);
$aco = current($aco);
$alias = $this->getAlias();
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/AcoActionsFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class AcoActionsFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'parent_id' => ['type' => 'integer', 'length' => 10, 'null' => true],
'model' => ['type' => 'string', 'default' => ''],
'foreign_key' => ['type' => 'integer', 'length' => 10, 'null' => true],
'alias' => ['type' => 'string', 'default' => ''],
'lft' => ['type' => 'integer', 'length' => 10, 'null' => true],
'rght' => ['type' => 'integer', 'length' => 10, 'null' => true],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/AcoTwosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class AcoTwosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'parent_id' => ['type' => 'integer', 'length' => 10, 'null' => true],
'model' => ['type' => 'string', 'null' => true],
'foreign_key' => ['type' => 'integer', 'length' => 10, 'null' => true],
'alias' => ['type' => 'string', 'default' => ''],
'lft' => ['type' => 'integer', 'length' => 10, 'null' => true],
'rght' => ['type' => 'integer', 'length' => 10, 'null' => true],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/AcosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class AcosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'parent_id' => ['type' => 'integer', 'length' => 10, 'null' => true],
'model' => ['type' => 'string', 'null' => true],
'foreign_key' => ['type' => 'integer', 'length' => 10, 'null' => true],
'alias' => ['type' => 'string', 'default' => ''],
'lft' => ['type' => 'integer', 'length' => 10, 'null' => true],
'rght' => ['type' => 'integer', 'length' => 10, 'null' => true],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/AroTwosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class AroTwosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'parent_id' => ['type' => 'integer', 'length' => 10, 'null' => true],
'model' => ['type' => 'string', 'null' => true],
'foreign_key' => ['type' => 'integer', 'length' => 10, 'null' => true],
'alias' => ['type' => 'string', 'default' => ''],
'lft' => ['type' => 'integer', 'length' => 10, 'null' => true],
'rght' => ['type' => 'integer', 'length' => 10, 'null' => true],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/ArosAcoTwosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class ArosAcoTwosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'aro_id' => ['type' => 'integer', 'length' => 10, 'null' => false],
'aco_id' => ['type' => 'integer', 'length' => 10, 'null' => false],
'_create' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_read' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_update' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_delete' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/ArosAcosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class ArosAcosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'aro_id' => ['type' => 'integer', 'length' => 10, 'null' => false],
'aco_id' => ['type' => 'integer', 'length' => 10, 'null' => false],
'_create' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_read' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_update' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_delete' => ['type' => 'string', 'length' => 2, 'default' => 0],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
16 changes: 0 additions & 16 deletions tests/Fixture/ArosFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@
class ArosFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer'],
'parent_id' => ['type' => 'integer', 'length' => 10, 'null' => true],
'model' => ['type' => 'string', 'null' => true],
'foreign_key' => ['type' => 'integer', 'length' => 10, 'null' => true],
'alias' => ['type' => 'string', 'default' => ''],
'lft' => ['type' => 'integer', 'length' => 10, 'null' => true],
'rght' => ['type' => 'integer', 'length' => 10, 'null' => true],
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
];

/**
* records property
*
Expand Down
18 changes: 0 additions & 18 deletions tests/Fixture/PeopleFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,6 @@
class PeopleFixture extends TestFixture
{

/**
* fields property
*
* @var array
*/
public $fields = [
'id' => ['type' => 'integer', 'null' => false],
'name' => ['type' => 'string', 'null' => false, 'length' => 32],
'mother_id' => ['type' => 'integer', 'null' => false],
'father_id' => ['type' => 'integer', 'null' => false],
'_constraints' => [
'PRIMARY' => ['type' => 'primary', 'columns' => ['id']],
],
'_indexes' => [
'mother_id' => ['type' => 'index', 'columns' => ['mother_id', 'father_id']],
],
];

/**
* records property
*
Expand Down
19 changes: 9 additions & 10 deletions tests/TestCase/AclExtrasTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ public function testAddingControllers()
*/
public function testUpdateWithPlugins()
{
$this->deprecated(function () {
Plugin::getCollection()->clear();
Plugin::getCollection()->add(new \TestPlugin\Plugin());
Plugin::getCollection()->add(new \Nested\TestPluginTwo\Plugin());
//Plugin::routes();
});

$this->clearPlugins();
$this->loadPlugins([
new \TestPlugin\Plugin(),
new \Nested\TestPluginTwo\Plugin()
]);
$this->_clean();

$this->Task->expects($this->atLeast(3))
Expand Down Expand Up @@ -433,10 +433,9 @@ public function testUpdateWithPlugins()
*/
public function testSyncWithNestedPlugin()
{
$this->deprecated(function () {
Plugin::getCollection()->clear();
Plugin::getCollection()->add(new \Nested\TestPluginTwo\Plugin());
});
$this->clearPlugins();
$this->loadPlugins([new \Nested\TestPluginTwo\Plugin()]);

$this->_clean();

$this->Task->expects($this->atLeast(2))
Expand Down
Loading

0 comments on commit 3eae9a9

Please sign in to comment.