Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7f62b32

Browse files
malteschlueternicolas-grekas
authored andcommitted
[PropertyAccess] Remove deprecated code
1 parent16f20b2 commit7f62b32

File tree

4 files changed

+11
-123
lines changed

4 files changed

+11
-123
lines changed

‎src/Symfony/Component/PropertyAccess/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* make`PropertyAccessor::__construct()` accept a combination of bitwise flags as first and second arguments
8+
49
5.3.0
510
-----
611

‎src/Symfony/Component/PropertyAccess/PropertyAccessor.php‎

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -86,53 +86,14 @@ class PropertyAccessor implements PropertyAccessorInterface
8686
* Should not be used by application code. Use
8787
* {@link PropertyAccess::createPropertyAccessor()} instead.
8888
*
89-
* @param int $magicMethods A bitwise combination of the MAGIC_* constants
90-
* to specify the allowed magic methods (__get, __set, __call)
91-
* or self::DISALLOW_MAGIC_METHODS for none
92-
* @param int $throw A bitwise combination of the THROW_* constants
93-
* to specify when exceptions should be thrown
94-
* @param PropertyReadInfoExtractorInterface $readInfoExtractor
95-
* @param PropertyWriteInfoExtractorInterface $writeInfoExtractor
89+
* @param int $magicMethods A bitwise combination of the MAGIC_* constants
90+
* to specify the allowed magic methods (__get, __set, __call)
91+
* or self::DISALLOW_MAGIC_METHODS for none
92+
* @param int $throw A bitwise combination of the THROW_* constants
93+
* to specify when exceptions should be thrown
9694
*/
97-
publicfunction__construct(/*int*/$magicMethods =self::MAGIC_GET |self::MAGIC_SET,/*int*/$throw =self::THROW_ON_INVALID_PROPERTY_PATH,CacheItemPoolInterface$cacheItemPool =null,/*PropertyReadInfoExtractorInterface*/$readInfoExtractor =null,/*PropertyWriteInfoExtractorInterface*/$writeInfoExtractor =null)
95+
publicfunction__construct(int$magicMethods =self::MAGIC_GET |self::MAGIC_SET,int$throw =self::THROW_ON_INVALID_PROPERTY_PATH,CacheItemPoolInterface$cacheItemPool =null,PropertyReadInfoExtractorInterface$readInfoExtractor =null,PropertyWriteInfoExtractorInterface$writeInfoExtractor =null)
9896
{
99-
if (\is_bool($magicMethods)) {
100-
trigger_deprecation('symfony/property-access','5.2','Passing a boolean as the first argument to "%s()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).',__METHOD__);
101-
102-
$magicMethods = ($magicMethods ?self::MAGIC_CALL :0) |self::MAGIC_GET |self::MAGIC_SET;
103-
}elseif (!\is_int($magicMethods)) {
104-
thrownew \TypeError(sprintf('Argument 1 passed to "%s()" must be an integer, "%s" given.',__METHOD__,get_debug_type($readInfoExtractor)));
105-
}
106-
107-
if (\is_bool($throw)) {
108-
trigger_deprecation('symfony/property-access','5.3','Passing a boolean as the second argument to "%s()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).',__METHOD__);
109-
110-
$throw =$throw ?self::THROW_ON_INVALID_INDEX :self::DO_NOT_THROW;
111-
112-
if (!\is_bool($readInfoExtractor)) {
113-
$throw |=self::THROW_ON_INVALID_PROPERTY_PATH;
114-
}
115-
}
116-
117-
if (\is_bool($readInfoExtractor)) {
118-
trigger_deprecation('symfony/property-access','5.3','Passing a boolean as the fourth argument to "%s()" is deprecated. Pass a combination of bitwise flags as the second argument instead (i.e an integer).',__METHOD__);
119-
120-
if ($readInfoExtractor) {
121-
$throw |=self::THROW_ON_INVALID_PROPERTY_PATH;
122-
}
123-
124-
$readInfoExtractor =$writeInfoExtractor;
125-
$writeInfoExtractor =4 <\func_num_args() ?func_get_arg(4) :null;
126-
}
127-
128-
if (null !==$readInfoExtractor && !$readInfoExtractorinstanceof PropertyReadInfoExtractorInterface) {
129-
thrownew \TypeError(sprintf('Argument 4 passed to "%s()" must be null or an instance of "%s", "%s" given.',__METHOD__, PropertyReadInfoExtractorInterface::class,get_debug_type($readInfoExtractor)));
130-
}
131-
132-
if (null !==$writeInfoExtractor && !$writeInfoExtractorinstanceof PropertyWriteInfoExtractorInterface) {
133-
thrownew \TypeError(sprintf('Argument 5 passed to "%s()" must be null or an instance of "%s", "%s" given.',__METHOD__, PropertyWriteInfoExtractorInterface::class,get_debug_type($writeInfoExtractor)));
134-
}
135-
13697
$this->magicMethodsFlags =$magicMethods;
13798
$this->ignoreInvalidIndices =0 === ($throw &self::THROW_ON_INVALID_INDEX);
13899
$this->cacheItemPool =$cacheItemPoolinstanceof NullAdapter ?null :$cacheItemPool;// Replace the NullAdapter by the null value

‎src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php‎

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespaceSymfony\Component\PropertyAccess\Tests;
1313

1414
usePHPUnit\Framework\TestCase;
15-
useSymfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1615
useSymfony\Component\Cache\Adapter\ArrayAdapter;
1716
useSymfony\Component\PropertyAccess\Exception\AccessException;
1817
useSymfony\Component\PropertyAccess\Exception\InvalidArgumentException;
@@ -39,8 +38,6 @@
3938

4039
class PropertyAccessorTestextends TestCase
4140
{
42-
use ExpectDeprecationTrait;
43-
4441
/**
4542
* @var PropertyAccessor
4643
*/
@@ -123,19 +120,6 @@ public function testGetValueReturnsNullIfPropertyNotFoundAndExceptionIsDisabled(
123120
$this->assertNull($this->propertyAccessor->getValue($objectOrArray,$path),$path);
124121
}
125122

126-
/**
127-
* @group legacy
128-
* @dataProvider getPathsWithMissingProperty
129-
*/
130-
publicfunctiontestGetValueReturnsNullIfPropertyNotFoundAndExceptionIsDisabledUsingBooleanArgument($objectOrArray,$path)
131-
{
132-
$this->expectDeprecation('Since symfony/property-access 5.3: Passing a boolean as the fourth argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags as the second argument instead (i.e an integer).');
133-
134-
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET, PropertyAccessor::DO_NOT_THROW,null,false);
135-
136-
$this->assertNull($this->propertyAccessor->getValue($objectOrArray,$path),$path);
137-
}
138-
139123
/**
140124
* @dataProvider getPathsWithMissingIndex
141125
*/
@@ -154,19 +138,6 @@ public function testGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnab
154138
$this->propertyAccessor->getValue($objectOrArray,$path);
155139
}
156140

157-
/**
158-
* @group legacy
159-
* @dataProvider getPathsWithMissingIndex
160-
*/
161-
publicfunctiontestGetValueThrowsExceptionIfIndexNotFoundAndIndexExceptionsEnabledUsingBooleanArgument($objectOrArray,$path)
162-
{
163-
$this->expectException(NoSuchIndexException::class);
164-
$this->expectDeprecation('Since symfony/property-access 5.3: Passing a boolean as the second argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).');
165-
166-
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::DISALLOW_MAGIC_METHODS,true);
167-
$this->propertyAccessor->getValue($objectOrArray,$path);
168-
}
169-
170141
publicfunctiontestGetValueThrowsExceptionIfUninitializedProperty()
171142
{
172143
$this->expectException(UninitializedPropertyException::class);
@@ -291,17 +262,6 @@ public function testGetValueDoesNotReadMagicCallByDefault()
291262
$this->propertyAccessor->getValue(newTestClassMagicCall('Bernhard'),'magicCallProperty');
292263
}
293264

294-
/**
295-
* @group legacy
296-
* @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).
297-
*/
298-
publicfunctiontestLegacyGetValueReadsMagicCallIfEnabled()
299-
{
300-
$this->propertyAccessor =newPropertyAccessor(true);
301-
302-
$this->assertSame('Bernhard',$this->propertyAccessor->getValue(newTestClassMagicCall('Bernhard'),'magicCallProperty'));
303-
}
304-
305265
publicfunctiontestGetValueReadsMagicCallIfEnabled()
306266
{
307267
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::MAGIC_GET | PropertyAccessor::MAGIC_SET | PropertyAccessor::MAGIC_CALL);
@@ -410,21 +370,6 @@ public function testSetValueDoesNotUpdateMagicCallByDefault()
410370
$this->propertyAccessor->setValue($author,'magicCallProperty','Updated');
411371
}
412372

413-
/**
414-
* @group legacy
415-
* @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).
416-
*/
417-
publicfunctiontestLegacySetValueUpdatesMagicCallIfEnabled()
418-
{
419-
$this->propertyAccessor =newPropertyAccessor(true);
420-
421-
$author =newTestClassMagicCall('Bernhard');
422-
423-
$this->propertyAccessor->setValue($author,'magicCallProperty','Updated');
424-
425-
$this->assertEquals('Updated',$author->__call('getMagicCallProperty', []));
426-
}
427-
428373
publicfunctiontestSetValueUpdatesMagicCallIfEnabled()
429374
{
430375
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::MAGIC_CALL);
@@ -498,17 +443,6 @@ public function testIsReadableDoesNotRecognizeMagicCallByDefault()
498443
$this->assertFalse($this->propertyAccessor->isReadable(newTestClassMagicCall('Bernhard'),'magicCallProperty'));
499444
}
500445

501-
/**
502-
* @group legacy
503-
* @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).
504-
*/
505-
publicfunctiontestLegacyIsReadableRecognizesMagicCallIfEnabled()
506-
{
507-
$this->propertyAccessor =newPropertyAccessor(true);
508-
509-
$this->assertTrue($this->propertyAccessor->isReadable(newTestClassMagicCall('Bernhard'),'magicCallProperty'));
510-
}
511-
512446
publicfunctiontestIsReadableRecognizesMagicCallIfEnabled()
513447
{
514448
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::MAGIC_CALL);
@@ -570,17 +504,6 @@ public function testIsWritableDoesNotRecognizeMagicCallByDefault()
570504
$this->assertFalse($this->propertyAccessor->isWritable(newTestClassMagicCall('Bernhard'),'magicCallProperty'));
571505
}
572506

573-
/**
574-
* @group legacy
575-
* @expectedDeprecation Since symfony/property-access 5.2: Passing a boolean as the first argument to "Symfony\Component\PropertyAccess\PropertyAccessor::__construct()" is deprecated. Pass a combination of bitwise flags instead (i.e an integer).
576-
*/
577-
publicfunctiontestLegacyIsWritableRecognizesMagicCallIfEnabled()
578-
{
579-
$this->propertyAccessor =newPropertyAccessor(true);
580-
581-
$this->assertTrue($this->propertyAccessor->isWritable(newTestClassMagicCall('Bernhard'),'magicCallProperty'));
582-
}
583-
584507
publicfunctiontestIsWritableRecognizesMagicCallIfEnabled()
585508
{
586509
$this->propertyAccessor =newPropertyAccessor(PropertyAccessor::MAGIC_CALL);

‎src/Symfony/Component/PropertyAccess/composer.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
],
1818
"require": {
1919
"php":">=8.0.2",
20-
"symfony/deprecation-contracts":"^2.1",
2120
"symfony/property-info":"^5.4|^6.0"
2221
},
2322
"require-dev": {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp