Skip to content

Commit

Permalink
Fix mentions in PR and refactor namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tacxou committed Jul 28, 2020
1 parent 6e79d26 commit c453ecf
Show file tree
Hide file tree
Showing 79 changed files with 235 additions and 248 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@
},
"autoload": {
"psr-4": {
"Phalcon\\Incubator\\": "src/"
"Phalcon\\Incubator\\MongoDB\\": "src/"
},
"files": [
"src/functions.php"
]
},
"autoload-dev": {
"psr-4": {
"Phalcon\\Incubator\\Mvc\\Test\\Integration\\": "tests/integration/",
"Phalcon\\Incubator\\Mvc\\Test\\Unit\\": "tests/unit/",
"Phalcon\\Incubator\\Test\\Fixtures\\": "tests/_data/fixtures/"
"Phalcon\\Incubator\\MongoDB\\Mvc\\Test\\Integration\\": "tests/integration/",
"Phalcon\\Incubator\\MongoDB\\Mvc\\Test\\Unit\\": "tests/unit/",
"Phalcon\\Incubator\\MongoDB\\Test\\Fixtures\\": "tests/_data/fixtures/"
}
},
"minimum-stability": "dev",
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ parameters:
ignoreErrors:
- '#Parameter \#1 \$eventsManager of method Phalcon#'
reportUnmatchedIgnoredErrors: false
© 2020 GitHub, Inc.
10 changes: 4 additions & 6 deletions src/Mvc/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

declare(strict_types=1);

namespace Phalcon\Incubator\Mvc;
namespace Phalcon\Incubator\MongoDB\Mvc;

use JsonSerializable;
use MongoDB\BSON\ObjectId;
Expand All @@ -26,9 +26,9 @@
use Phalcon\Di\DiInterface;
use Phalcon\Events\ManagerInterface as EventsManagerInterface;
use Phalcon\Helper\Str;
use Phalcon\Incubator\Mvc\Collection\BehaviorInterface;
use Phalcon\Incubator\Mvc\Collection\Exception;
use Phalcon\Incubator\Mvc\Collection\ManagerInterface;
use Phalcon\Incubator\MongoDB\Mvc\Collection\BehaviorInterface;
use Phalcon\Incubator\MongoDB\Mvc\Collection\Exception;
use Phalcon\Incubator\MongoDB\Mvc\Collection\ManagerInterface;
use Phalcon\Messages\Message;
use Phalcon\Messages\MessageInterface;
use Phalcon\Mvc\EntityInterface;
Expand Down Expand Up @@ -1516,8 +1516,6 @@ public function assign(array $data, $dataColumnMap = null, $whiteList = null): C
}

foreach (get_object_vars($this) as $key => $value) {
$reserved = $this->getReservedAttributes();

if (isset($dataMapped[$key])) {
if (is_array($whiteList) && !in_array($key, $whiteList)) {
continue;
Expand Down
13 changes: 7 additions & 6 deletions src/Mvc/Collection/Behavior.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,16 +9,18 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection;
declare(strict_types=1);

use Phalcon\Incubator\Mvc\CollectionInterface;
namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;

/**
* Phalcon\Incubator\Mvc\Collection\Behavior
* Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior
*
* This is an optional base class for ORM behaviors
*
* @package Phalcon\Incubator\Mvc\Collection
* @package Phalcon\Incubator\MongoDB\Mvc\Collection
*/
abstract class Behavior implements BehaviorInterface
{
Expand All @@ -43,7 +45,6 @@ public function __construct(array $options = [])
protected function getOptions(?string $eventName = null)
{
if ($eventName !== null) {

return $this->options[$eventName] ?? null;
}

Expand Down
23 changes: 17 additions & 6 deletions src/Mvc/Collection/Behavior/SoftDelete.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<?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\Incubator\Mvc\Collection\Behavior;
namespace Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior;

use Phalcon\Incubator\Mvc\Collection\Behavior;
use Phalcon\Incubator\Mvc\Collection\Exception;
use Phalcon\Incubator\Mvc\CollectionInterface;
use Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior;
use Phalcon\Incubator\MongoDB\Mvc\Collection\Exception;
use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;
use Phalcon\Mvc\EntityInterface;

/**
* Phalcon\Incubator\Mvc\Collection\Behavior\SoftDelete
* Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior\SoftDelete
*
* Instead of permanently delete a record it marks the record as
* deleted changing the value of a flag column
*
* @package Phalcon\Incubator\Mvc\Collection\Behavior
* @package Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior
*/
class SoftDelete extends Behavior
{
Expand Down Expand Up @@ -51,6 +60,8 @@ public function notify(string $type, CollectionInterface $collection)

/**
* Skip the current operation
*
* @noinspection PhpPossiblePolymorphicInvocationInspection
*/
$collection->skipOperation(true);

Expand Down
19 changes: 10 additions & 9 deletions src/Mvc/Collection/Behavior/Timestampable.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,20 +9,22 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection\Behavior;
declare(strict_types=1);

namespace Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior;

use Closure;
use Phalcon\Incubator\Mvc\Collection\Behavior;
use Phalcon\Incubator\Mvc\Collection\Exception;
use Phalcon\Incubator\Mvc\CollectionInterface;
use Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior;
use Phalcon\Incubator\MongoDB\Mvc\Collection\Exception;
use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;

/**
* Phalcon\Incubator\Mvc\Collection\Behavior\Timestampable
* Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior\Timestampable
*
* Allows to automatically update a collection’s attribute saving the
* datetime when a record is created or updated
*
* @package Phalcon\Incubator\Mvc\Collection\Behavior
* @package Phalcon\Incubator\MongoDB\Mvc\Collection\Behavior
*/
class Timestampable extends Behavior
{
Expand All @@ -46,14 +48,13 @@ public function notify(string $type, CollectionInterface $collection)
$options = $this->getOptions($type);

if (is_array($options)) {
$value = $options['value'];
$field = $options['field'];
$format = $options['format'];

/**
* The field name is required in this behavior
*/
if (isset($field)) {
if (!is_string($field)) {
throw new Exception("The option 'field' is required");
}

Expand Down
8 changes: 5 additions & 3 deletions src/Mvc/Collection/BehaviorInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,9 +9,11 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection;
declare(strict_types=1);

use Phalcon\Incubator\Mvc\CollectionInterface;
namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;

/**
* Phalcon\Mvc\Collection\BehaviorInterface
Expand Down
6 changes: 4 additions & 2 deletions src/Mvc/Collection/Document.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php /** @noinspection PhpUndefinedClassInspection */
<?php

/** @noinspection PhpUndefinedClassInspection */

/**
* This file is part of the Phalcon Framework.
Expand All @@ -11,7 +13,7 @@

declare(strict_types=1);

namespace Phalcon\Incubator\Mvc\Collection;
namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

use ArrayAccess;
use JsonSerializable;
Expand Down
12 changes: 7 additions & 5 deletions src/Mvc/Collection/Exception.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,14 +9,16 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection;
declare(strict_types=1);

namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

/**
* Phalcon\Incubator\Mvc\Collection\Exception
* Phalcon\Incubator\MongoDB\Mvc\Collection\Exception
*
* Exceptions thrown in Phalcon\Incubator\Mvc\Collection\* classes will use this class
* Exceptions thrown in Phalcon\Incubator\MongoDB\Mvc\Collection\* classes will use this class
*
* @package Phalcon\Incubator\Mvc\Collection
* @package Phalcon\Incubator\MongoDB\Mvc\Collection
*/
class Exception extends \Phalcon\Exception
{
Expand Down
42 changes: 24 additions & 18 deletions src/Mvc/Collection/Manager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php

/** @noinspection PhpUnused */

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,21 +11,23 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection;
declare(strict_types=1);

namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

use MongoDB\Database;
use Phalcon\Di\DiInterface;
use Phalcon\Di\InjectionAwareInterface;
use Phalcon\Events\EventsAwareInterface;
use Phalcon\Events\ManagerInterface as EventsManagerInterface;
use Phalcon\Helper\Str;
use Phalcon\Incubator\Mvc\CollectionInterface;
use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;

use function Phalcon\Incubator\get_class_lower;
use function Phalcon\Incubator\get_class_ns;
use function Phalcon\Incubator\MongoDB\get_class_lower;
use function Phalcon\Incubator\MongoDB\get_class_ns;

/**
* Phalcon\Incubator\Mvc\Collection\Manager
* Phalcon\Incubator\MongoDB\Mvc\Collection\Manager
*
* This components controls the initialization of collections, keeping record of relations
* between the different collections of the application.
Expand All @@ -36,14 +40,14 @@
* $di->set(
* "collectionManager",
* function () {
* return new \Phalcon\Incubator\Mvc\Collection\Manager();
* return new \Phalcon\Incubator\MongoDB\Mvc\Collection\Manager();
* }
* );
*
* $robot = new Robots($di);
* </code>
*
* @package Phalcon\Incubator\Mvc\Collection
* @package Phalcon\Incubator\MongoDB\Mvc\Collection
*/
class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareInterface
{
Expand All @@ -66,7 +70,7 @@ class Manager implements ManagerInterface, InjectionAwareInterface, EventsAwareI
/** @var array|null $connectionServices */
protected $connectionServices = null;

/** @var ManagerInterface[]|null $customEventsManager */
/** @var ManagerInterface|null $customEventsManager */
protected $customEventsManager = null;

/** @var CollectionInterface|null $lastInitialized */
Expand Down Expand Up @@ -300,14 +304,14 @@ public function getConnection(CollectionInterface $collection)
}

if (!is_object($this->container)) {

throw new Exception('A dependency injector container is required to obtain the services related to the ORM');
throw new Exception(
'A dependency injector container is required to obtain the services related to the ORM'
);
}

$connection = $this->container->getShared($service);

if (!is_object($connection)) {

throw new Exception('Invalid injected connection service');
}

Expand Down Expand Up @@ -351,11 +355,15 @@ public function notifyEvent(string $eventName, CollectionInterface $collection)
/**
* A collection can has a specific events manager for it
*/
if (is_array($this->customEventsManager) && isset($this->customEventsManager[get_class_lower($collection)])) {
$status = $this->customEventsManager->fire("collection:$eventName", $collection);
if (is_array($this->customEventsManager)) {
$customEventsManager = $this->customEventsManager[get_class_lower($collection)];

if (!$status) {
return $status;
if (isset($customEventsManager)) {
$status = $customEventsManager->fire("collection:$eventName", $collection);

if (!$status) {
return $status;
}
}
}

Expand Down Expand Up @@ -385,7 +393,6 @@ public function missingMethod(CollectionInterface $collection, string $eventName
$result = $behavior->missingMethod($collection, $eventName, $data);

if ($result !== null) {

return $result;
}
}
Expand All @@ -395,7 +402,6 @@ public function missingMethod(CollectionInterface $collection, string $eventName
* Dispatch events to the global events manager
*/
if (is_object($this->eventsManager)) {

return $this->eventsManager->fire("collection:$eventName", $collection, $data);
}

Expand Down
8 changes: 5 additions & 3 deletions src/Mvc/Collection/ManagerInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php

/**
* This file is part of the Phalcon Framework.
Expand All @@ -9,11 +9,13 @@
* file that was distributed with this source code.
*/

namespace Phalcon\Incubator\Mvc\Collection;
declare(strict_types=1);

namespace Phalcon\Incubator\MongoDB\Mvc\Collection;

use MongoDB\Database;
use Phalcon\Events\ManagerInterface as EventsManagerInterface;
use Phalcon\Incubator\Mvc\CollectionInterface;
use Phalcon\Incubator\MongoDB\Mvc\CollectionInterface;

/**
* Phalcon\Mvc\Collection\Manager
Expand Down
Loading

0 comments on commit c453ecf

Please sign in to comment.