How to add in php declare(strict_types)?


is there way how to generate to each php files generated by haxe
on top of file afte <?php , please?

Or in general, is there way how to edit files after its compilations?

Thank you

Hello, you can do this by running the haxe code after compilation.

# build.hxml
--dce full

--main Main
--class-path src/

--php bin/php

--cmd haxe --main PostBuild --class-path src/ --interp
// src/PostBuild.hx
using StringTools;

import sys.FileSystem;

class PostBuild {
	static function main() {
		final buildPath = "./bin/php";
		final queue:Array<String> = [buildPath];

		while (queue.length != 0) {
			final currentPath = queue.shift();

			if (FileSystem.isDirectory(currentPath)) {
				for (file in FileSystem.readDirectory(currentPath)) {
					queue.push(Path.join([currentPath, file]));
			} else if (currentPath.endsWith(".php")) {
				var content = File.getContent(currentPath);

				content = content.replace(

				File.saveContent(currentPath, content);
1 Like

Interesting, thank you :slight_smile:

1 Like