Skip to content

Commit a8b064c

Browse files
committed
bug #98 Fix deprecations triggered by PHP 8.1 (derrabus)
This PR was merged into the 3.x-dev branch. Discussion ---------- Fix deprecations triggered by PHP 8.1 Commits ------- 006eaf8 Fix deprecations triggered by PHP 8.1
2 parents b5e4d8e + 006eaf8 commit a8b064c

File tree

7 files changed

+51
-18
lines changed

7 files changed

+51
-18
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php: ['7.2.5', '7.3', '7.4', '8.0']
16+
php: ['7.2.5', '7.3', '7.4', '8.0', '8.1']
1717
include:
1818
- php: '7.4'
1919
deps: lowest

Tests/Domain/AuditLoggerTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
namespace Symfony\Component\Security\Acl\Tests\Domain;
1313

14-
class AuditLoggerTest extends \PHPUnit\Framework\TestCase
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Security\Acl\Domain\AuditLogger;
16+
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAuditableEntryInterface;
17+
18+
class AuditLoggerTest extends TestCase
1519
{
1620
/**
1721
* @dataProvider getTestLogData
@@ -73,11 +77,11 @@ public function getTestLogData()
7377

7478
protected function getEntry()
7579
{
76-
return $this->createMock('Symfony\Component\Security\Acl\Model\AuditableEntryInterface');
80+
return $this->createMock(SerializableAuditableEntryInterface::class);
7781
}
7882

7983
protected function getLogger()
8084
{
81-
return $this->getMockForAbstractClass('Symfony\Component\Security\Acl\Domain\AuditLogger');
85+
return $this->getMockForAbstractClass(AuditLogger::class);
8286
}
8387
}

Tests/Domain/EntryTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111

1212
namespace Symfony\Component\Security\Acl\Tests\Domain;
1313

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\Security\Acl\Domain\Entry;
16+
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
17+
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;
1518

16-
class EntryTest extends \PHPUnit\Framework\TestCase
19+
class EntryTest extends TestCase
1720
{
1821
public function testConstructor()
1922
{
@@ -77,7 +80,7 @@ public function testSerializeUnserialize()
7780
$uAce = unserialize($serialized);
7881

7982
$this->assertNull($uAce->getAcl());
80-
$this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity());
83+
$this->assertInstanceOf(SecurityIdentityInterface::class, $uAce->getSecurityIdentity());
8184
$this->assertEquals($ace->getId(), $uAce->getId());
8285
$this->assertEquals($ace->getMask(), $uAce->getMask());
8386
$this->assertEquals($ace->getStrategy(), $uAce->getStrategy());
@@ -109,11 +112,11 @@ protected function getAce($acl = null, $sid = null)
109112

110113
protected function getAcl()
111114
{
112-
return $this->createMock('Symfony\Component\Security\Acl\Model\AclInterface');
115+
return $this->createMock(SerializableAclInterface::class);
113116
}
114117

115118
protected function getSid()
116119
{
117-
return $this->createMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
120+
return $this->createMock(SecurityIdentityInterface::class);
118121
}
119122
}

Tests/Domain/FieldEntryTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
namespace Symfony\Component\Security\Acl\Tests\Domain;
1313

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Component\Security\Acl\Domain\FieldEntry;
1516
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
17+
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;
1618

17-
class FieldEntryTest extends \PHPUnit\Framework\TestCase
19+
class FieldEntryTest extends TestCase
1820
{
1921
public function testConstructor()
2022
{
@@ -31,7 +33,7 @@ public function testSerializeUnserialize()
3133
$uAce = unserialize($serialized);
3234

3335
$this->assertNull($uAce->getAcl());
34-
$this->assertInstanceOf('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface', $uAce->getSecurityIdentity());
36+
$this->assertInstanceOf(SecurityIdentityInterface::class, $uAce->getSecurityIdentity());
3537
$this->assertEquals($ace->getId(), $uAce->getId());
3638
$this->assertEquals($ace->getField(), $uAce->getField());
3739
$this->assertEquals($ace->getMask(), $uAce->getMask());
@@ -86,11 +88,11 @@ protected function getAce($acl = null, $sid = null)
8688

8789
protected function getAcl()
8890
{
89-
return $this->createMock('Symfony\Component\Security\Acl\Model\AclInterface');
91+
return $this->createMock(SerializableAclInterface::class);
9092
}
9193

9294
protected function getSid()
9395
{
94-
return $this->createMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
96+
return $this->createMock(SecurityIdentityInterface::class);
9597
}
9698
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Symfony\Component\Security\Acl\Tests\Fixtures;
4+
5+
use Symfony\Component\Security\Acl\Model\AclInterface;
6+
7+
interface SerializableAclInterface extends AclInterface
8+
{
9+
public function __serialize(): array;
10+
11+
public function __unserialize(array $data): void;
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Symfony\Component\Security\Acl\Tests\Fixtures;
4+
5+
use Symfony\Component\Security\Acl\Model\AuditableEntryInterface;
6+
7+
interface SerializableAuditableEntryInterface extends AuditableEntryInterface
8+
{
9+
public function __serialize(): array;
10+
11+
public function __unserialize(array $data): void;
12+
}

Tests/Voter/AclVoterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
1818
use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
1919
use Symfony\Component\Security\Acl\Exception\NoAceFoundException;
20-
use Symfony\Component\Security\Acl\Model\AclInterface;
2120
use Symfony\Component\Security\Acl\Model\AclProviderInterface;
2221
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface;
2322
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface;
2423
use Symfony\Component\Security\Acl\Permission\PermissionMapInterface;
24+
use Symfony\Component\Security\Acl\Tests\Fixtures\SerializableAclInterface;
2525
use Symfony\Component\Security\Acl\Voter\AclVoter;
2626
use Symfony\Component\Security\Acl\Voter\FieldVote;
2727
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -220,7 +220,7 @@ public function testVoteGrantsAccess($grant)
220220
->expects($this->once())
221221
->method('findAcl')
222222
->with($this->equalTo($oid), $this->equalTo($sids))
223-
->willReturn($acl = $this->createMock(AclInterface::class))
223+
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
224224
;
225225

226226
$acl
@@ -266,7 +266,7 @@ public function testVoteNoAceFound()
266266
->expects($this->once())
267267
->method('findAcl')
268268
->with($this->equalTo($oid), $this->equalTo($sids))
269-
->willReturn($acl = $this->createMock(AclInterface::class))
269+
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
270270
;
271271

272272
$acl
@@ -309,7 +309,7 @@ public function testVoteGrantsFieldAccess($grant)
309309
->expects($this->once())
310310
->method('findAcl')
311311
->with($this->equalTo($oid), $this->equalTo($sids))
312-
->willReturn($acl = $this->createMock(AclInterface::class))
312+
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
313313
;
314314

315315
$acl
@@ -355,7 +355,7 @@ public function testVoteNoFieldAceFound()
355355
->expects($this->once())
356356
->method('findAcl')
357357
->with($this->equalTo($oid), $this->equalTo($sids))
358-
->willReturn($acl = $this->createMock(AclInterface::class))
358+
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
359359
;
360360

361361
$acl
@@ -396,7 +396,7 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje
396396
->expects($this->once())
397397
->method('findAcl')
398398
->with($this->equalTo($oid), $this->equalTo($sids))
399-
->willReturn($acl = $this->createMock(AclInterface::class))
399+
->willReturn($acl = $this->createMock(SerializableAclInterface::class))
400400
;
401401

402402
$acl

0 commit comments

Comments
 (0)