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
8 changes: 4 additions & 4 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:

services:
mysql:
image: mysql:latest
image: mysql:9
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
postgres:
image: postgres:12
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
tools: composer:v2
coverage: xdebug
extensions: redis
Expand All @@ -78,7 +78,7 @@ jobs:
# run: sed -i 's/\/home\/runner\/work\/framework\/framework\//\/github\/workspace\//g' coverage-report.clover

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:

services:
mysql:
image: mysql:latest
image: mysql:9
env:
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
postgres:
image: postgres:12
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
Expand All @@ -44,8 +44,7 @@ jobs:
strategy:
fail-fast: true
matrix:
#php: [8.0, 8.1]
php: [8.1, 8.2, 8.3]
php: [8.3, 8.4]
mapper: [mysql, pgsql]

name: Unit tests PHP ${{ matrix.php }} and ${{ matrix.mapper }}
Expand Down Expand Up @@ -91,7 +90,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2, 8.3]
php: [8.3, 8.4]

name: Code analysis with PHPStan PHP ${{ matrix.php }}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ At moment, code, isn't utilized in production environment, Hope in future.

# Require

- PHP >= 8.1
- PHP >= 8.3
- PDO extension (optional)
- Memcached extension (optional)
- Mongodb extension (optional)
Expand Down Expand Up @@ -77,7 +77,7 @@ Please see [CONTRIBUTING.md](https://github.com/linna/framework/blob/master/CONT

### High Priority
- [ ] [IN PROGRESS] Reduce the technical debt
- [ ] [IN PROGRESS] Complete the PHP 8.1 porting
- [ ] [IN PROGRESS] Complete the PHP 8.3 porting
- [X] Complete the updating and the review of the code comments
- [ ] [IN PROGRESS] Create documentation for the site, api and articles about how to do things
- [X] Unify database session handlers
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"psr/simple-cache": "^3.0"
},
"require-dev": {
"infection/infection": ">=0.26",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10",
"infection/infection": "^0.30",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12",
"linna/auth-mapper-mysql": "dev-master",
"linna/db-dumps": "dev-master",
"mongodb/mongodb": "^1.5",
"brianium/paratest": "^7.0"
"mongodb/mongodb": "^2.1",
"brianium/paratest": "^7"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 5 additions & 5 deletions composer.mysql.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"psr/simple-cache": "^3.0"
},
"require-dev": {
"infection/infection": ">=0.26",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10",
"infection/infection": "^0.30",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12",
"linna/auth-mapper-mysql": "dev-master",
"linna/db-dumps": "dev-master",
"mongodb/mongodb": "^1.5",
"brianium/paratest": "^7.0"
"mongodb/mongodb": "^2.1",
"brianium/paratest": "^7"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 5 additions & 5 deletions composer.pgsql.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"psr/simple-cache": "^3.0"
},
"require-dev": {
"infection/infection": ">=0.26",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^10",
"infection/infection": "^0.30",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^12",
"linna/auth-mapper-pgsql": "dev-master",
"linna/db-dumps": "dev-master",
"mongodb/mongodb": "^1.5",
"brianium/paratest": "^7.0"
"mongodb/mongodb": "^2.1",
"brianium/paratest": "^7"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions phpunit.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<logging/>
<php>
<var name="pdo_mysql_dsn" value="mysql:host=0.0.0.0;dbname=linna_db;charset=utf8mb4"/>
<var name="pdo_mysql_host" value="0.0.0.0"/>
<var name="pdo_mysql_user" value="root"/>
<var name="pdo_mysql_password" value="password"/>
<var name="pdo_pgsql_dsn" value="pgsql:dbname=linna_db;host=0.0.0.0"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Linna/Authentication/ProtectedControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* <p>This trait contains only private mothods.</p>
*/
trait ProtectedControllerTrait
trait ProtectedControllerTrait // @phpstan-ignore trait.unused
{
/** @var bool Contain login status. */
private bool $authentication = false;
Expand Down
1 change: 1 addition & 0 deletions src/Linna/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function register(): bool
$callback = '\Linna\Autoloader::loadClass';
$result = false;

/** @phpstan-ignore-next-line */
if (\is_callable($callback)) {
/** @phpstan-ignore-next-line */
$result = $result || \spl_autoload_register($callback);
Expand Down
1 change: 1 addition & 0 deletions src/Linna/Cache/RedisCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct(array $options)
$this->redis = new Redis();
$callback = [$this->redis, 'connect'];

/** @phpstan-ignore-next-line */
if (!isset($options['connect']['host']) || \is_callable($callback) && !\call_user_func_array($callback, $options['connect'])) {
throw new InvalidArgumentException('Unable to connect to Redis server.');
}
Expand Down
1 change: 0 additions & 1 deletion src/Linna/Mvc/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Linna\Mvc;

use Linna\Mvc\TemplateInterface;

use SplObserver;
use SplSubject;

Expand Down
2 changes: 2 additions & 0 deletions src/Linna/Session/EncryptedSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,13 @@ public function read(string $id): string|false
$ciphertext = $this->handler->read($id);

//if session doesn't contain data, return a void string
// @phpstan-ignore-next-line
if (\strlen($ciphertext) === 0) {
return "";
}

//decrypt session data
// @phpstan-ignore-next-line
$plaintext = $this->crypto->decrypt(\sodium_base642bin($ciphertext, SODIUM_BASE64_VARIANT_ORIGINAL), $this->additionalData, $this->nonce, $this->key);

//return plaintext
Expand Down
1 change: 1 addition & 0 deletions src/Linna/Storage/ExtendedPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function queryWithParam(string $query, array $params): PDOStatement|false

$callback = [$statement, "bindParam"];

/** @phpstan-ignore-next-line */
if (\is_callable($callback)) {
foreach ($params as $value) {
$this->checkValue($value);
Expand Down
7 changes: 3 additions & 4 deletions tests/Linna/Authentication/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Linna\Authentication;

use Linna\Session\Session;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -100,12 +101,11 @@ public static function tamperingProvider()
/**
* Test login.
*
* @dataProvider tamperingProvider
*
* @runInSeparateProcess
*
* @return void
*/
#[DataProvider('tamperingProvider')]
public function testLoginTampering(int $case): void
{
self::$session->start();
Expand Down Expand Up @@ -290,15 +290,14 @@ public static function loginTimeProvider(): array
/**
* Test login refresh.
*
* @dataProvider loginTimeProvider
*
* @runInSeparateProcess
*
* @param int $time
* @param bool $loginPass
*
* @return void
*/
#[DataProvider('loginTimeProvider')]
public function testLoginRefreshTime(int $time, bool $loginPass): void
{
self::$session->start();
Expand Down
16 changes: 6 additions & 10 deletions tests/Linna/Authentication/PasswordGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Linna\Authentication;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionObject;

Expand Down Expand Up @@ -64,12 +65,11 @@ public static function stringLengthProvider(): array
/**
* Test get from random.
*
* @dataProvider stringLengthProvider
*
* @param int $strLen
*
* @return void
*/
#[DataProvider('stringLengthProvider')]
public function testGetFromRandom(int $strLen): void
{
$password = self::$passwordGenerator->getFromRandom($strLen);
Expand All @@ -86,12 +86,11 @@ public function testGetFromRandom(int $strLen): void
/**
* Test get from random.
*
* @dataProvider stringLengthProvider
*
* @param int $strLen
*
* @return void
*/
#[DataProvider('stringLengthProvider')]
public function testCheckRandomTopology(int $strLen): void
{
$topology = '';
Expand Down Expand Up @@ -147,13 +146,12 @@ public static function topologyAndPasswordProvider(): array
/**
* Test get topology.
*
* @dataProvider topologyAndPasswordProvider
*
* @param string $password
* @param string $topology
*
* @return void
*/
#[DataProvider('topologyAndPasswordProvider')]
public function testGetTopology(string $password, string $topology): void
{
$this->assertEquals($topology, self::$passwordGenerator->getTopology($password));
Expand Down Expand Up @@ -192,12 +190,11 @@ public static function topologyProvider(): array
/**
* Test get topology.
*
* @dataProvider topologyProvider
*
* @param string $topology
*
* @return void
*/
#[DataProvider('topologyProvider')]
public function testGetFromTopology(string $topology): void
{
$password = self::$passwordGenerator->getFromTopology(\strtoupper($topology));
Expand Down Expand Up @@ -225,12 +222,11 @@ public static function badTopologyProvider(): array
/**
* Test get topology.
*
* @dataProvider badTopologyProvider
*
* @param string $topology
*
* @return void
*/
#[DataProvider('badTopologyProvider')]
public function testGetFromTopologyException(string $topology): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
6 changes: 3 additions & 3 deletions tests/Linna/Authentication/PasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace Linna\Authentication;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -39,7 +40,7 @@ public static function setUpBeforeClass(): void
*/
public static function tearDownAfterClass(): void
{
self::$password = null;
//self::$password = null;
}

/**
Expand Down Expand Up @@ -101,10 +102,9 @@ public static function optionsProvider(): array
/**
* Test get hash info.
*
* @dataProvider optionsProvider
*
* @return void
*/
#[DataProvider('optionsProvider')]
public function testGetHashInfo(int $opsLimit, int $memLimit, int $memExp, int $timeExp, int $threads): void
{
$password = new Password($opsLimit, $memLimit);
Expand Down
Loading