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

Commitaf52f6e

Browse files
committed
bug#30361 [PropertyInfo] Fix undefined variable fromConstructor when passing context to getTypes (mantis, OskarStark)
This PR was merged into the 4.2 branch.Discussion----------[PropertyInfo] Fix undefined variable fromConstructor when passing context to getTypes| Q | A| ------------- | ---| Branch? | 4.1, 4.2, master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |symfony/symfony-docs#10969| License | MIT| Doc PR |If passing context to getTypes, it checks value of $context['enable_constructor_extraction'] for true/false or the constructor value of enableConstructorExtraction and should then populate fromConstructor if necessary. The missing brackets around the first part of this check mean that fromConstructor is only applied if context is not set.This fixes the issue described at [symfony/symfony-docs#10969](symfony/symfony-docs#10969)Commits-------8e401af Allow 3rd argument to be null04dc692 Remove whitespace (tab on blank line)a0aa15a Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.phpc2986d5 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php42995c8 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php2d88298 Update src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.phpe43a3bc Update ReflectionExtractorTest.php2c91c75 Update ReflectionExtractorTest.php5acc85c Update ReflectionExtractorTest.phpd0a2dc0 Update ReflectionExtractorTest.phpbe8d14a Fix undefined variable fromConstructor when passing context to getTypes
2 parents203cfc4 +8e401af commitaf52f6e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

‎src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function getTypes($class, $property, array $context = [])
112112
}
113113

114114
if (
115-
$context['enable_constructor_extraction'] ??$this->enableConstructorExtraction &&
115+
($context['enable_constructor_extraction'] ??$this->enableConstructorExtraction) &&
116116
$fromConstructor =$this->extractFromConstructor($class,$property)
117117
) {
118118
return$fromConstructor;

‎src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,29 @@ public function getInitializableProperties(): array
293293
[NotInstantiable::class,'foo',false],
294294
];
295295
}
296+
297+
/**
298+
* @dataProvider constructorTypesProvider
299+
*/
300+
publicfunctiontestExtractTypeConstructor(string$class,string$property,array$type =null)
301+
{
302+
/* Check that constructor extractions works by default, and if passed in via context.
303+
Check that null is returned if constructor extraction is disabled */
304+
$this->assertEquals($type,$this->extractor->getTypes($class,$property, []));
305+
$this->assertEquals($type,$this->extractor->getTypes($class,$property, ['enable_constructor_extraction' =>true]));
306+
$this->assertNull($this->extractor->getTypes($class,$property, ['enable_constructor_extraction' =>false]));
307+
}
308+
309+
publicfunctionconstructorTypesProvider():array
310+
{
311+
return [
312+
// php71 dummy has following constructor: __construct(string $string, int $intPrivate)
313+
[Php71Dummy::class,'string', [newType(Type::BUILTIN_TYPE_STRING,false)]],
314+
[Php71Dummy::class,'intPrivate', [newType(Type::BUILTIN_TYPE_INT,false)]],
315+
// Php71DummyExtended2 adds int $intWithAccessor
316+
[Php71DummyExtended2::class,'intWithAccessor', [newType(Type::BUILTIN_TYPE_INT,false)]],
317+
[Php71DummyExtended2::class,'intPrivate', [newType(Type::BUILTIN_TYPE_INT,false)]],
318+
[DefaultValue::class,'foo',null],
319+
];
320+
}
296321
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp