Compare commits

...

12 Commits

Author SHA1 Message Date
Dominique FOURNIER
35534549fe Smtp : il there is a connection error, reset the connection socket to not send multiple packets to closed socket (and generate associated errors) 2025-10-03 08:15:03 +02:00
Dominique FOURNIER
8b1faf795c PHP8.4 Deprecation stream_context_set_option -> stream_context_set_options 2025-09-12 11:52:19 +02:00
Dominique FOURNIER
b2a4cbff01 TcpclientTest : change from Google to Fournier38.fr (no default redirect on Fournier38.fr) 2025-09-12 11:51:25 +02:00
Dominique FOURNIER
8656362f0d Logger : Deprectation PHP8.2 : openlog want a valid flag and not null 2023-06-30 09:45:59 +02:00
Dominique FOURNIER
fa7de7c6c4 Language : allow to load the DomFramework locale correctely 2023-06-26 21:39:52 +02:00
Dominique FOURNIER
d86b69ce61 Form : do not use an error array if there is no error and the array is false 2023-06-23 07:35:16 +02:00
Dominique FOURNIER
46979352b8 Form/Formfield : Add the return types for the methods 2023-06-20 08:39:29 +02:00
Dominique FOURNIER
9f028ac798 FormField : property formTemplate must be public and not private (used by Form) 2023-05-15 08:38:04 +02:00
Dominique FOURNIER
7cbbec7f81 phpstan 2023-04-14 21:37:54 +02:00
Dominique FOURNIER
a2e103c32f Dblayeroo and Dblayer : {ENGINE} -> ENGINE to be PHP lintable in all the cases 2023-04-14 21:15:49 +02:00
Dominique FOURNIER
2f4461f8d9 dblayoo : checkRealTypes as changed to CamelCase : update tests 2023-04-14 21:11:07 +02:00
Dominique FOURNIER
5b56197aaa phpstan 2023-04-14 20:52:27 +02:00
24 changed files with 258 additions and 210 deletions

View File

@@ -16,11 +16,17 @@ use Domframework\Dbjson;
*/
class DbjsonTest extends \PHPUnit_Framework_TestCase
{
private $DBFILE;
public function __construct()
{
$this->DBFILE = "/tmp/dbjson-" . time();
}
public function testInsertOne1()
{
// Document #0
define("dbfile", "/tmp/dbjson-" . time());
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->insertOne(
"collection",
["key1" => "val1", "key2" => "val2"]
@@ -31,7 +37,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testInsertOne2()
{
// Document #1
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->insertOne(
"collection",
["key1" => "val1", "key2" => "val2"]
@@ -43,7 +49,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
{
// Error : Invalid array provided (not array of array)
$this->setExpectedException("Exception");
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->insertMany(
"collection",
["key1" => "val1", "key2" => "val2"]
@@ -53,7 +59,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testInsertMany2()
{
// Document #2 and #3
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->insertMany(
"collection",
[["key1" => "val3", "key2" => "val2"],
@@ -65,21 +71,21 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testFilter1()
{
// Return all the keys (filter = array ())
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", []);
$this->assertSame(array_keys($res), [0,1,2,3]);
}
public function testFilter2()
{
// Return the keys where filter = array ("key2"=>"val2"))
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", ["key2" => "val2"]);
$this->assertSame(array_keys($res), [0,1,2]);
}
public function testFilter3()
{
// Return the keys where filter = array ("key1"=>"val3","key2"=>"val2"))
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", ["key1" => "val3",
"key2" => "val2"]);
$this->assertSame(count($res), 1);
@@ -88,7 +94,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "=="),
// "key2"=>array ("val2", "=="))
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", ["key1" => ["val3", "=="],
"key2" => ["val2", "=="]]);
$this->assertSame(count($res), 1);
@@ -97,7 +103,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
// "key2"=>array ("val2", "=="))
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
"key2" => ["val2", "=="]]);
$this->assertSame(array_keys($res), [0,1,2]);
@@ -106,7 +112,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
{
// Return the keys where filter = array ("key1"=>array ("val3", "<="),
// "key2"=>array ("val2", ">"))
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->filter("collection", ["key1" => ["val3", "<="],
"key2" => ["val2", ">"]]);
$this->assertSame(count($res), 1);
@@ -114,7 +120,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testFind1()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find("collection", ["key1" => ["val3", "<="],
"key2" => ["val2", ">"]]);
$res = array_values($res);
@@ -125,7 +131,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind2()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -142,7 +148,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
{
// Exception : fields not an array
$this->setExpectedException("Exception");
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -152,7 +158,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind4()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -166,7 +172,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind5()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -181,7 +187,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind6()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -202,7 +208,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind7()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -220,7 +226,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind8()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -236,7 +242,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testDeleteOne1()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->deleteOne(
"collection",
["key1" => ["val3", "<="],
@@ -247,7 +253,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind9()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -264,7 +270,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testDeleteMany1()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->deleteMany(
"collection",
["key1" => ["val3", "<="],
@@ -275,7 +281,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind10()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->find(
"collection",
["key1" => ["val3", "<="],
@@ -290,7 +296,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testFind11()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -299,13 +305,13 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testReplace1()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->replace("collection", [], ["key2" => "val5"]);
$this->assertSame($res, 1);
}
public function testFind12()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -314,14 +320,14 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testUpdate1()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->update("collection", [], ["key2" => "val6",
"key5" => "val5"]);
$this->assertSame($res, 1);
}
public function testFind13()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -331,7 +337,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testInsertOne3()
{
// Document #4
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->insertOne(
"collection",
["key1" => "val1", "key2" => "val2"]
@@ -340,7 +346,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind14()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -353,14 +359,14 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testUpdate2()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->update("collection", [], ["key2" => "val7",
"key5" => "val8"]);
$this->assertSame($res, 2);
}
public function testFind15()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -374,7 +380,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
public function testUpdate3()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = $dbjson->update(
"collection",
[],
@@ -386,7 +392,7 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
}
public function testFind16()
{
$dbjson = new Dbjson("dbjson://" . dbfile);
$dbjson = new Dbjson("dbjson://" . $this->DBFILE);
$res = array_values($dbjson->find("collection"));
// ["_id"] is random : skip the test
unset($res[0]["_id"]);
@@ -399,8 +405,8 @@ class DbjsonTest extends \PHPUnit_Framework_TestCase
// Concurrency tests
public function testConcurrency1()
{
$dbjson1 = new Dbjson("dbjson://" . dbfile);
$dbjson2 = new Dbjson("dbjson://" . dbfile);
$dbjson1 = new Dbjson("dbjson://" . $this->DBFILE);
$dbjson2 = new Dbjson("dbjson://" . $this->DBFILE);
$dbjson1->insertOne(
"collection",
["key1" => "val1", "key2" => "val2"]

View File

@@ -11,13 +11,13 @@ namespace Domframework\Tests;
use Domframework\Dblayer;
class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
class DblayerTestENGINE extends \PHPUnit_Framework_TestCase
{
// Test with column name 'group', 'object', 'where', 'with space'
// Test with table name 'group', 'object', 'where', 'with space'
// For the 3 DB engines
public $engine = "{ENGINE}";
public $engine = "ENGINE";
public $confs = [
"sqlite" => [
"dsn" => "sqlite:/tmp/databaseDBLayer.db",
@@ -47,7 +47,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
*/
public function testDropTable()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -75,7 +75,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testCreateTable1()
{
// Create a table named grouped
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -99,7 +99,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
*/
public function testInsert1()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -123,7 +123,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testRead1()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -148,7 +148,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testUpdate1()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -170,7 +170,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testRead2()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -195,7 +195,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testUpdate2()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -218,7 +218,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testRead3()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -243,7 +243,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testUpdate3()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -277,7 +277,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testCreateTable2()
{
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -306,7 +306,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testInsert2()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -335,7 +335,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
// Test the unique feature
public function testInsert3()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -362,7 +362,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testInsert4()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -395,7 +395,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
{
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -432,7 +432,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testCreateTable3()
{
// Create a table named group
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -454,7 +454,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase
*/
public function testReadOR1()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayer(
$dbconfig["dsn"],
$dbconfig["username"],

View File

@@ -11,13 +11,13 @@ namespace Domframework\Tests;
use Domframework\Dblayeroo;
class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
class DblayerooTestENGINE extends \PHPUnit_Framework_TestCase
{
// Test with column name 'group', 'object', 'where', 'with space'
// Test with table name 'group', 'object', 'where', 'with space'
// For the 3 DB engines
public $engine = "{ENGINE}";
public $engine = "ENGINE";
public $confs = [
"sqlite" => [
"dsn" => "sqlite:/tmp/databaseDBLayeroo.db",
@@ -44,7 +44,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
private function tbl1()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$tbl1 = new Dblayeroo(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -64,7 +64,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
private function tbl2()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$tbl2 = new Dblayeroo(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -86,7 +86,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
private function tbl3()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$tbl3 = new Dblayeroo(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -98,7 +98,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
private function tbl4()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$tbl4 = new Dblayeroo(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -119,7 +119,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
public function testDropTable()
{
$dbconfig = $this->confs["{ENGINE}"];
$dbconfig = $this->confs["ENGINE"];
$db = new Dblayeroo(
$dbconfig["dsn"],
$dbconfig["username"],
@@ -1250,7 +1250,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_integerPositive",
"checkRealTypeIntegerPositive",
"1",
""
);
@@ -1261,7 +1261,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_integerPositive",
"checkRealTypeIntegerPositive",
"-1",
""
);
@@ -1273,7 +1273,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_integerPositive",
"checkRealTypeIntegerPositive",
"0777",
""
);
@@ -1285,7 +1285,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_integerPositive",
"checkRealTypeIntegerPositive",
"07a7",
""
);
@@ -1298,7 +1298,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_allowedchars",
"checkRealTypeAllowedchars",
"1111",
"allowedchars(123)"
);
@@ -1309,7 +1309,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_allowedchars",
"checkRealTypeAllowedchars",
"-1",
"allowedchars(123)"
);
@@ -1321,7 +1321,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_array",
"checkRealTypeArray",
"235",
"array('123','235','256')"
);
@@ -1332,7 +1332,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_array",
"checkRealTypeArray",
"777",
"array('123','235','256')"
);
@@ -1344,7 +1344,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_regex",
"checkRealTypeRegex",
"235",
"regex(/^\\d+$/)"
);
@@ -1355,7 +1355,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_regex",
"checkRealTypeRegex",
"235",
"regex(/^\\d{3}$/)"
);
@@ -1366,7 +1366,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_regex",
"checkRealTypeRegex",
"235",
"regex(/^\\d{4}$/)"
);
@@ -1377,7 +1377,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_regex",
"checkRealTypeRegex",
"abcdef",
"regex(/^[a-z]+$/)"
);
@@ -1388,7 +1388,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_regex",
"checkRealTypeRegex",
"Abcdef",
"regex(/^[a-z]+$/)"
);
@@ -1400,7 +1400,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_mail",
"checkRealTypeMail",
"toto@example.com",
""
);
@@ -1411,7 +1411,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_mail",
"checkRealTypeMail",
"toto@",
""
);
@@ -1423,7 +1423,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_uuid",
"checkRealTypeUuid",
"4e799e3f-f376-46e5-a5db-85200949987e",
""
);
@@ -1434,7 +1434,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_uuid",
"checkRealTypeUuid",
"4E799E3F-F376-46E5-A5DB-85200949987E",
""
);
@@ -1445,7 +1445,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_uuid",
"checkRealTypeUuid",
"4E799E3F-F376-46E5+A5DB+85200949987E",
""
);
@@ -1456,7 +1456,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_uuid",
"checkRealTypeUuid",
"4E799E3F5F376546E55A5DB585200949987E",
""
);
@@ -1468,7 +1468,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldate",
"checkRealTypeSqldate",
"2018-10-24",
""
);
@@ -1479,7 +1479,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldate",
"checkRealTypeSqldate",
"2018/10/24",
""
);
@@ -1490,7 +1490,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldate",
"checkRealTypeSqldate",
"2018-10-32",
""
);
@@ -1502,7 +1502,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqltime",
"checkRealTypeSqltime",
"12:34:56",
""
);
@@ -1513,7 +1513,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqltime",
"checkRealTypeSqltime",
"12;22;22",
""
);
@@ -1524,7 +1524,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqltime",
"checkRealTypeSqltime",
"32:34:56",
""
);
@@ -1536,7 +1536,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldatetime",
"checkRealTypeSqldatetime",
"2018-10-24 22:23:24",
""
);
@@ -1547,7 +1547,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldatetime",
"checkRealTypeSqldatetime",
"2018/10/24",
""
);
@@ -1558,7 +1558,7 @@ class DblayerooTest{ENGINE} extends \PHPUnit_Framework_TestCase
$tbl1 = $this->tbl1();
$res = $this->invokeMethod(
$tbl1,
"checkRealType_sqldatetime",
"checkRealTypeSqldatetime",
"2018-10-24 25:12:25",
""
);

View File

@@ -16,13 +16,13 @@ use Domframework\Tcpclient;
*/
class TcpclientTest extends \PHPUnit_Framework_TestCase
{
public function testGoogleIPv4()
public function testFournier38IPv4()
{
$tcpclient = new Tcpclient("www.google.fr", 80);
$tcpclient = new Tcpclient("ipv4.fournier38.fr", 80);
$tcpclient->preferIPv4(true);
$tcpclient->connect();
$tcpclient->send("GET / HTTP/1.1\r\n" .
"Host: www.google.fr\r\n" .
"Host: ip.fournier38.fr\r\n" .
"User-Agent: DomFramework\r\n" .
"Accept: *" . "/*\r\n" .
"\r\n");
@@ -34,12 +34,12 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
}
public function testGoogleIPv4orIpv6()
public function testFournier38IPv4orIpv6()
{
$tcpclient = new Tcpclient("www.google.fr", 80);
$tcpclient = new Tcpclient("ip.fournier38.fr", 80);
$tcpclient->connect();
$tcpclient->send("GET / HTTP/1.1\r\n" .
"Host: www.google.fr\r\n" .
"Host: ip.fournier38.fr\r\n" .
"User-Agent: DomFramework\r\n" .
"Accept: *" . "/*\r\n" .
"\r\n");
@@ -51,13 +51,13 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
}
public function testGoogleSSL()
public function testFournier38SSL()
{
$tcpclient = new Tcpclient("www.google.fr", 443);
$tcpclient = new Tcpclient("ip.fournier38.fr", 443);
$tcpclient->connect();
$tcpclient->cryptoEnable(true);
$tcpclient->send("GET / HTTP/1.1\r\n" .
"Host: www.google.fr\r\n" .
"Host: ip.fournier38.fr\r\n" .
"User-Agent: DomFramework\r\n" .
"Accept: *" . "/*\r\n" .
"\r\n");
@@ -69,13 +69,13 @@ class TcpclientTest extends \PHPUnit_Framework_TestCase
$this->assertSame(substr($res, 0, 15), "HTTP/1.1 200 OK");
}
public function testGoogleSSLIPv6()
public function testFournier38SSLIPv6()
{
$tcpclient = new Tcpclient("ipv6.google.com", 443);
$tcpclient = new Tcpclient("ipv6.fournier38.fr", 443);
$tcpclient->connect();
$tcpclient->cryptoEnable(true);
$tcpclient->send("GET / HTTP/1.1\r\n" .
"Host: www.google.fr\r\n" .
"Host: ipv6.fournier38.f\r\n" .
"User-Agent: DomFramework\r\n" .
"Accept: *" . "/*\r\n" .
"\r\n");

View File

@@ -25,7 +25,7 @@ define("PHPUNIT", "ON-GOING");
file_put_contents(
"Tests/DblayerooSqliteTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"sqlite",
file_get_contents("Tests/DblayerooComplet.php")
)
@@ -33,7 +33,7 @@ file_put_contents(
file_put_contents(
"Tests/DblayerooMySQLTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"mysql",
file_get_contents("Tests/DblayerooComplet.php")
)
@@ -41,7 +41,7 @@ file_put_contents(
file_put_contents(
"Tests/DblayerooPostgreSQLTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"pgsql",
file_get_contents("Tests/DblayerooComplet.php")
)
@@ -49,7 +49,7 @@ file_put_contents(
file_put_contents(
"Tests/DblayerSqliteTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"sqlite",
file_get_contents("Tests/DblayerComplet.php")
)
@@ -57,7 +57,7 @@ file_put_contents(
file_put_contents(
"Tests/DblayerMySQLTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"mysql",
file_get_contents("Tests/DblayerComplet.php")
)
@@ -65,7 +65,7 @@ file_put_contents(
file_put_contents(
"Tests/DblayerPostgreSQLTest.php",
str_replace(
"{ENGINE}",
"ENGINE",
"pgsql",
file_get_contents("Tests/DblayerComplet.php")
)

View File

@@ -214,7 +214,7 @@ class Authldap extends Auth
"email" => $vals["mail"][0]];
}
unset($data[$key]["mail"]["count"]);
unset($data[$key]["email"]["count"]);
}
return $data;

View File

@@ -490,10 +490,10 @@ class Authorizationdb extends Authorization
* Change mode bits for an object
* Need to be the owner of the object or the root administrator
* @param string $object Object path to change
* @param integer $mod Bits of authorization
* @param integer $modbits Bits of authorization
* @return boolean TRUE or an exception with the error message
*/
public function chmod($object, $mod)
public function chmod($object, $modbits)
{
if ($this->db === null) {
throw new \Exception(dgettext(
@@ -743,6 +743,7 @@ class Authorizationdb extends Authorization
foreach ($parents as $i => $p) {
$found = false;
$r = [];
foreach ($res as $r) {
if ($r["object"] === $p) {
$found = true;

View File

@@ -41,7 +41,7 @@ class Authshibboleth extends Auth
/**
* The optional URL to change the user password
*/
public $urlPasswd = "";
public $urlPasswdChange = "";
/**
* No connection to shibboleth

View File

@@ -91,6 +91,7 @@ class Cli
// This error code is not included in error_reporting
return;
}
$severity = "ERROR";
switch ($errno) {
case E_ERROR:
$severity = "ERROR";
@@ -217,6 +218,7 @@ class Cli
}
die("No controllers/models available in " . getcwd() . "\n");
}
$classes = [];
foreach ($files as $file) {
if (strpos($file, "_")) {
$classes[substr(strstr($file, "_"), 1, -4)] = $file;
@@ -415,16 +417,21 @@ class Cli
if (in_array("-?", $argv, true)) {
// Question mark display the PHPDoc of the method
$comment = trim(substr($r1->getDocComment(), 3, -2));
if ($comment !== "") {
$comment .= "\n";
$comment = "";
if (isset($r1)) {
$comment = trim(substr($r1->getDocComment(), 3, -2));
if ($comment !== "") {
$comment .= "\n";
}
}
$comment .= trim(substr($r2->getDocComment(), 3, -2));
$comment = preg_replace("#^\s*\*\s*#m", "", $comment);
$comment = preg_replace("#@param .+ \\$(\w+) #U", "<\\1> ", $comment);
$params = "";
foreach ($r1->getParameters() as $param) {
$params .= "<" . $param->name . "> ";
if (isset($r1)) {
foreach ($r1->getParameters() as $param) {
$params .= "<" . $param->name . "> ";
}
}
foreach ($r2->getParameters() as $param) {
$params .= "<" . $param->name . "> ";
@@ -449,7 +456,7 @@ class Cli
// (Array management in CLI)
foreach ($argv as $key => $arg) {
// Don't modify the stdin
if (isset($keyStdIn) && $key === $keyStdIn) {
if ($key === $keyStdIn) {
continue;
}
$pairs = explode('&', $arg);

View File

@@ -694,7 +694,7 @@ class Console
*/
public function completeFunction($completionKeys, $completionFunction)
{
if (! is_string($completionKeys) && ! is_boolean($completionKeys)) {
if (! is_string($completionKeys) && ! is_bool($completionKeys)) {
$this->consoleException("Can not set the completionKeys : not a string");
}
if ($completionKeys === true) {

View File

@@ -351,12 +351,12 @@ class Dblayeroo
if ($this->sep === "") {
$this->DBException(dgettext("domframework", "Database not connected"));
}
$res = [];
switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
case "sqlite":
$req = "SELECT name FROM sqlite_master WHERE type='table'";
$st = self::$instance[$this->dsn]->prepare($req);
$st->execute();
$res = [];
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
if ($d["name"] !== "sqlite_sequence") {
$res[] = $d["name"];
@@ -369,7 +369,6 @@ class Dblayeroo
WHERE TABLE_SCHEMA='" . $this->databasename() . "'";
$st = self::$instance[$this->dsn]->prepare($req);
$st->execute();
$res = [];
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
$res[] = $d["TABLE_NAME"];
}
@@ -380,7 +379,6 @@ class Dblayeroo
WHERE schemaname = 'public'";
$st = self::$instance[$this->dsn]->prepare($req);
$st->execute();
$res = [];
while ($d = $st->fetch(\PDO::FETCH_ASSOC)) {
$res[] = $d["tablename"];
}
@@ -430,6 +428,7 @@ class Dblayeroo
"No table name defined to create the table"
), 500);
}
$sql = "";
switch (self::$instance[$this->dsn]->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
case "sqlite":
$sql = "CREATE TABLE IF NOT EXISTS " .
@@ -1684,7 +1683,7 @@ class Dblayeroo
}
@list($func, $param) = explode("(", $realType);
$func = trim($func);
$method = "checkRealType_" . $func;
$method = "checkRealType" . ucfirst($func);
if (! method_exists($this, $method)) {
$this->DBException("Invalid setRealType provided : " .
"field '$field' : unknown realType provided '$func'");
@@ -2008,10 +2007,10 @@ class Dblayeroo
}
$display = $name = trim($display);
$pos = strpos($display, "(");
$separator = "";
if ($pos !== false) {
$func = strtoupper(trim(substr($name, 0, $pos)));
$name = trim(substr($name, $pos + 1, -1));
$separator = "";
if (
in_array($func, ["AVG", "COUNT", "GROUP_CONCAT", "MAX",
"MIN","SUM"], true)
@@ -2848,6 +2847,7 @@ class Dblayeroo
"The unique configuration is not an array"
));
}
$sql = "";
switch ($this->command) {
case "SELECT":
$sql = "SELECT";
@@ -2980,7 +2980,7 @@ class Dblayeroo
try {
$st = self::$instance[$this->dsn]->prepare($sql);
} catch (\Exception $e) {
$this->DBException($e->getMessage());
throw $this->DBException($e->getMessage());
}
}
foreach ($this->whereGetValues() as $hash => $val) {
@@ -3053,7 +3053,7 @@ class Dblayeroo
$text .= "(date)\n";
} else {
$text .= "(UNKNOWN)\n";
$this->DBException("TO BE DEVELOPPED : " . $fields[$field][0]);
$this->DBException("TO BE DEVELOPPED : Unknown type : " . $type);
}
if (!$textForm) {
if ($value === null) {
@@ -3306,6 +3306,7 @@ class Dblayeroo
}
$setValues = $values;
$foundImpactedLines = 0;
$resUpdate = [];
foreach ($uniques as $k => $columns) {
if ($update) {
// Can not update multiple UNIQUE rows with the same value
@@ -3314,7 +3315,7 @@ class Dblayeroo
} elseif (is_array($columns)) {
$cols = $columns;
} else {
$this->DBException(dgettext(
throw $this->DBException(dgettext(
"domframework",
"Unique def is not a string or an array"
));
@@ -3592,7 +3593,7 @@ class Dblayeroo
$val = trim($values[$field]);
@list($func, $param) = explode("(", $this->realTypes[$field]);
$func = trim($func);
$method = "checkRealType_" . $func;
$method = "checkRealType" . ucfirst($func);
$res = $this->$method($val, $this->realTypes[$field]);
if (is_string($res)) {
$errors[$field] = $res;
@@ -3796,7 +3797,7 @@ class Dblayeroo
break;
}
}
if ($autoInc !== null) {
if ($autoInc !== null && isset($col)) {
$autoInc = $this->table . "_{$col}_seq";
}
}
@@ -3912,7 +3913,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_integerPositive($val, $definition)
private function checkRealTypeIntegerPositive($val, $definition)
{
if (substr($val, 0, 1) === "-") {
return dgettext("domframework", "Invalid positive integer : " .
@@ -3935,7 +3936,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_integer($val, $definition)
private function checkRealTypeInteger($val, $definition)
{
if (strspn($val, "0123456789-") !== strlen($val)) {
return dgettext("domframework", "Invalid integer : " .
@@ -3959,7 +3960,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_allowedchars($val, $definition)
private function checkRealTypeAllowedchars($val, $definition)
{
list($func, $param) = explode("(", $definition);
if ($param === null) {
@@ -3988,7 +3989,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_array($val, $definition)
private function checkRealTypeArray($val, $definition)
{
list($func, $param) = explode("(", $definition);
if ($param === null) {
@@ -4018,7 +4019,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_regex($val, $definition)
private function checkRealTypeRegex($val, $definition)
{
list($func, $param) = explode("(", $definition);
if ($param === null) {
@@ -4047,7 +4048,7 @@ class Dblayeroo
* @param string $definition The definition of the type
* @return string or null
*/
private function checkRealType_mail($val, $definition)
private function checkRealTypeMail($val, $definition)
{
if (!! filter_var($val, FILTER_VALIDATE_EMAIL)) {
return;
@@ -4059,9 +4060,9 @@ class Dblayeroo
* Check the type "uuid"
* @param string $val The value to check
* @param string $definition The definition of the type
* @return string or null
* @return string|null
*/
private function checkRealType_uuid($val, $definition)
private function checkRealTypeUuid($val, $definition)
{
if (strlen($val) !== 36) {
return dgettext("domframework", "Invalid UUID provided : " .
@@ -4082,9 +4083,9 @@ class Dblayeroo
* Check the type "sqldate"
* @param string $val The value to check
* @param string $definition The definition of the type
* @return string or null
* @return string|null
*/
private function checkRealType_sqldate($val, $definition)
private function checkRealTypeSqldate($val, $definition)
{
if (strlen($val) !== 10) {
return dgettext("domframework", "Invalid date provided : " .
@@ -4117,9 +4118,9 @@ class Dblayeroo
* Check the type "sqltime"
* @param string $val The value to check
* @param string $definition The definition of the type
* @return string or null
* @return string|null
*/
private function checkRealType_sqltime($val, $definition)
private function checkRealTypeSqltime($val, $definition)
{
if (strlen($val) !== 8) {
return dgettext("domframework", "Invalid time provided : " .
@@ -4152,9 +4153,9 @@ class Dblayeroo
* Check the type "sqldatetime"
* @param string $val The value to check
* @param string $definition The definition of the type
* @return string or null
* @return string|null
*/
private function checkRealType_sqldatetime($val, $definition)
private function checkRealTypeSqldatetime($val, $definition)
{
if (strlen($val) !== 19) {
return dgettext("domframework", "Invalid date and time provided : " .

View File

@@ -691,6 +691,7 @@ class File
$newname = $this->realpath($newname);
$this->checkPathRO(dirname($oldname));
$this->checkPathRW(dirname($newname));
$rc = "";
if (is_dir($oldname)) {
// Copy directory structure
if (! $this->file_exists($newname)) {

View File

@@ -91,7 +91,7 @@ class Form
* Set the debug level
* @param integer $val The debug value
*/
public function debug($val)
public function debug($val): self
{
$this->debug = $val;
return $this;
@@ -101,7 +101,7 @@ class Form
* Set the csrf enable
* @param integer $val The csrf check
*/
public function csrf($val)
public function csrf($val): self
{
$this->csrf = !! $val;
return $this;
@@ -111,7 +111,7 @@ class Form
* Set the method
* @param string $val The method to use
*/
public function method($val)
public function method($val): self
{
$this->method = strtolower($val);
return $this;
@@ -121,7 +121,7 @@ class Form
* Set the csrf token name
* @param integer $val The csrf token name
*/
public function csrfField($val)
public function csrfField($val): self
{
$this->csrfField = $val;
return $this;
@@ -131,7 +131,7 @@ class Form
* Set the titlewidth
* @param integer $val The titlewidth
*/
public function titlewidth($val)
public function titlewidth($val): self
{
$this->titlewidth = $val;
return $this;
@@ -141,7 +141,7 @@ class Form
* Set the fieldwidth
* @param integer $val The fieldwidth
*/
public function fieldwidth($val)
public function fieldwidth($val): self
{
$this->fieldwidth = $val;
return $this;
@@ -151,7 +151,7 @@ class Form
* Set the formClass
* @param integer $val The formClass
*/
public function formClass($val)
public function formClass($val): self
{
$this->formClass = $val;
return $this;
@@ -164,7 +164,7 @@ class Form
* @param string|null $loggingBasemsg The basemsg added at the beginning of
* the log
*/
public function logging($loggingCallable, $loggingBasemsg = "")
public function logging($loggingCallable, $loggingBasemsg = ""): void
{
$this->loggingCallable = $loggingCallable;
$this->loggingBasemsg = $loggingBasemsg;
@@ -175,7 +175,7 @@ class Form
* Can be : Bootstrap3, Bootstrap4 (later Bulma)
* @param string $formTemplate The template to use
*/
public function formTemplate($formTemplate)
public function formTemplate($formTemplate): self
{
if (
! in_array(
@@ -195,7 +195,7 @@ class Form
* @param integer $prio The priority of the message
* @param string $msg The message to store
*/
private function loggingCallable($prio, $msg)
private function loggingCallable($prio, $msg): void
{
if (! is_callable($this->loggingCallable)) {
return;
@@ -236,7 +236,7 @@ class Form
*
* @param array $fields The fields to be displayed
*/
public function fields($fields)
public function fields($fields): void
{
$this->fields = $fields;
}
@@ -246,7 +246,7 @@ class Form
* in fields method
* @param object $field The field to add
*/
public function addfield($field)
public function addfield($field): void
{
$this->fields[] = $field;
}
@@ -256,7 +256,7 @@ class Form
* NEVER read the values from $_POST in your codes or CSRF will not be
* checked
*/
public function values()
public function values(): array
{
$values = [];
if ($this->method === "post") {
@@ -328,7 +328,7 @@ class Form
$method = 'post',
$values = null,
$errors = []
) {
): string {
if (count($this->fields) === 0) {
$this->loggingCallable(
LOG_ERR,
@@ -456,7 +456,7 @@ class Form
* Check the token from the user
* @param string $tokenFromUser The value form the user's token
*/
public function checkToken($tokenFromUser)
public function checkToken($tokenFromUser): void
{
$csrf = new Csrf();
$csrf->field = $this->csrfField;
@@ -468,10 +468,11 @@ class Form
/**
* Return the token generated in form
*/
public function getToken()
public function getToken(): string
{
if ($this->csrfToken === "") {
$this->createToken();
$csrf = new Csrf();
$this->csrfToken = $csrf->newToken();
}
return $this->csrfToken;
}
@@ -484,7 +485,7 @@ class Form
* stored one if the value is null)
* @return array containing the errors
*/
public function verify($values, $fields = [])
public function verify($values, $fields = []): array
{
if (count($fields) === 0) {
if (! isset($_SESSION["domframework"]["form"]["fields"])) {
@@ -528,7 +529,7 @@ class Form
* $spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]);
* $route->redirect ("/admin/space/");
*/
public function redirectIfError($values, $errors, $route, $url = "")
public function redirectIfError($values, $errors, $route, $url = ""): void
{
$this->saveValuesErrors($values, $errors);
if ($url === "") {
@@ -547,7 +548,7 @@ class Form
* @param array $values The values of the fields filled by the user
* @param array|null $errors The errors detected by a verify
*/
public function saveValuesErrors($values, $errors = [])
public function saveValuesErrors($values, $errors = []): void
{
if (isset($_SESSION)) {
$_SESSION["domframework"]["form"][$this->formName]["values"] = $values;
@@ -559,7 +560,7 @@ class Form
* Reset the saved values to provide a clean form next page
* Need the session to work
*/
public function saveValuesErrorsReset()
public function saveValuesErrorsReset(): void
{
unset($_SESSION["domframework"]["form"][$this->formName]["values"]);
unset($_SESSION["domframework"]["form"][$this->formName]["errors"]);
@@ -571,7 +572,7 @@ class Form
* @param array $values The values returned if there is no stored values
* @return array The values to use
*/
public function getOldValues($values)
public function getOldValues($values): array
{
if (isset($_SESSION["domframework"]["form"][$this->formName]["values"])) {
$values = $_SESSION["domframework"]["form"][$this->formName]["values"];
@@ -586,7 +587,7 @@ class Form
* @param array $errors The values returned if there is no stored values
* @return array The errors to use
*/
public function getOldErrors($errors)
public function getOldErrors($errors): array
{
if (isset($_SESSION["domframework"]["form"][$this->formName]["errors"])) {
$errors = $_SESSION["domframework"]["form"][$this->formName]["errors"];
@@ -605,14 +606,14 @@ class Form
* @param string $outputFormat The output format of the date
* @return string
*/
public function convertDate($inputDate, $inputFormat, $outputFormat)
public function convertDate($inputDate, $inputFormat, $outputFormat): string
{
$date = \DateTime::CreateFromFormat($inputFormat, $inputDate);
if ($date === false) {
return $inputDate;
}
$errors = $date->getLastErrors();
if ($errors["warning_count"] > 0 || $errors["error_count"] > 0) {
if (is_array($errors) && ($errors["warning_count"] > 0 || $errors["error_count"] > 0)) {
return $inputDate;
}
return $date->format($outputFormat);

View File

@@ -87,6 +87,10 @@ class Formfield
* The Bootstrap width of the column of fields
*/
public $fieldwidth = 10;
/**
* Form template (Bootstrap3 by default)
*/
public $formTemplate = "Bootstrap3";
/**
* When adding a field, the name and the label are the minimum mandatory
@@ -102,7 +106,7 @@ class Formfield
/**
* Display really the form
*/
public function display()
public function display(): string
{
$func = "field" . $this->formTemplate . $this->type;
return $this->$func();
@@ -113,7 +117,7 @@ class Formfield
* Set the type of the field
* @param string $val The value of the type of the field
*/
public function type($val)
public function type($val): self
{
$this->type = $val;
return $this;
@@ -123,7 +127,7 @@ class Formfield
* Set the hidden of the field
* @param string $val The value of the hidden of the field
*/
public function hidden($val)
public function hidden($val): self
{
$this->hidden = !! $val;
return $this;
@@ -133,7 +137,7 @@ class Formfield
* Set the help of the field
* @param string $val The value of the help of the field
*/
public function help($val)
public function help($val): self
{
$this->help = $val;
return $this;
@@ -143,7 +147,7 @@ class Formfield
* Set the placeholder
* @param string $val The value of the placeholder
*/
public function placeholder($val)
public function placeholder($val): self
{
$this->placeholder = $val;
return $this;
@@ -153,7 +157,7 @@ class Formfield
* Set the multiple
* @param string $val The value of the multiple
*/
public function multiple($val)
public function multiple($val): self
{
$this->multiple = $val;
return $this;
@@ -163,7 +167,7 @@ class Formfield
* Set the group
* @param string $val The value of the group
*/
public function group($val)
public function group($val): self
{
$this->group = $val;
return $this;
@@ -173,7 +177,7 @@ class Formfield
* Set the readonly
* @param string $val The value of the readonly
*/
public function readonly($val)
public function readonly($val): self
{
$this->readonly = !! $val;
return $this;
@@ -183,7 +187,7 @@ class Formfield
* Set the mandatory
* @param string $val The value of the mandatory
*/
public function mandatory($val)
public function mandatory($val): self
{
$this->mandatory = !! $val;
return $this;
@@ -193,7 +197,7 @@ class Formfield
* Set the rows
* @param string $val The value of the rows
*/
public function rows($val)
public function rows($val): self
{
$this->rows = $val;
return $this;
@@ -203,7 +207,7 @@ class Formfield
* Set the cols
* @param string $val The value of the cols
*/
public function cols($val)
public function cols($val): self
{
$this->cols = $val;
return $this;
@@ -215,7 +219,7 @@ class Formfield
/**
* Return the checkbox defined
*/
private function fieldBootstrap3checkbox()
private function fieldBootstrap3checkbox(): string
{
// No $this->multiple, $this->rows $this->cols $this->placeholder,
// $this->maxlength
@@ -362,7 +366,7 @@ class Formfield
/**
* Return the hidden field defined
*/
private function fieldBootstrap3hidden()
private function fieldBootstrap3hidden(): string
{
$res = "";
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
@@ -384,7 +388,7 @@ class Formfield
/**
* Return the password field defined
*/
private function fieldBootstrap3password()
private function fieldBootstrap3password(): string
{
$res = "";
// No $this->multiple, $this->rows $this->cols
@@ -468,7 +472,7 @@ class Formfield
/**
* Return the radio field defined
*/
private function fieldBootstrap3radio()
private function fieldBootstrap3radio(): string
{
$res = "";
// No $this->multiple, $this->rows $this->cols $this->placeholder
@@ -570,7 +574,7 @@ class Formfield
/**
* Return the checkbox defined
*/
private function fieldBootstrap3select()
private function fieldBootstrap3select(): string
{
// No $this->placeholder $this->maxlength
$res = "";
@@ -700,7 +704,7 @@ class Formfield
/**
* Return the submit defined
*/
private function fieldBootstrap3submit()
private function fieldBootstrap3submit(): string
{
$res = "";
// No $this->label, $this->multiple, $this->error, $this->rows,
@@ -745,7 +749,7 @@ class Formfield
/**
* Return the textarea defined
*/
private function fieldBootstrap3textarea()
private function fieldBootstrap3textarea(): string
{
$res = "";
// No $this->multiple, $this->titles
@@ -831,7 +835,7 @@ class Formfield
/**
* Return the text defined
*/
private function fieldBootstrap3text()
private function fieldBootstrap3text(): string
{
$res = "";
// No $this->multiple, $this->titles, $this->rows, $this->cols
@@ -915,7 +919,7 @@ class Formfield
/**
* Return the file defined
*/
private function fieldBootstrap3file()
private function fieldBootstrap3file(): string
{
$res = "";
// No $this->multiple, $this->titles, $this->rows, $this->cols
@@ -1017,7 +1021,7 @@ class Formfield
/**
* Return the checkbox defined
*/
private function fieldBootstrap4checkbox()
private function fieldBootstrap4checkbox(): string
{
// No $this->multiple, $this->rows $this->cols $this->placeholder,
// $this->maxlength
@@ -1172,7 +1176,7 @@ class Formfield
/**
* Return the hidden field defined
*/
private function fieldBootstrap4hidden()
private function fieldBootstrap4hidden(): string
{
$res = "";
// No $this->label, $this->multiple, $this->readonly, $this->hidden,
@@ -1194,7 +1198,7 @@ class Formfield
/**
* Return the password field defined
*/
private function fieldBootstrap4password()
private function fieldBootstrap4password(): string
{
$res = "";
// No $this->multiple, $this->rows $this->cols
@@ -1286,7 +1290,7 @@ class Formfield
/**
* Return the radio field defined
*/
private function fieldBootstrap4radio()
private function fieldBootstrap4radio(): string
{
$res = "";
// No $this->multiple, $this->rows $this->cols $this->placeholder
@@ -1396,7 +1400,7 @@ class Formfield
/**
* Return the checkbox defined
*/
private function fieldBootstrap4select()
private function fieldBootstrap4select(): string
{
// No $this->placeholder $this->maxlength
$res = "";
@@ -1534,7 +1538,7 @@ class Formfield
/**
* Return the submit defined
*/
private function fieldBootstrap4submit()
private function fieldBootstrap4submit(): string
{
$res = "";
// No $this->label, $this->multiple, $this->error, $this->rows,
@@ -1579,7 +1583,7 @@ class Formfield
/**
* Return the textarea defined
*/
private function fieldBootstrap4textarea()
private function fieldBootstrap4textarea(): string
{
$res = "";
// No $this->multiple, $this->titles
@@ -1673,7 +1677,7 @@ class Formfield
/**
* Return the text defined
*/
private function fieldBootstrap4text()
private function fieldBootstrap4text(): string
{
$res = "";
// No $this->multiple, $this->titles, $this->rows, $this->cols
@@ -1765,7 +1769,7 @@ class Formfield
/**
* Return the file defined
*/
private function fieldBootstrap4file()
private function fieldBootstrap4file(): string
{
$res = "";
// No $this->multiple, $this->titles, $this->rows, $this->cols

View File

@@ -42,6 +42,12 @@ class Graph
*/
public $title = null;
/**
* The graph title position
* @var string
*/
private $titlePosition = null;
/**
* The height of the graph (150px by default)
*/

View File

@@ -73,6 +73,7 @@ class GraphAxisHorizontal extends GraphAxisGeneral
*/
public function positionMin($value)
{
$posCenter = $this->position($value);
if ($this->numerical) {
return $posCenter;
}

View File

@@ -137,6 +137,7 @@ class GraphAxisVertical extends GraphAxisGeneral
*/
public function positionMin($value)
{
$posCenter = $this->position($value);
if ($this->numerical) {
return $posCenter;
}

View File

@@ -268,7 +268,7 @@ class GraphSerie
"Invalid style provided to serie"
), 406);
}
$styleClass = "GraphStyle" . $style;
$styleClass = "GraphStyle" . ucfirst($style);
if ($this->style === null) {
$this->style = new $styleClass();
}

View File

@@ -364,7 +364,7 @@ class Language
$languageCode,
"domframework",
LC_MESSAGES,
dirname(__FILE__) . "/locale"
__DIR__ . "/../locale"
);
$dfDir = dirname(dirname(dirname($dfFile)));
$this->languageActivation($dfFile, $languageCode, LC_MESSAGES, $dfDir);

View File

@@ -437,7 +437,7 @@ class Logger
break;
}
}
openlog($this->syslogPrefix, null, $this->syslogFacility);
openlog($this->syslogPrefix, LOG_PID, $this->syslogFacility);
// Syslog display a #012 when there is a \n : remove it
$message = str_replace("\n", "", $message);
syslog($priority, $message);

View File

@@ -302,7 +302,7 @@ class Mail
PREG_SPLIT_DELIM_CAPTURE
);
// Remove the first 2 dashes : the boundary is stored like in the headers
$boundary = "";
$boundary = $boundaryCR = "";
while (count($boundaryArray) > 0 && substr($boundary, 0, 2) !== "--") {
// Skip the lines until the coundary is found. The boundary start by --
$boundary = array_shift($boundaryArray);
@@ -379,9 +379,9 @@ class Mail
$headersEML = ltrim(substr($content, 0, $pos +
strlen($headerBodySeparator)));
$headersArray = [];
$prevCR = "";
if ($headersEML !== "" && $headersEML !== "--") {
$prev = "";
$prevCR = "";
$headersSplit = preg_split(
"#([\r\n]+)#",
$headersEML,
@@ -527,6 +527,7 @@ class Mail
// multipart/alternative)
$sectionList = $this->sectionList();
$sectionIDtoChange = "";
$boundary = $boundaryCR = "";
foreach ($sectionList as $sectionID) {
$section = $this->sectionGet($sectionID);
if (
@@ -628,10 +629,10 @@ class Mail
"text/html; charset=$charset",
$sectionIDtoChange
);
if (isset($boundary)) {
if ($boundary !== "") {
$part["_boundary"] = $boundary;
}
if (isset($boundaryCR)) {
if ($boundaryCR != "") {
$part["_boundaryCR"] = $boundaryCR;
}
$this->sectionUpdate($sectionIDtoChange, $part);
@@ -654,6 +655,7 @@ class Mail
// multipart/alternative)
$sectionList = $this->sectionList();
$sectionIDtoChange = "";
$boundary = "";
foreach ($sectionList as $sectionID) {
$section = $this->sectionGet($sectionID);
if (
@@ -736,12 +738,9 @@ class Mail
"text/plain; charset=$charset",
$sectionIDtoChange
);
if (isset($boundary)) {
if ($boundary !== "") {
$part["_boundary"] = $boundary;
}
if (isset($boundaryCR)) {
$part["_boundaryCR"] = $boundaryCR;
}
$this->sectionUpdate($sectionIDtoChange, $part);
$this->createMailEML();
}
@@ -939,6 +938,7 @@ class Mail
);
}
// Add the new section to the mixed section
$contentID = "";
$sectionID = $this->sectionAddDefault();
$this->sectionAddChild($sectionIDMixed, $sectionID);
$finfo = new \finfo(FILEINFO_MIME);
@@ -1059,6 +1059,7 @@ class Mail
), $number), 404);
}
$part = $this->sectionGet($attachmentIDs[$number]);
$res = [];
foreach ($part as $key => $val) {
if ($key[0] === "_") {
if (

View File

@@ -106,6 +106,7 @@ class Smtp
if ($errstr === "" && $php_errormsg !== "") {
$errstr = $php_errormsg;
}
$this->smtpStream = null;
throw new \Exception(sprintf(dgettext(
"domframework",
"Can't connect to SMTP server : %s"
@@ -123,7 +124,11 @@ class Smtp
$this->putLine("STARTTLS\r\n");
$context["ssl"]["verify_peer_name"] = $this->starttlsCheck;
$context["ssl"]["verify_peer"] = $this->starttlsCheck;
stream_context_set_option($this->smtpStream, $context);
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
stream_context_set_option($this->smtpStream, $context);
} else {
stream_context_set_options($this->smtpStream, $context);
}
// The track_errors permit to create the $php_errormsg in case of
// warning
ini_set('track_errors', 1);
@@ -135,6 +140,7 @@ class Smtp
) ===
false
) {
$this->smtpStream = null;
throw new \Exception(sprintf(dgettext(
"domframework",
"Can't activate STARTTLS %s"
@@ -144,6 +150,7 @@ class Smtp
$this->debug("STARTTLS ACTIVATED\n");
}
} elseif ($this->starttls === "encrypt") {
$this->smtpStream = null;
throw new \Exception(dgettext(
"domframework",
"Server doesn't supports STARTTLS"
@@ -166,6 +173,7 @@ class Smtp
$this->putLine("AUTH LOGIN " . base64_encode($this->user) . "\r\n");
$this->putLine(base64_encode($this->password) . "\r\n");
} else {
$this->smtpStream = null;
throw new \Exception(
dgettext(
"domframework",

View File

@@ -246,9 +246,14 @@ class Tcpclient
"capture_peer_cert_chain" => true,
"SNI_enabled" => true,
]];
$optionsMerged = [];
$optionsMerged["ssl"] = array_merge($optionsBase["ssl"], $options);
stream_set_blocking($this->socket, true);
stream_context_set_option($this->socket, $optionsMerged);
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
stream_context_set_option($this->socket, $optionsMerged);
} else {
stream_context_set_options($this->socket, $optionsMerged);
}
$php_errormsg = "";
ini_set("track_errors", 1);
$rc = @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);

View File

@@ -228,6 +228,7 @@ class Tcpserver
pcntl_signal(SIGTERM, [$this, "sigTERMINT"]);
pcntl_signal(SIGINT, [$this, "sigTERMINT"]);
cli_set_process_title($this->processName . " main");
$sockServer = [];
foreach ($this->addresses as $key => $address) {
$port = $this->ports[$key];
if (filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
@@ -495,7 +496,11 @@ class Tcpserver
"verify_peer_name" => false,
]];
stream_set_blocking($this->socket, true);
stream_context_set_option($this->socket, $options);
if (version_compare(PHP_VERSION, '8.3.0') <= 0) {
stream_context_set_option($this->socket, $options);
} else {
stream_context_set_options($this->socket, $options);
}
return @stream_socket_enable_crypto($this->socket, !!$val, $cryptoMethod);
}