HaxeFoundation / HaxeFoundation/haxe
[php] return type declarations
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
If I have this extern for a CakePHP class
package cake.orm;
import php.NativeArray;
@:native("Cake\\ORM\\Table")
extern class Table {
function initialize(config:NativeArray):Void;
}
And this subclass
package app.model.table;
import cake.orm.Table;
class CookiesTable extends Table
{
override function initialize(config):Void
{
}
}
Then this php is emitted
namespace app\model\table;
.....
/**
* @param array $config
*
* @return void
*/
public function initialize ($config) {
But initialize() has a return type declaration from CakePHP 4 onward so this doesn't work too well:
class Table {
public function initialize(array $config): void
It would be nice if extern methods could be annotated as having a return type so the compiler would emit overrides with the correct type.
Contributor guide
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 from the extern method declaration and the emitted PHP override shown in the issue, then trace how the PHP backend emits method signatures. Done means an extern annotation can carry a return type and generated PHP overrides match the CakePHP declaration, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100