Skip to content

Commit

Permalink
Use Symfony's new contract Event class instead of the deprecated one
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Sep 12, 2019
1 parent ac48a9b commit a1ef939
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 2 files
+1 −0 composer.json
+1 −1 composer.lock
7 changes: 3 additions & 4 deletions lib/private/Authentication/TwoFactorAuth/Registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\Authentication\TwoFactorAuth\RegistryEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;

class Registry implements IRegistry {

/** @var ProviderUserAssignmentDao */
private $assignmentDao;

/** @var EventDispatcherInterface */
/** @var IEventDispatcher */
private $dispatcher;

public function __construct(ProviderUserAssignmentDao $assignmentDao,
EventDispatcherInterface $dispatcher) {
IEventDispatcher $dispatcher) {
$this->assignmentDao = $assignmentDao;
$this->dispatcher = $dispatcher;
}
Expand Down
18 changes: 16 additions & 2 deletions lib/public/EventDispatcher/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace OCP\EventDispatcher;

use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;

/**
* Base event class for the event dispatcher service
Expand All @@ -35,6 +35,20 @@
*
* @since 17.0.0
*/
class Event extends GenericEvent {
class Event extends SymfonyEvent {

/**
* Compatibility constructor
*
* In Nextcloud 17.0.0 this event class used a now deprecated/removed Symfony base
* class that had a constructor (with default arguments). To lower the risk of
* a breaking change (PHP won't allow parent constructor calls if there is none),
* this empty constructor's only purpose is to hopefully not break existing sub-
* classes of this class.
*
* @since 18.0.0
*/
public function __construct() {
}

}
1 change: 1 addition & 0 deletions lib/public/Security/CSP/AddContentSecurityPolicyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AddContentSecurityPolicyEvent extends Event {
* @since 17.0.0
*/
public function __construct(ContentSecurityPolicyManager $policyManager) {
parent::__construct();
$this->policyManager = $policyManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AddFeaturePolicyEvent extends Event {
* @since 17.0.0
*/
public function __construct(FeaturePolicyManager $policyManager) {
parent::__construct();
$this->policyManager = $policyManager;
}

Expand Down
16 changes: 8 additions & 8 deletions tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);

/**
* @copyright 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
Expand Down Expand Up @@ -29,27 +29,27 @@
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\Authentication\TwoFactorAuth\RegistryEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

class RegistryTest extends TestCase {

/** @var ProviderUserAssignmentDao|PHPUnit_Framework_MockObject_MockObject */
/** @var ProviderUserAssignmentDao|MockObject */
private $dao;

/** @var IEventDispatcher|MockObject */
private $dispatcher;

/** @var Registry */
private $registry;

/** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */
private $dispatcher;

protected function setUp() {
parent::setUp();

$this->dao = $this->createMock(ProviderUserAssignmentDao::class);
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);

$this->registry = new Registry($this->dao, $this->dispatcher);
}
Expand Down

0 comments on commit a1ef939

Please sign in to comment.