Skip to content

Adjust assignment line number for match #6083

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
zend_delayed_compile_var(&var_node, var_ast, BP_VAR_W, 0);
zend_compile_expr(&expr_node, expr_ast);
zend_delayed_compile_end(offset);
CG(zend_lineno) = zend_ast_get_lineno(var_ast);
zend_emit_op_tmp(result, ZEND_ASSIGN, &var_node, &expr_node);
return;
case ZEND_AST_STATIC_PROP:
Expand Down
30 changes: 30 additions & 0 deletions sapi/phpdbg/tests/match_breakpoints_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Test match default breakpoint with variable assignment
--INI--
opcache.enable_cli=0
--PHPDBG--
b 5
b 10
r
q
--EXPECTF--
[Successful compilation of %s.php]
prompt> [Breakpoint #0 added at %s.php:5]
prompt> [Breakpoint #1 added at %s.php:10]
prompt> [Breakpoint #1 at %s.php:10, hits: 1]
>00010: default => 'bar',
00011: };
00012:
prompt>
--FILE--
<?php

$foo = match (0) {
0 => 'foo',
default => 'bar',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
default => 'bar',
default => 'bar', // breakpoint #0

Maybe, so one doesn't have to count lines.

};

$foo = match (1) {
0 => 'foo',
default => 'bar',
};
32 changes: 32 additions & 0 deletions sapi/phpdbg/tests/match_breakpoints_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
Test match default breakpoint with property assignment
--INI--
opcache.enable_cli=0
--PHPDBG--
b 7
b 12
r
q
--EXPECTF--
[Successful compilation of %s.php]
prompt> [Breakpoint #0 added at %s.php:7]
prompt> [Breakpoint #1 added at %s.php:12]
prompt> [Breakpoint #1 at %s.php:12, hits: 1]
>00012: default => 'bar',
00013: };
00014:
prompt>
--FILE--
<?php

$foo = new stdClass();

$foo->bar = match (0) {
0 => 'foo',
default => 'bar',
};

$foo->bar = match (1) {
0 => 'foo',
default => 'bar',
};
32 changes: 32 additions & 0 deletions sapi/phpdbg/tests/match_breakpoints_003.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
Test match default breakpoint with dim assignment
--INI--
opcache.enable_cli=0
--PHPDBG--
b 7
b 12
r
q
--EXPECTF--
[Successful compilation of %s.php]
prompt> [Breakpoint #0 added at %s.php:7]
prompt> [Breakpoint #1 added at %s.php:12]
prompt> [Breakpoint #1 at %s.php:12, hits: 1]
>00012: default => 'bar',
00013: };
00014:
prompt>
--FILE--
<?php

$foo = [];

$foo['foo'] = match (0) {
0 => 'foo',
default => 'bar',
};

$foo->bar = match (1) {
0 => 'foo',
default => 'bar',
};
34 changes: 34 additions & 0 deletions sapi/phpdbg/tests/match_breakpoints_004.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
Test match default breakpoint with static variable assignment
--INI--
opcache.enable_cli=0
--PHPDBG--
b 9
b 14
r
q
--EXPECTF--
[Successful compilation of %s.php]
prompt> [Breakpoint #0 added at %s.php:9]
prompt> [Breakpoint #1 added at %s.php:14]
prompt> [Breakpoint #1 at %s.php:14, hits: 1]
>00014: default => 'bar',
00015: };
00016:
prompt>
--FILE--
<?php

class Foo {
public static $bar;
}

Foo::$bar = match (0) {
0 => 'foo',
default => 'bar',
};

Foo::$bar = match (1) {
0 => 'foo',
default => 'bar',
};