mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
types, rename
This commit is contained in:
@@ -50,9 +50,13 @@ class Params
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
* @param array{
|
||||
* forceDefault?: bool,
|
||||
* orderBy?: ?string,
|
||||
* order?: SearchParams::ORDER_ASC|SearchParams::ORDER_DESC|null,
|
||||
* } $params
|
||||
*/
|
||||
public static function fromArray(array $params): self
|
||||
public static function fromAssoc(array $params): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
@@ -71,10 +75,13 @@ class Params
|
||||
throw new InvalidArgumentException("Bad orderBy.");
|
||||
}
|
||||
|
||||
/** @var ?string $order */
|
||||
$order = $object->order;
|
||||
|
||||
if (
|
||||
$object->order &&
|
||||
$object->order !== SearchParams::ORDER_ASC &&
|
||||
$object->order !== SearchParams::ORDER_DESC
|
||||
$order &&
|
||||
$order !== SearchParams::ORDER_ASC &&
|
||||
$order !== SearchParams::ORDER_DESC
|
||||
) {
|
||||
throw new InvalidArgumentException("Bad order.");
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class SearchParams
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getRaw(): array
|
||||
{
|
||||
@@ -320,7 +320,7 @@ class SearchParams
|
||||
/**
|
||||
* Create an instance from a raw.
|
||||
*
|
||||
* @param stdClass|array<string,mixed> $params
|
||||
* @param stdClass|array<string, mixed> $params
|
||||
*/
|
||||
public static function fromRaw($params): self
|
||||
{
|
||||
@@ -493,7 +493,7 @@ class SearchParams
|
||||
/**
|
||||
* For compatibility with the legacy definition.
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
private function adjustParams(array &$params): void
|
||||
{
|
||||
|
||||
@@ -396,7 +396,7 @@ class SelectBuilder
|
||||
|
||||
$order = $this->searchParams?->getOrder();
|
||||
|
||||
$params = OrderParams::fromArray([
|
||||
$params = OrderParams::fromAssoc([
|
||||
'forceDefault' => true,
|
||||
'order' => $order,
|
||||
]);
|
||||
@@ -429,7 +429,7 @@ class SelectBuilder
|
||||
{
|
||||
assert($this->queryBuilder !== null);
|
||||
|
||||
$params = WhereParams::fromArray([
|
||||
$params = WhereParams::fromAssoc([
|
||||
'applyPermissionCheck' => $this->applyWherePermissionCheck,
|
||||
'forbidComplexExpressions' => $this->applyComplexExpressionsForbidden,
|
||||
]);
|
||||
@@ -458,7 +458,7 @@ class SelectBuilder
|
||||
!$this->applyDefaultOrder &&
|
||||
($this->searchParams->getOrderBy() || $this->searchParams->getOrder())
|
||||
) {
|
||||
$params = OrderParams::fromArray([
|
||||
$params = OrderParams::fromAssoc([
|
||||
//'forbidComplexExpressions' => $this->applyComplexExpressionsForbidden,
|
||||
'orderBy' => $this->searchParams->getOrderBy(),
|
||||
'order' => $this->searchParams->getOrder(),
|
||||
|
||||
@@ -45,9 +45,12 @@ class Params
|
||||
{}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
* @param array{
|
||||
* applyPermissionCheck?: bool,
|
||||
* forbidComplexExpressions?: bool,
|
||||
* } $params
|
||||
*/
|
||||
public static function fromArray(array $params): self
|
||||
public static function fromAssoc(array $params): self
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testFromArray()
|
||||
{
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
'order' => 'DESC',
|
||||
'orderBy' => 'test',
|
||||
//'forbidComplexExpressions' => true,
|
||||
@@ -55,7 +55,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
//$this->assertTrue($item->forbidComplexExpressions());
|
||||
$this->assertTrue($item->forceDefault());
|
||||
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
//'forbidComplexExpressions' => false,
|
||||
'forceDefault' => false,
|
||||
]);
|
||||
@@ -66,7 +66,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testEmpty()
|
||||
{
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
]);
|
||||
|
||||
$this->assertEquals(null, $item->getOrder());
|
||||
@@ -79,7 +79,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$params = Params::fromArray([
|
||||
$params = Params::fromAssoc([
|
||||
'order' => 'd',
|
||||
]);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$params = Params::fromArray([
|
||||
$params = Params::fromAssoc([
|
||||
'bad' => 'd',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$whereItem = $searchParams->getWhere();
|
||||
|
||||
$whereParams = WhereParams::fromArray([
|
||||
$whereParams = WhereParams::fromAssoc([
|
||||
'applyPermissionCheck' => true,
|
||||
'forbidComplexExpressions' => true,
|
||||
]);
|
||||
@@ -209,7 +209,7 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
$whereParams
|
||||
);
|
||||
|
||||
$orderParams = OrderParams::fromArray([
|
||||
$orderParams = OrderParams::fromAssoc([
|
||||
//'forbidComplexExpressions' => true,
|
||||
'orderBy' => $searchParams->getOrderBy(),
|
||||
'order' => $searchParams->getOrder(),
|
||||
@@ -248,7 +248,7 @@ class SelectBuilderTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$searchParams = SearchParams::fromRaw($raw);
|
||||
|
||||
$orderParams = OrderParams::fromArray([
|
||||
$orderParams = OrderParams::fromAssoc([
|
||||
'forceDefault' => true,
|
||||
'order' => null,
|
||||
]);
|
||||
|
||||
@@ -43,7 +43,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testFromArray()
|
||||
{
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
'applyPermissionCheck' => true,
|
||||
'forbidComplexExpressions' => true,
|
||||
]);
|
||||
@@ -51,7 +51,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertTrue($item->applyPermissionCheck());
|
||||
$this->assertTrue($item->forbidComplexExpressions());
|
||||
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
'applyPermissionCheck' => false,
|
||||
'forbidComplexExpressions' => false,
|
||||
]);
|
||||
@@ -59,7 +59,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertFalse($item->applyPermissionCheck());
|
||||
$this->assertFalse($item->forbidComplexExpressions());
|
||||
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
'applyPermissionCheck' => false,
|
||||
'forbidComplexExpressions' => true,
|
||||
]);
|
||||
@@ -70,7 +70,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testEmpty()
|
||||
{
|
||||
$item = Params::fromArray([
|
||||
$item = Params::fromAssoc([
|
||||
]);
|
||||
|
||||
$this->assertFalse($item->applyPermissionCheck());
|
||||
@@ -81,7 +81,7 @@ class ParamsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$params = Params::fromArray([
|
||||
$params = Params::fromAssoc([
|
||||
'bad' => 'd',
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user