Skip to content

Commit a27629f

Browse files
authored
Revert "feature: introduce short hand false syntax for component props (#48084)"
This reverts commit 901ca01.
1 parent 4c5d4d5 commit a27629f

File tree

2 files changed

+0
-64
lines changed

2 files changed

+0
-64
lines changed

src/Illuminate/View/Compilers/ComponentTagCompiler.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ protected function compileOpeningTags(string $value)
127127
(\:\\\$)(\w+)
128128
)
129129
|
130-
(?:
131-
(![\w]+)
132-
)
133-
|
134130
(?:
135131
[\w\-:.@%]+
136132
(
@@ -196,10 +192,6 @@ protected function compileSelfClosingTags(string $value)
196192
(\:\\\$)(\w+)
197193
)
198194
|
199-
(?:
200-
(![\w]+)
201-
)
202-
|
203195
(?:
204196
[\w\-:.@%]+
205197
(
@@ -590,7 +582,6 @@ public function compileSlots(string $value)
590582
protected function getAttributesFromAttributeString(string $attributeString)
591583
{
592584
$attributeString = $this->parseShortAttributeSyntax($attributeString);
593-
$attributeString = $this->parseShortFalseSyntax($attributeString);
594585
$attributeString = $this->parseAttributeBag($attributeString);
595586
$attributeString = $this->parseComponentTagClassStatements($attributeString);
596587
$attributeString = $this->parseComponentTagStyleStatements($attributeString);
@@ -659,21 +650,6 @@ protected function parseShortAttributeSyntax(string $value)
659650
}, $value);
660651
}
661652

662-
/**
663-
* Parses a short false syntax like !required into a fully-qualified syntax like :required="false".
664-
*
665-
* @param string $value
666-
* @return string
667-
*/
668-
protected function parseShortFalseSyntax(string $value)
669-
{
670-
$pattern = "/\s!(\w+)/x";
671-
672-
return preg_replace_callback($pattern, function (array $matches) {
673-
return " :{$matches[1]}=\"false\"";
674-
}, $value);
675-
}
676-
677653
/**
678654
* Parse the attribute bag in a given attribute string into its fully-qualified syntax.
679655
*

tests/View/Blade/BladeComponentTagCompilerTest.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -734,31 +734,6 @@ public function testAttributesTreatedAsPropsAreRemovedFromFinalAttributes()
734734
$this->assertSame($attributes->get('other'), 'ok');
735735
}
736736

737-
public function testFalseShortSyntax()
738-
{
739-
$this->mockViewFactory();
740-
$result = $this->compiler(['bool' => TestBoolComponent::class])->compileTags('<x-bool !bool></x-bool>');
741-
742-
$this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestBoolComponent', 'bool', ['bool' => false])
743-
<?php if (isset(\$attributes) && \$attributes instanceof Illuminate\View\ComponentAttributeBag && \$constructor = (new ReflectionClass(Illuminate\Tests\View\Blade\TestBoolComponent::class))->getConstructor()): ?>
744-
<?php \$attributes = \$attributes->except(collect(\$constructor->getParameters())->map->getName()->all()); ?>
745-
<?php endif; ?>
746-
<?php \$component->withAttributes([]); ?> @endComponentClass##END-COMPONENT-CLASS##", trim($result));
747-
}
748-
749-
public function testSelfClosingComponentWithFalseShortSyntax()
750-
{
751-
$this->mockViewFactory();
752-
$result = $this->compiler(['bool' => TestBoolComponent::class])->compileTags('<x-bool !bool />');
753-
754-
$this->assertSame("##BEGIN-COMPONENT-CLASS##@component('Illuminate\Tests\View\Blade\TestBoolComponent', 'bool', ['bool' => false])
755-
<?php if (isset(\$attributes) && \$attributes instanceof Illuminate\View\ComponentAttributeBag && \$constructor = (new ReflectionClass(Illuminate\Tests\View\Blade\TestBoolComponent::class))->getConstructor()): ?>
756-
<?php \$attributes = \$attributes->except(collect(\$constructor->getParameters())->map->getName()->all()); ?>
757-
<?php endif; ?>
758-
<?php \$component->withAttributes([]); ?>
759-
@endComponentClass##END-COMPONENT-CLASS##", trim($result));
760-
}
761-
762737
protected function mockViewFactory($existsSucceeds = true)
763738
{
764739
$container = new Container;
@@ -822,18 +797,3 @@ public function render()
822797
return 'input';
823798
}
824799
}
825-
826-
class TestBoolComponent extends Component
827-
{
828-
public $bool;
829-
830-
public function __construct($bool)
831-
{
832-
$this->bool = $bool;
833-
}
834-
835-
public function render()
836-
{
837-
return 'bool';
838-
}
839-
}

0 commit comments

Comments
 (0)