-
Notifications
You must be signed in to change notification settings - Fork 110
Named args #853
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
Open
mkornaukhov
wants to merge
13
commits into
master
Choose a base branch
from
mkornaukhov03/named-args
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Named args #853
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cbc05ae
Add syntax; order still matter
mkornaukhov 5f7d055
Tmp
mkornaukhov 7b9c9a1
Change DeduceImplicitTypes
mkornaukhov 7b9b75a
Got how it works
mkornaukhov fa32aa6
refactoring in CheckFuncCallAndVararg pass
mkornaukhov 2c50bd8
Add error check(unknown argument name); implement detect_variadic_args
mkornaukhov cdcbb9f
Implement
mkornaukhov f25a047
Fix
mkornaukhov 583ec06
Fix
mkornaukhov 487fdec
Fix tests
mkornaukhov 467e15d
Merge branch 'master' of github.com:VKCOM/kphp into mkornaukhov03/nam…
mkornaukhov ea6a3f5
Fix error with clone
mkornaukhov edb7635
Fix review notes
mkornaukhov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| @php8 ok | ||
| <?php | ||
|
|
||
| function test($a, $b, $c = "c", $d = "d", $e = "e") { | ||
| echo "a=$a, b=$b, c=$c, d=$d, e=$e\n"; | ||
| } | ||
|
|
||
| $a = "A"; $b = "B"; $c = "C"; $d = "D"; $e = "E"; | ||
|
|
||
| test("A", "B", "C", d: "D", e: "E"); | ||
| test("A", "B", "C", e: "E", d: "D"); | ||
| test(e: "E", a: "A", d: "D", b: "B", c: "C"); | ||
| test("A", "B", "C", e: "E"); | ||
|
|
||
| test("A", "B", e : "E"); | ||
| test("A", "B", d : "D"); | ||
| test("A", "B", d : "D", e : "E"); | ||
|
|
||
| test2("A", "B", "C", d: "D", e: "E"); | ||
| test2("A", "B", "C", e: "E", d: "D"); | ||
| test2(e: "E", a: "A", d: "D", b: "B", c: "C"); | ||
| test2("A", "B", "C", e: "E"); | ||
|
|
||
| test($a, $b, $c, d: $d, e: $e); | ||
| test($a, $b, $c, e: $e, d: $d); | ||
| test(e: $e, a: $a, d: $d, b: $b, c: $c); | ||
| test(a: $a, b: $b, c: $c, e: $e); | ||
|
|
||
| test2($a, $b, $c, d: $d, e: $e); | ||
| test2($a, $b, $c, e: $e, d: $d); | ||
| test2(e: $e, a: $a, d: $d, b: $b, c: $c); | ||
| test2(a: $a, b: $b, c: $c, e: $e); | ||
|
|
||
| function test2($a, $b, $c = "c", $d = "d", $e = "e") { | ||
| echo "a=$a, b=$b, c=$c, d=$d, e=$e\n"; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| @ok php8 | ||
| <?php | ||
|
|
||
| function foo(int $a, int $b, ...$args) { | ||
| var_dump($args); | ||
| var_dump($a); | ||
| var_dump($b); | ||
| } | ||
|
|
||
| foo(a : 1, b : 2, args2: [3, 4, 5]); | ||
| foo(1, b : 2, args2: [3, 4, 5]); | ||
| foo(1, 2, args2 : [3, 4, 5]); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| @ok php8 | ||
| <?php | ||
|
|
||
| function test1($a = 'a', $b = 'b') { | ||
| echo "a: $a, b: $b\n"; | ||
| } | ||
|
|
||
| function test2($a = SOME_CONST, $b = 'b') { | ||
| echo "a: $a, b: $b\n"; | ||
| } | ||
|
|
||
| test1(b: 'B'); | ||
|
|
||
| define('SOME_CONST', 'X'); | ||
| test2(b: 'B'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| @kphp_should_fail | ||
| /Named arguments with duplicated name: 'a'/ | ||
| <?php | ||
|
|
||
|
|
||
| function test($a, $b) {} | ||
|
|
||
| test(a: 1, a: 2); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably add
kphp_error (...)here.