Great project. I really like it and I am looking forward to more momentum in this space.
I don't know if you are already open for suggestions but I am going to post it anyway so it gets tracked. ;-)
I know that you, @ryangjchandler, are also familiar with Go. One of the things I really like about golang is the possibility to define multiple return values, so I don't have to create a class for e.g. a min and a max value returned by a function.
Current situation
/**
* Here could be some array shape
*/
function calculate(): array {}
The result of this function could be accessed by destructuring the resulting array.
[$min, $max] = calculate();
['min' => $min, 'max' => $max] = calculate();
Please note that the syntax might not be 100 % correct as I am only typing it out of my mind. However, you should be able to get the gist of it.
Alternatively one could create a class containing only the both values like this:
readonly class {
public function __construct(
public int $min,
public int $max,
)
}
However, this might become tedious as I don't want to create a new class (and a new file) for each simple return type.
Proposed solution
function calculate(): int, int {}
$min, $max = calculate();
$min2, _ = calculate();
_, $max2 = calculate();
This would/could transpile down to the following PHP code:
// Here needs to be the correct array syntax for this
function calculate(): array {}
// Or take another var name
$result = calculate();
$min = $result[0];
$max = $result[1];
$result = calculate();
$min2 = $result[0];
$result = calculate();
$max2 = $result[1];
Please note that I made the array of the type array<int, mixed>
to make it simpler. Other methods may also work.
Conclusion
I think this could be a nice addition to the syntax. You might also have already thought about this. Please let me know what you think.