Skip to content

Commit

Permalink
refactor(builder): refactor from zephir.
Browse files Browse the repository at this point in the history
  • Loading branch information
noone-silent committed Aug 1, 2024
1 parent 85be6de commit 2b15c81
Show file tree
Hide file tree
Showing 15 changed files with 207 additions and 668 deletions.
12 changes: 9 additions & 3 deletions src/Mvc/Model/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ final public function autoescape(string $identifier): string
* $builder->betweenHaving("SUM(Robots.price)", 100.25, 200.50);
*```
*
* @param string $expr
* @param string $expr
* @param string|float|int $minimum
* @param string|float|int $maximum
* @param string $operator
* @param string $operator
*
* @throws Exception
* @return BuilderInterface
Expand Down Expand Up @@ -542,7 +542,8 @@ public function columns(array | string $columns): BuilderInterface
* Sets SELECT DISTINCT / SELECT ALL flag
*
*```php
* $builder->distinct();
* $builder->distinct("status");
* $builder->distinct(true);
* $builder->distinct(false);
*```
*
Expand Down Expand Up @@ -1969,6 +1970,11 @@ protected function conditionNotIn(
return $this;
}

/**
* @param array $conditions
*
* @return string
*/
private function mergeConditions(array $conditions): string
{
$mergedConditions = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Mvc/Model/Query/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
interface BuilderInterface
{
public const OPERATOR_AND = "and";
public const OPERATOR_OR = "or";
public const OPERATOR_OR = "or";

/**
* Add a model to take part of the query
Expand Down
3 changes: 1 addition & 2 deletions src/Mvc/Model/QueryInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
Expand All @@ -16,7 +16,6 @@
use Phalcon\Mvc\ModelInterface;

/**
* Phalcon\Mvc\Model\QueryInterface
* Interface for Phalcon\Mvc\Model\Query
*/
interface QueryInterface
Expand Down
7 changes: 2 additions & 5 deletions src/Paginator/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
Expand All @@ -17,9 +17,6 @@
use Phalcon\Paginator\Repository;
use Phalcon\Paginator\RepositoryInterface;

/**
* Phalcon\Paginator\Adapter\AbstractAdapter
*/
abstract class AbstractAdapter implements AdapterInterface
{
/**
Expand Down Expand Up @@ -60,7 +57,7 @@ abstract class AbstractAdapter implements AdapterInterface
public function __construct(array $config)
{
$this->repository = new Repository();
$this->config = $config;
$this->config = $config;

if (isset($config["limit"])) {
$this->setLimit(
Expand Down
4 changes: 2 additions & 2 deletions src/Paginator/Adapter/Model.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Paginator\Adapter;

use Phalcon\Paginator\RepositoryInterface;

/**
* Phalcon\Paginator\Adapter\Model
* This adapter allows to paginate data using a Phalcon\Mvc\Model resultset as a
* base.
* ```php
Expand Down
6 changes: 4 additions & 2 deletions src/Paginator/Adapter/NativeArray.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Paginator\Adapter;
Expand All @@ -16,10 +17,11 @@
use Phalcon\Paginator\RepositoryInterface;

/**
* Phalcon\Paginator\Adapter\NativeArray
* Pagination using a PHP array as source of data
*
* ```php
* use Phalcon\Paginator\Adapter\NativeArray;
*
* $paginator = new NativeArray(
* [
* "data" => [
Expand Down
2 changes: 0 additions & 2 deletions src/Paginator/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
namespace Phalcon\Paginator;

/**
* Phalcon\Paginator\Exception
*
* Exceptions thrown in Phalcon\Paginator will use this class
*/
class Exception extends \Exception
Expand Down
10 changes: 8 additions & 2 deletions src/Paginator/Repository.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Paginator;
Expand All @@ -16,15 +17,20 @@
use Phalcon\Traits\Helper\Str\CamelizeTrait;

/**
* Phalcon\Paginator\Repository
* Repository of current state Phalcon\Paginator\AdapterInterface::paginate()
*/
class Repository implements RepositoryInterface, JsonSerializable
{
use CamelizeTrait;

/**
* @var array
*/
protected array $aliases = [];

/**
* @var array
*/
protected array $properties = [];

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Paginator/RepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
Expand All @@ -19,14 +19,14 @@
*/
interface RepositoryInterface
{
public const PROPERTY_CURRENT_PAGE = 'current';
public const PROPERTY_FIRST_PAGE = 'first';
public const PROPERTY_ITEMS = 'items';
public const PROPERTY_LAST_PAGE = 'last';
public const PROPERTY_LIMIT = 'limit';
public const PROPERTY_NEXT_PAGE = 'next';
public const PROPERTY_CURRENT_PAGE = 'current';
public const PROPERTY_FIRST_PAGE = 'first';
public const PROPERTY_ITEMS = 'items';
public const PROPERTY_LAST_PAGE = 'last';
public const PROPERTY_LIMIT = 'limit';
public const PROPERTY_NEXT_PAGE = 'next';
public const PROPERTY_PREVIOUS_PAGE = 'previous';
public const PROPERTY_TOTAL_ITEMS = 'total_items';
public const PROPERTY_TOTAL_ITEMS = 'total_items';

/**
* Gets the aliases for properties repository
Expand Down
46 changes: 0 additions & 46 deletions tests/_data/fixtures/Factory/TestFactory.php

This file was deleted.

1 change: 0 additions & 1 deletion tests/_support/Helper/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Codeception\Exception\ModuleException;
use Codeception\Module;
use Codeception\TestInterface;
use Codeception\Util\Debug;
use PDO;
use Phalcon\DataMapper\Pdo\Connection;

Expand Down
Loading

0 comments on commit 2b15c81

Please sign in to comment.