Confusion about curly syntax statement
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
From manual page: https://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex
There is a note about "Complex (curly) syntax" on the manual page:
The value accessed from functions, method calls, static class variables, and class constants inside {$} will be interpreted as the name of a variable in the scope in which the string is defined. Using single curly braces ({}) will not work for accessing the return values of functions or methods or the values of class constants or static class variables.
I did some test to verify the last statement:
function test() { return 'a'; }
class Test {
const A = 'a';
static $b = 'b';
function c() { return 'c'; }
}
echo "{test()}"; // Function in {} not working as expected
echo "{Test::A}"; // Constant in {} not working as expected
echo "{Test::$b}"; // Static property in {} not working as expected
echo "{(new Test())->a()}"; // Instantiate Test and call method c() inside {} not working as expected
$test = new Test(); // Instantiate A outside {}
echo "{$test->c()}"; // Calling the method c() inside {} is working which is not expected
The confusion is on word "methods" in the statement "Using single curly braces ({}) will not work for accessing the return values of functions or methods ...". As you can see from the test above, we can access the return value 'c' of method c(), which violates the statement.
Is there any problem with my understanding? Or the statement from manual is inaccurate on this matter?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked PHP manual section on complex (curly) syntax and compare its statement about methods with the supplied PHP examples. Determine whether the wording needs clarification or correction, then update the relevant documentation text and verify the rendered section and documentation checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100