Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-24.04]
php-versions: ['8.0', '8.1', '8.2']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4', '8.5']

name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
Expand Down
20 changes: 20 additions & 0 deletions .rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\CodeQuality\Rector as CodeQuality;
use Rector\Set\ValueObject\LevelSetList;
use Rector\ValueObject\PhpVersion;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/lib',
])
->withRules([
CodeQuality\Class_\CompleteDynamicPropertiesRector::class
])
->withSets([
LevelSetList::UP_TO_PHP_85
])
->withPhpVersion(PhpVersion::PHP_80);
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
"url": "https://github.com/tine20/zendframework1.git"
}],
"require": {
"php": ">=7.4.0",
"php": ">=8.0",
"ext-ctype": "*",
"zendframework/zendframework1": "1.12.20.*"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"phing/phing": "2.6.1-p0"
"phing/phing": "2.6.1-p0",
"rector/rector": "^2.3"
},
"autoload": {
"psr-0": {
Expand All @@ -33,6 +34,8 @@
},
"scripts": {
"php8test": "cd tests/docker; docker-compose run cli8 ash -c 'cd /src/tests; ../vendor/bin/phpunit --color Syncroton/AllTests.php'; cd ../..;",
"php81test": "cd tests/docker; docker-compose run cli81 ash -c 'cd /src/tests; ../vendor/bin/phpunit --color Syncroton/AllTests.php'; cd ../..;"
"php81test": "cd tests/docker; docker-compose run cli81 ash -c 'cd /src/tests; ../vendor/bin/phpunit --color Syncroton/AllTests.php'; cd ../..;",
"rector:test": "vendor/bin/rector process --config .rector.php --dry-run",
"rector:fix": "vendor/bin/rector process --config .rector.php"
}
}
123 changes: 118 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions lib/Syncroton/Backend/ABackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ abstract class Syncroton_Backend_ABackend implements Syncroton_Backend_IBackend
*/
protected $_db;

protected $_tablePrefix;

protected $_tableName;

protected $_modelClassName;
Expand All @@ -38,10 +36,9 @@ abstract class Syncroton_Backend_ABackend implements Syncroton_Backend_IBackend
* @param Zend_Db_Adapter_Abstract $_db
* @param string $_tablePrefix
*/
public function __construct(Zend_Db_Adapter_Abstract $_db, $_tablePrefix = 'Syncroton_')
public function __construct(Zend_Db_Adapter_Abstract $_db, protected $_tablePrefix = 'Syncroton_')
{
$this->_db = $_db;
$this->_tablePrefix = $_tablePrefix;
}

/**
Expand Down Expand Up @@ -73,7 +70,7 @@ public function create($model)
*/
protected function _convertModelToArray($model)
{
$data = array();
$data = [];

foreach ($model as $key => $value) {
if ($value instanceof DateTime) {
Expand Down Expand Up @@ -145,7 +142,7 @@ public function delete($id)
{
$id = $id instanceof $this->_modelInterfaceName ? $id->id : $id;

$result = $this->_db->delete($this->_tablePrefix . $this->_tableName, array('id = ?' => $id));
$result = $this->_db->delete($this->_tablePrefix . $this->_tableName, ['id = ?' => $id]);

return (bool) $result;
}
Expand All @@ -162,9 +159,9 @@ public function update($model)

$data = $this->_convertModelToArray($model);

$this->_db->update($this->_tablePrefix . $this->_tableName, $data, array(
$this->_db->update($this->_tablePrefix . $this->_tableName, $data, [
'id = ?' => $model->id
));
]);

return $this->get($model->id);
}
Expand All @@ -178,7 +175,7 @@ public function update($model)
*/
public function userAccounts($device)
{
return array();
return [];
}

/**
Expand All @@ -190,7 +187,7 @@ protected function _fromCamelCase($string)
{
$string = lcfirst($string);

return preg_replace_callback('/([A-Z])/', function ($string) {return '_' . strtolower($string[0]);}, $string);
return preg_replace_callback('/([A-Z])/', fn($string) => '_' . strtolower($string[0]), $string);
}

/**
Expand All @@ -206,6 +203,6 @@ protected function _toCamelCase($string, $ucFirst = true)
$string = ucfirst($string);
}

return preg_replace_callback('/_([a-z])/', function ($string) {return strtoupper($string[1]);}, $string);
return preg_replace_callback('/_([a-z])/', fn($string) => strtoupper($string[1]), $string);
}
}
10 changes: 5 additions & 5 deletions lib/Syncroton/Backend/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public function delete($id)
{
$id = $id instanceof $this->_modelInterfaceName ? $id->id : $id;

$this->_db->update($this->_tablePrefix . 'content', array(
$this->_db->update($this->_tablePrefix . 'content', [
'is_deleted' => 1
), array(
], [
'id = ?' => $id
));
]);

}

Expand Down Expand Up @@ -106,10 +106,10 @@ public function resetState($deviceId, $folderId)
$deviceId = $deviceId instanceof Syncroton_Model_IDevice ? $deviceId->id : $deviceId;
$folderId = $folderId instanceof Syncroton_Model_IFolder ? $folderId->id : $folderId;

$where = array(
$where = [
$this->_db->quoteInto($this->_db->quoteIdentifier('device_id') . ' = ?', $deviceId),
$this->_db->quoteInto($this->_db->quoteIdentifier('folder_id') . ' = ?', $folderId)
);
];

$this->_db->delete($this->_tablePrefix . 'content', $where);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Syncroton/Backend/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getUserDevice($ownerId, $deviceId)
*/
public function userAccounts($device)
{
return array();
return [];
}

/**
Expand Down
Loading