Skip to content

Commit 5a9cb60

Browse files
Use str_starts_with() in a few more places
Some of these are technically slight behavior changes, but not significant ones IMHO.
1 parent 8847d9b commit 5a9cb60

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function replaceMustacheVariables( DOMNode $node, array $data ) {
110110
private function handleAttributeBinding( DOMElement $node, array $data ) {
111111
/** @var DOMAttr $attribute */
112112
foreach ( iterator_to_array( $node->attributes ) as $attribute ) {
113-
if ( !preg_match( '/^:[\w-]+$/', $attribute->name ) ) {
113+
if ( !str_starts_with( $attribute->name, ':' ) ) {
114114
continue;
115115
}
116116

src/JsParsing/BasicJsExpressionParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public function __construct( array $methods ) {
1919
*/
2020
public function parse( $expression ) {
2121
$expression = $this->normalizeExpression( $expression );
22-
if ( strncmp( $expression, '!', 1 ) === 0 ) {
22+
if ( str_starts_with( $expression, '!' ) ) {
2323
return new NegationOperator( $this->parse( substr( $expression, 1 ) ) );
24-
} elseif ( strncmp( $expression, "'", 1 ) === 0 ) {
24+
} elseif ( str_starts_with( $expression, "'" ) && str_ends_with( $expression, "'" ) ) {
2525
return new StringLiteral( substr( $expression, 1, -1 ) );
2626
} elseif ( preg_match( '/^(\w+)\((.*)\)$/', $expression, $matches ) ) {
2727
$methodName = $matches[1];

0 commit comments

Comments
 (0)