diff --git a/.circleci/config.yml b/.circleci/config.yml
index 2ac83f9..b80d560 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -103,12 +103,29 @@ jobs:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_HOST: "%"
- image: memcached:1.4
+ build-php80:
+ <<: *defaults
+ docker:
+ - image: php:8.0-alpine
+ environment:
+ ADD_PACKAGES: "libmemcached"
+ ADD_MODULES: "mysqli pdo pdo_mysql"
+ ADD_PECL: "apcu memcached"
+ ADD_PHPIZE_DEPS: "zlib-dev libmemcached-dev"
+ - image: cassandra:2.1
+ environment:
+ CASSANDRA_START_RPC: yes
+ - image: circleci/mysql:5.6
+ environment:
+ MYSQL_ALLOW_EMPTY_PASSWORD: yes
+ MYSQL_ROOT_HOST: "%"
+ - image: memcached:1.4
workflows:
version: 2
build:
jobs:
- - build-php71
- build-php72
- build-php73
- build-php74
+ - build-php80
diff --git a/composer.json b/composer.json
index 3d6d035..6da3ea9 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,7 @@
}
],
"require": {
- "php": ">=7.1",
+ "php": ">=7.2",
"ext-json": "*",
"packaged/helpers": "~1.23||~2.5",
"packaged/docblock": "~0.1||~1.0",
@@ -23,7 +23,7 @@
"ext-apcu": "*"
},
"require-dev": {
- "phpunit/phpunit": "~7"
+ "phpunit/phpunit": "~8"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml b/phpunit.xml
index cdcf171..95744a6 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -14,11 +14,11 @@
>
- tests
+ ./tests/*
-
+
src
diff --git a/src/DataTypes/Counter.php b/src/DataTypes/Counter.php
index 854d4cb..270e6d4 100644
--- a/src/DataTypes/Counter.php
+++ b/src/DataTypes/Counter.php
@@ -26,7 +26,7 @@ public function current()
public function setValue($value)
{
- $this->_value = $value;
+ $this->_value = $this->_safeValue($value);
$this->_adjust = 0;
$this->_adjusted = true;
}
@@ -36,8 +36,22 @@ public function calculated()
return $this->_value + $this->_adjust;
}
+ protected function _safeValue($by)
+ {
+ if(is_int($by) || is_float($by))
+ {
+ return $by;
+ }
+ if(is_numeric($by) && strpos($by, '.') > 0)
+ {
+ return (float)$by;
+ }
+ return (int)$by;
+ }
+
public function increment($by = 1)
{
+ $by = $this->_safeValue($by);
$this->_adjust += abs($by);
$this->_adjusted = abs($by) > 0;
return $this;
@@ -45,6 +59,7 @@ public function increment($by = 1)
public function decrement($by = 1)
{
+ $by = $this->_safeValue($by);
$this->_adjust -= abs($by);
$this->_adjusted = abs($by) > 0;
return $this;
diff --git a/src/Ql/Cql/CqlConnection.php b/src/Ql/Cql/CqlConnection.php
index fa6f6ed..d0d498d 100644
--- a/src/Ql/Cql/CqlConnection.php
+++ b/src/Ql/Cql/CqlConnection.php
@@ -96,10 +96,7 @@ public function connect()
{
$this->_prepareCache = [];
- $remainingAttempts = (int)$this->_config()->getItem(
- 'connect_attempts',
- 1
- );
+ $remainingAttempts = (int)$this->_config()->getItem('connect_attempts', 1);
while($remainingAttempts > 0)
{
@@ -109,35 +106,21 @@ public function connect()
{
if(empty($this->_availableHosts))
{
- $this->_availableHosts = ValueAs::arr(
- $this->_config()->getItem('hosts', 'localhost')
- );
+ $this->_availableHosts = ValueAs::arr($this->_config()->getItem('hosts', 'localhost'));
$this->_availableHostCount = count($this->_availableHosts);
if($this->_availableHostCount < 1)
{
- throw new ConnectionException(
- 'Could not find any configured hosts'
- );
+ throw new ConnectionException('Could not find any configured hosts');
}
}
shuffle($this->_availableHosts);
$host = reset($this->_availableHosts);
- $this->_socket = new DalSocket(
- $host,
- (int)$this->_config()->getItem('port', 9160),
- $this->_isPersistent()
- );
- $this->_socket->setConnectTimeout(
- (int)$this->_config()->getItem('connect_timeout', 1000)
- );
- $this->_socket->setRecvTimeout(
- (int)$this->_config()->getItem('receive_timeout', 1000)
- );
- $this->_socket->setSendTimeout(
- (int)$this->_config()->getItem('send_timeout', 1000)
- );
+ $this->_socket = new DalSocket($host, (int)$this->_config()->getItem('port', 9160), $this->_isPersistent());
+ $this->_socket->setConnectTimeout((int)$this->_config()->getItem('connect_timeout', 1000));
+ $this->_socket->setRecvTimeout((int)$this->_config()->getItem('receive_timeout', 1000));
+ $this->_socket->setSendTimeout((int)$this->_config()->getItem('send_timeout', 1000));
$this->_transport = new TFramedTransport($this->_socket);
$this->_protocol = new TBinaryProtocolAccelerated($this->_transport);
diff --git a/src/Ql/Cql/DalSocket.php b/src/Ql/Cql/DalSocket.php
index 5761765..d754df1 100644
--- a/src/Ql/Cql/DalSocket.php
+++ b/src/Ql/Cql/DalSocket.php
@@ -28,7 +28,10 @@ public function close()
{
$persist = $this->persist_;
$this->persist_ = false;
- parent::close();
+ if($this->handle_ !== null && !is_bool($this->handle_))
+ {
+ parent::close();
+ }
$this->persist_ = $persist;
}
diff --git a/tests/Cache/Apc/ApcConnectionTest.php b/tests/Cache/Apc/ApcConnectionTest.php
index c308192..9674635 100644
--- a/tests/Cache/Apc/ApcConnectionTest.php
+++ b/tests/Cache/Apc/ApcConnectionTest.php
@@ -8,7 +8,7 @@
class ApcConnectionTest extends TestCase
{
- protected function setUp()
+ protected function setUp(): void
{
if(!((extension_loaded('apc') || extension_loaded('apcu'))
&& ini_get('apc.enabled'))
diff --git a/tests/Exceptions/Connection/CqlExceptionTest.php b/tests/Exceptions/Connection/CqlExceptionTest.php
index 752c776..152d7db 100644
--- a/tests/Exceptions/Connection/CqlExceptionTest.php
+++ b/tests/Exceptions/Connection/CqlExceptionTest.php
@@ -31,12 +31,12 @@ public function testExceptions($exception, $code, $contains)
{
foreach($contains as $contain)
{
- $this->assertContains($contain, $formed->getMessage());
+ $this->assertStringContainsString($contain, $formed->getMessage());
}
}
else
{
- $this->assertContains($contains, $formed->getMessage());
+ $this->assertStringContainsString($contains, $formed->getMessage());
}
$this->assertSame($exception, $formed->getPrevious());
}
diff --git a/tests/Exceptions/Connection/PdoExceptionTest.php b/tests/Exceptions/Connection/PdoExceptionTest.php
index 00864aa..4adc2c9 100644
--- a/tests/Exceptions/Connection/PdoExceptionTest.php
+++ b/tests/Exceptions/Connection/PdoExceptionTest.php
@@ -25,12 +25,12 @@ public function testExceptions($exception, $code, $contains)
{
foreach($contains as $contain)
{
- $this->assertContains($contain, $formed->getMessage());
+ $this->assertStringContainsString($contain, $formed->getMessage());
}
}
else
{
- $this->assertContains($contains, $formed->getMessage());
+ $this->assertStringContainsString($contains, $formed->getMessage());
}
$this->assertSame($exception, $formed->getPrevious());
}
diff --git a/tests/FileSystem/FileSystemDataStoreTest.php b/tests/FileSystem/FileSystemDataStoreTest.php
index c458163..2f81692 100644
--- a/tests/FileSystem/FileSystemDataStoreTest.php
+++ b/tests/FileSystem/FileSystemDataStoreTest.php
@@ -19,13 +19,13 @@ protected function _getResourceLocation($filename)
return Path::system(dirname(__DIR__), 'resources', 'FileSystem', $filename);
}
- protected function setUp()
+ protected function setUp(): void
{
$resolver = new DalResolver();
$resolver->boot();
}
- protected function tearDown()
+ protected function tearDown(): void
{
Dao::unsetDalResolver();
}
diff --git a/tests/FileSystem/JsonFileDaoTest.php b/tests/FileSystem/JsonFileDaoTest.php
index 3d50b5f..d1d69f9 100644
--- a/tests/FileSystem/JsonFileDaoTest.php
+++ b/tests/FileSystem/JsonFileDaoTest.php
@@ -14,13 +14,13 @@ protected function _getResourceLocation($filename)
return Path::system(dirname(__DIR__), 'resources', 'FileSystem', $filename);
}
- protected function setUp()
+ protected function setUp(): void
{
$resolver = new DalResolver();
$resolver->boot();
}
- protected function tearDown()
+ protected function tearDown(): void
{
Dao::unsetDalResolver();
}
diff --git a/tests/Foundation/AbstractSanitizableDaoTest.php b/tests/Foundation/AbstractSanitizableDaoTest.php
index 819cde9..8a7ea0e 100644
Binary files a/tests/Foundation/AbstractSanitizableDaoTest.php and b/tests/Foundation/AbstractSanitizableDaoTest.php differ
diff --git a/tests/Ql/Cql/CqlTest.php b/tests/Ql/Cql/CqlTest.php
index 54ba3d4..9967a84 100644
--- a/tests/Ql/Cql/CqlTest.php
+++ b/tests/Ql/Cql/CqlTest.php
@@ -165,7 +165,7 @@ public function testLsd()
$this->assertEquals(123456, $dao->intVal);
$this->assertEquals(-123456, $dao->bigintVal);
$this->assertEquals(123456, $dao->doubleVal);
- $this->assertEquals(12.3456, $dao->floatVal, '', 0.00001);
+ $this->assertEqualsWithDelta(12.3456, $dao->floatVal, 0.00001);
$this->assertEquals(1200, $dao->decimalVal);
$this->assertEquals(-54.321, $dao->negDecimalVal);
$this->assertEquals(strtotime('2015-04-02'), $dao->timestampVal);