Skip to content

Commit 905b110

Browse files
authored
Merge pull request #3 from challgren/cake-4.x
Cake 4.x
2 parents 3ee4c91 + 9e05fdf commit 905b110

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ env:
66
- RUN_TESTS=1
77

88
php:
9-
- 5.6
10-
- 7.0
11-
- 7.1
9+
- 7.2
10+
- 7.3
1211

1312
sudo: false
1413

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All notable changes to `cakephp-encrypted-type` will be documented in this file.
44

5+
## 2.0.0 - TBA
6+
- Supports CakePHP 4.x
7+
58
## 1.0.0 - 2017-09-09
69

710
- First stable release.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Quality Score][ico-code-quality]][link-code-quality]
88
[![Total Downloads][ico-downloads]][link-downloads]
99

10-
This plugin provides a CakePHP 3 encrypted database type for application-level
10+
This plugin provides a CakePHP 4 encrypted database type for application-level
1111
encryption. Before using this plugin you may want to weigh your options
1212
between [full-disk, database-level, and application-level encryption](https://www.percona.com/blog/2016/04/08/mysql-data-at-rest-encryption/).
1313
This plugin was born out of Amazon Aurora not supporting encryption with cross

composer.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"cakephp/cakephp": "^3.4.0"
19+
"php": ">=7.2",
20+
"cakephp/cakephp": "4.x-dev as 4.0.0"
2021
},
2122
"require-dev": {
22-
"phpunit/phpunit": "^5.0",
23+
"phpunit/phpunit": "^8.0",
2324
"scrutinizer/ocular": "~1.1"
2425
},
2526
"autoload": {
@@ -40,8 +41,5 @@
4041
"branch-alias": {
4142
"dev-master": "1.0-dev"
4243
}
43-
},
44-
"conflict": {
45-
"phpunit/phpunit": "<5.7"
4644
}
4745
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<logging>
3232
<log type="tap" target="build/report.tap"/>
3333
<log type="junit" target="build/report.junit.xml"/>
34-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
34+
<log type="coverage-html" target="build/coverage"/>
3535
<log type="coverage-text" target="build/coverage.txt"/>
3636
<log type="coverage-clover" target="build/logs/clover.xml"/>
3737
</logging>

src/Database/Type/EncryptedType.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
declare(strict_types=1);
3+
24
namespace BryanCrowe\EncryptedType\Database\Type;
35

46
use Cake\Core\Configure;
5-
use Cake\Database\Driver;
6-
use Cake\Database\Type;
7-
use Cake\Database\TypeInterface;
7+
use Cake\Database\DriverInterface;
8+
use Cake\Database\Type\BaseType;
89
use Cake\Database\Type\OptionalConvertInterface;
910
use Cake\Utility\Security;
1011
use InvalidArgumentException;
@@ -13,7 +14,7 @@
1314
/**
1415
* Encrypted BLOB converter. Used to encrypt and decrypt stored data.
1516
*/
16-
class EncryptedType extends Type implements OptionalConvertInterface, TypeInterface
17+
class EncryptedType extends BaseType implements OptionalConvertInterface
1718
{
1819

1920
/**
@@ -38,10 +39,10 @@ public function __construct($name = null)
3839
* Convert encrypted values to PHP strings or null.
3940
*
4041
* @param mixed $value The value to convert.
41-
* @param \Cake\Database\Driver $driver The driver instance to convert with.
42-
* @return mixed
42+
* @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
43+
* @return string|null
4344
*/
44-
public function toPHP($value, Driver $driver)
45+
public function toPHP($value, DriverInterface $driver)
4546
{
4647
if ($value === null) {
4748
return null;
@@ -73,10 +74,10 @@ public function marshal($value)
7374
* Convert PHP values into the database format.
7475
*
7576
* @param mixed $value The value to convert.
76-
* @param \Cake\Database\Driver $driver The driver instance to convert with.
77-
* @return string
77+
* @param \Cake\Database\DriverInterface $driver The driver instance to convert with.
78+
* @return string|null
7879
*/
79-
public function toDatabase($value, Driver $driver)
80+
public function toDatabase($value, DriverInterface $driver): ?string
8081
{
8182
if ($value === null) {
8283
return null;
@@ -101,10 +102,10 @@ public function toDatabase($value, Driver $driver)
101102
* Get the correct PDO binding type for string data.
102103
*
103104
* @param mixed $value The value being bound.
104-
* @param \Cake\Database\Driver $driver The driver.
105+
* @param \Cake\Database\DriverInterface $driver The driver.
105106
* @return int
106107
*/
107-
public function toStatement($value, Driver $driver)
108+
public function toStatement($value, DriverInterface $driver)
108109
{
109110
if ($value === null) {
110111
return PDO::PARAM_NULL;
@@ -118,7 +119,7 @@ public function toStatement($value, Driver $driver)
118119
*
119120
* @return boolean True as database results are returned as encrypted strings.
120121
*/
121-
public function requiresToPhpCast()
122+
public function requiresToPhpCast(): bool
122123
{
123124
return true;
124125
}

tests/TestCase/Database/Type/EncryptedTypeTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class EncryptedTypeTest extends TestCase
1515
*
1616
* @return void
1717
*/
18-
public function setUp()
18+
public function setUp(): void
1919
{
2020
parent::setUp();
2121
$this->type = Type::build('encrypted');
@@ -56,11 +56,11 @@ public function testToDatabase()
5656
/**
5757
* Tests that passing an invalid value will throw an exception
5858
*
59-
* @expectedException \InvalidArgumentException
6059
* @return void
6160
*/
6261
public function testToDatabaseInvalidArray()
6362
{
63+
$this->expectException('InvalidArgumentException');
6464
$this->type->toDatabase([1, 2, 3], $this->driver);
6565
}
6666

@@ -85,6 +85,7 @@ public function testMarshal()
8585
public function testToStatement()
8686
{
8787
$this->assertEquals(PDO::PARAM_STR, $this->type->toStatement('', $this->driver));
88+
$this->assertEquals(PDO::PARAM_NULL, $this->type->toStatement(null, $this->driver));
8889
}
8990

9091
/**

0 commit comments

Comments
 (0)