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

Fix implicit to and from bool type juggling#60890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Girgias wants to merge30 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromGirgias:bool-type-juggling
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
30 commits
Select commitHold shift + click to select a range
d7109ac
Pull fixes from Nicolas
GirgiasJun 24, 2025
4212ed9
Pull ignores/suppressed tests from Nicolas
GirgiasJun 24, 2025
90c0a98
Use false instead of 0
GirgiasJun 24, 2025
d0834ee
IntlTestHelper::requireFullIntl() use null as second arg instead of f…
GirgiasJun 24, 2025
d387c49
Check return value of getenv()
GirgiasJun 24, 2025
ad4fd82
Symfony\Component\Validator\Constraints\Isbn does not take a bool as …
GirgiasJun 24, 2025
2ee80c5
intl false instead of null
GirgiasJun 25, 2025
6190e42
Cast result of preg_match to bool
GirgiasJun 24, 2025
9997d96
Use bool as param type
GirgiasJun 24, 2025
78f4f10
Cast bitwise op result to bool
GirgiasJun 24, 2025
de4c7d5
ErrorHandler::handleError() cast bitwise op to bool and use false ins…
GirgiasJun 24, 2025
17ab127
Yield empty string when no doc comment exists
GirgiasJun 24, 2025
f677c74
Set value to null if parse_url() fails badly and returns false
GirgiasJun 24, 2025
90401c0
Fix deprecation with PHPUnit's assertTrue
GirgiasJun 24, 2025
85de1ec
Remove ZPP test
GirgiasJun 24, 2025
72b9650
file_get_contents() does not take a fopen mode parameter
GirgiasJun 24, 2025
aa67b63
Symfony\Component\String\LazyString::resolve() add explicit string cast
GirgiasJun 24, 2025
2317f30
Fix string to true type juggling in test
GirgiasJun 24, 2025
4edbb43
Remove ZPP test
GirgiasJun 24, 2025
2017a7b
Use empty string instead of false
GirgiasJun 24, 2025
e816540
Explicit cast to bool from string
GirgiasJun 25, 2025
8afc277
Definition::addMethodCall() arg 3 must be a bool v2
GirgiasJun 25, 2025
4d883cc
Fix test passing false to ?string type
GirgiasJun 29, 2025
218a4f8
Remove ZPP tests testing false to string coercion
GirgiasJun 29, 2025
5397577
NumberFormatter::setAttribute() takes values of type int|float
GirgiasJun 29, 2025
dfcef56
Default non-existing environment variable to empty string
GirgiasJun 29, 2025
a828919
Split grapheme extraction and check if one is found
GirgiasJun 29, 2025
52dec0e
Fix substr with bool?
GirgiasJun 29, 2025
f3286e3
Use '1' instead of true
GirgiasJun 29, 2025
fa063a6
cookie_httponly key does not support values of auto
GirgiasJun 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2141,7 +2141,7 @@ public function testMoney()
publicfunctiontestMoneyWithoutCurrency()
{
$form =$this->factory->createNamed('name','Symfony\Component\Form\Extension\Core\Type\MoneyType',1234.56, [
'currency' =>false,
'currency' =>null,
]);

$this->assertWidgetMatchesXpath($form->createView(), ['id' =>'my&id','attr' => ['class' =>'my&class']],
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,8 +94,8 @@ public static function provideObjectFieldAclCases()
return [
[null,null,null],
['object',null,'object'],
['object',false,newFieldVote('object',false)],
['object',0,newFieldVote('object',0)],
['object','',newFieldVote('object',false)],
['object','0',newFieldVote('object',0)],
['object','',newFieldVote('object','')],
['object','field',newFieldVote('object','field')],
];
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$container->register(StaticExtensionWithAttributes::class, StaticExtensionWithAttributes::class)
->setAutoconfigured(true);
$container->register(RuntimeExtensionWithAttributes::class, RuntimeExtensionWithAttributes::class)
->setArguments(['prefix_'])
->setArguments([true])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

given thatRuntimeExtensionWithAttributes performs string concatenation with the prefix, the right fix is rather to change the constructor argument type in this RuntimeExtensionWithAttributes stub class.

->setAutoconfigured(true);

$container->setAlias('twig_test','twig')->setPublic(true);
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -146,7 +146,7 @@ public function onKernelRequest(RequestEvent $event): void
if ($mediaType =$this->getMediaType($asset->publicPath)) {
$response->headers->set('Content-Type',$mediaType);
}
$response->headers->set('X-Assets-Dev',true);
$response->headers->set('X-Assets-Dev','1');

$event->setResponse($response);
$event->stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletionsrc/Symfony/Component/BrowserKit/AbstractBrowser.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -686,7 +686,7 @@ private function updateServerFromUri(array $server, string $uri): array

privatefunctionextractHost(string$uri): ?string
{
$host =parse_url($uri, \PHP_URL_HOST);
$host =parse_url($uri, \PHP_URL_HOST) ?:null;

if ($port =parse_url($uri, \PHP_URL_PORT)) {
return$host.':'.$port;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,7 +57,11 @@ public function testUrlDecodeParameters()

publicstaticfunctionprovideCreateConnection():array
{
$hosts =array_map(fn ($host) =>\sprintf('host[%s]',$host),explode('',getenv('REDIS_CLUSTER_HOSTS')));
$envHosts =getenv('REDIS_CLUSTER_HOSTS');
if ($envHosts ===false) {
$envHosts ='';
}
$hosts =array_map(fn ($host) =>\sprintf('host[%s]',$host),explode('',$envHosts));

return [
[
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,7 +122,7 @@ private function generateSignature(\ReflectionClass $class): iterable
yieldprint_r($attributes,true);
$attributes = [];

yield$class->getDocComment();
yield$class->getDocComment() ?:'';
yield (int)$class->isFinal();
yield (int)$class->isAbstract();

Expand All@@ -144,7 +144,7 @@ private function generateSignature(\ReflectionClass $class): iterable
yieldprint_r($attributes,true);
$attributes = [];

yield$p->getDocComment();
yield$p->getDocComment() ?:'';
yield$p->isDefault() ?'<default>' :'';
yield$p->isPublic() ?'public' :'protected';
yield$p->isStatic() ?'static' :'';
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,7 @@ protected function processValue(mixed $value, bool $isRoot = false): mixed
$setters =$value->getMethodCalls();
$value->setMethodCalls($withers);
foreach ($settersas$call) {
$value->addMethodCall($call[0],$call[1],$call[2] ??false);
$value->addMethodCall($call[0],$call[1],isset($call[2]) &&$call[2]);
}
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1174,7 +1174,7 @@ private function createService(Definition $definition, array &$inlineServices, b
if (!$definition->isDeprecated() &&\is_array($factory) &&\is_string($factory[0])) {
$r =new \ReflectionClass($factory[0]);

if (0 <strpos($r->getDocComment(),"\n * @deprecated")) {
if (0 <strpos($r->getDocComment() ?:'',"\n * @deprecated")) {
trigger_deprecation('','','The "%s" service relies on the deprecated "%s" factory class. It should either be deprecated or its factory upgraded.',$id,$r->name);
}
}
Expand All@@ -1191,7 +1191,7 @@ private function createService(Definition $definition, array &$inlineServices, b
$service =$r->getConstructor() ?$r->newInstanceArgs($arguments) :$r->newInstance();
}

if (!$definition->isDeprecated() &&0 <strpos($r->getDocComment(),"\n * @deprecated")) {
if (!$definition->isDeprecated() &&0 <strpos($r->getDocComment() ?:'',"\n * @deprecated")) {
trigger_deprecation('','','The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.',$id,$r->name);
}
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -527,7 +527,7 @@ private function collectLineage(string $class, array &$lineage): void
return;
}
$file = $r->getFileName();
if (str_ends_with($file, ') : eval()\'d code')) {
if ($file &&str_ends_with($file, ') : eval()\'d code')) {
$file = substr($file, 0, strrpos($file, '(', -17));
}
if (!$file || $this->doExport($file) === $exportedFile = $this->export($file)) {
Expand DownExpand Up@@ -575,10 +575,10 @@ private function generateProxyClasses(): array
}
do {
$file = $r->getFileName();
if (str_ends_with($file, ') : eval()\'d code')) {
if ($file &&str_ends_with($file, ') : eval()\'d code')) {
$file = substr($file, 0, strrpos($file, '(', -17));
}
if (is_file($file)) {
if ($file &&is_file($file)) {
$this->container->addResource(new FileResource($file));
}
$r = $r->getParentClass() ?: null;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -339,7 +339,12 @@ private function parseDefinition(\DOMElement $service, string $file, Definition
}

foreach ($this->getChildren($service, 'call') as $call) {
$definition->addMethodCall($call->getAttribute('method'), $this->getArgumentsAsPhp($call, 'argument', $file), XmlUtils::phpize($call->getAttribute('returns-clone')));
$returnClone = $call->getAttribute('returns-clone');
$definition->addMethodCall(
$call->getAttribute('method'),
$this->getArgumentsAsPhp($call, 'argument', $file),
$returnClone !== '' ? XmlUtils::phpize($returnClone) : false
);
}

$tags = $this->getChildren($service, 'tag');
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,7 @@ public static function invalidDeprecationMessageProvider(): array
"With \ns" => ["invalid \n message %alias_id%"],
'With */s' => ['invalid */ message %alias_id%'],
'message not containing required %alias_id% variable' => ['this is deprecated'],
'template not containing required %alias_id% variable' => [true],
//'template not containing required %alias_id% variable' => [true],
];
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -336,7 +336,7 @@ public function testProcessFailsOnPassingClassToScalarTypedParameter()
(newCheckTypeDeclarationsPass(true))->process($container);
}

publicfunctiontestProcessSuccessOnPassingBadScalarType()
publicfunctionxtestProcessSuccessOnPassingBadScalarType()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why skipping this test ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I stole this from@nicolas-grekas WIP commit:nicolas-grekas@02e3881

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

🙈

OskarStark reacted with laugh emoji
{
$container =newContainerBuilder();

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,7 +205,7 @@ public static function invalidDeprecationMessageProvider(): array
"With\ns" => ["invalid\n message %service_id%"],
'With */s' => ['invalid */ message %service_id%'],
'message not containing require %service_id% variable' => ['this is deprecated'],
'template not containing require %service_id% variable' => [true],
//'template not containing require %service_id% variable' => [true],
];
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/Symfony/Component/DomCrawler/UriResolver.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,7 +71,7 @@ public static function resolve(string $uri, ?string $baseUri): string

// relative path
$path =parse_url(substr($baseUri,\strlen($baseUriCleaned)), \PHP_URL_PATH) ??'';
$path =self::canonicalizePath(substr($path,0,strrpos($path,'/')).'/'.$uri);
$path =self::canonicalizePath(substr($path,0,strrpos($path,'/') ?:0).'/'.$uri);

return$baseUriCleaned.('' ===$path ||'/' !==$path[0] ?'/' :'').$path;
}
Expand Down
8 changes: 4 additions & 4 deletionssrc/Symfony/Component/ErrorHandler/ErrorHandler.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -396,13 +396,13 @@ public function handleError(int $type, string $message, string $file, int $line)
$silenced = 0 === ($level & $type);
// Strong errors are not authorized to be silenced.
$level |= \E_RECOVERABLE_ERROR | \E_USER_ERROR | \E_DEPRECATED | \E_USER_DEPRECATED;
$log = $this->loggedErrors & $type;
$throw = $this->thrownErrors & $type & $level;
$log =(bool) ($this->loggedErrors & $type);
$throw =(bool) ($this->thrownErrors & $type & $level);
$type &= $level | $this->screamedErrors;

// Never throw on warnings triggered by assert()
if (\E_WARNING === $type && 'a' === $message[0] && 0 === strncmp($message, 'assert(): ', 10)) {
$throw =0;
$throw =false;
}

if (!$type || (!$log && !$throw)) {
Expand DownExpand Up@@ -472,7 +472,7 @@ public function handleError(int $type, string $message, string $file, int $line)
}

if ($this->isRecursive) {
$log =0;
$log =false;
} else {
try {
$this->isRecursive = true;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,7 +96,7 @@ public static function getConstructorTestData()
'1k','1ki','1m','1mi','1g','1gi',
],
[
false,null,'',
null,'',
'','foobar',
'=1','===1',
'0 . 1','123 .45','234. 567',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,7 +72,7 @@ public static function getTestFilterData()

$inner[] =newMockSplFileInfo([
'name' =>'unreadable-file.txt',
'contents' =>false,
'contents' =>'',
'type' =>'file',
'mode' =>'r+', ]
);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,6 +92,6 @@ public function reverseTransform(mixed $value): ?\DateInterval

privatefunctionisISO8601(string$string):bool
{
returnpreg_match('/^P(?=\w*(?:\d|%\w))(?:\d+Y|%[yY]Y)?(?:\d+M|%[mM]M)?(?:(?:\d+D|%[dD]D)|(?:\d+W|%[wW]W))?(?:T(?:\d+H|[hH]H)?(?:\d+M|[iI]M)?(?:\d+S|[sS]S)?)?$/',$string);
return(bool)preg_match('/^P(?=\w*(?:\d|%\w))(?:\d+Y|%[yY]Y)?(?:\d+M|%[mM]M)?(?:(?:\d+D|%[dD]D)|(?:\d+W|%[wW]W))?(?:T(?:\d+H|[hH]H)?(?:\d+M|[iI]M)?(?:\d+S|[sS]S)?)?$/',$string);
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,7 +163,7 @@ protected function getNumberFormatter(): \NumberFormatter
$formatter->setAttribute(\NumberFormatter::ROUNDING_MODE,$this->roundingMode);
}

$formatter->setAttribute(\NumberFormatter::GROUPING_USED,$this->grouping);
$formatter->setAttribute(\NumberFormatter::GROUPING_USED,(int)$this->grouping);

return$formatter;
}
Expand Down
1 change: 0 additions & 1 deletionsrc/Symfony/Component/Form/Tests/ButtonBuilderTest.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,7 +51,6 @@ public static function getInvalidNames()
{
return [
[''],
[false],
[null],
];
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,7 +95,7 @@ public function testTransformWithRounding($input, $output, $roundingMode)
publicfunctiontestReverseTransform()
{
// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);

\Locale::setDefault('de_AT');

Expand All@@ -115,7 +115,7 @@ public function testReverseTransformEmpty()
publicfunctiontestReverseTransformWithGrouping()
{
// Since we test against "de_DE", we need the full implementation
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);

\Locale::setDefault('de_DE');

Expand DownExpand Up@@ -210,7 +210,7 @@ public function testReverseTransformExpectsValidNumber()
publicfunctiontestReverseTransformExpectsInteger($number,$locale)
{
$this->expectException(TransformationFailedException::class);
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);

\Locale::setDefault($locale);

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ protected function tearDown(): void
publicfunctiontestTransform()
{
// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);

\Locale::setDefault('de_AT');

Expand DownExpand Up@@ -71,7 +71,7 @@ public function testTransformEmpty()
publicfunctiontestReverseTransform()
{
// Since we test against "de_AT", we need the full implementation
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);

\Locale::setDefault('de_AT');

Expand DownExpand Up@@ -99,7 +99,7 @@ public function testReverseTransformEmpty()
publicfunctiontestFloatToIntConversionMismatchOnReverseTransform()
{
$transformer =newMoneyToLocalizedStringTransformer(null,null,null,100);
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);
\Locale::setDefault('de_AT');

$this->assertSame(3655, (int)$transformer->reverseTransform('36,55'));
Expand All@@ -108,7 +108,7 @@ public function testFloatToIntConversionMismatchOnReverseTransform()
publicfunctiontestFloatToIntConversionMismatchOnTransform()
{
$transformer =newMoneyToLocalizedStringTransformer(null,null, \NumberFormatter::ROUND_DOWN,100);
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);
\Locale::setDefault('de_AT');

$this->assertSame('10,20',$transformer->transform(1020));
Expand All@@ -120,7 +120,7 @@ public function testValidNumericValuesWithNonDotDecimalPointCharacter()
setlocale(\LC_ALL,'de_AT.UTF-8');

$transformer =newMoneyToLocalizedStringTransformer(4,null,null,100);
IntlTestHelper::requireFullIntl($this,false);
IntlTestHelper::requireFullIntl($this,null);
\Locale::setDefault('de_AT');

$this->assertSame('0,0035',$transformer->transform(12 /34));
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp