diff --git a/.gitignore b/.gitignore
index ae15de42..585bf452 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@
*.lo
*.la
*.profraw
+*.dep
.deps
.libs
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e2354d8..15bb8b46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
-## [Unreleased]
+## [Unreleased] - xxxx-xx-xx
+
+
+## [1.5.0] - 2022-02-12
+### Added
+- Added support for `false` return type [#137](https://github.com/phalcon/php-zephir-parser/issues/137)
## [1.4.2] - 2021-12-11
### Added
@@ -181,7 +186,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Initial stable release
-[Unreleased]: https://github.com/phalcon/php-zephir-parser/compare/v1.4.2...HEAD
+[Unreleased]: https://github.com/phalcon/php-zephir-parser/compare/v1.5.0...HEAD
+[1.5.0]: https://github.com/phalcon/php-zephir-parser/compare/v1.4.2...v1.5.0
[1.4.2]: https://github.com/phalcon/php-zephir-parser/compare/v1.4.1...v1.4.2
[1.4.1]: https://github.com/phalcon/php-zephir-parser/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/phalcon/php-zephir-parser/compare/v1.3.8...v1.4.0
diff --git a/VERSION b/VERSION
index 9df886c4..bc80560f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.4.2
+1.5.0
diff --git a/package.xml b/package.xml
index 68a2cc8c..93ad3c95 100644
--- a/package.xml
+++ b/package.xml
@@ -15,8 +15,8 @@
2021-09-18
- 1.4.2
- 1.4.2
+ 1.5.0
+ 1.5.0
stable
@@ -24,11 +24,11 @@
MIT
- Sat, Dec 1, 2021 - Zephir Parser 1.4.2
+ Sat, Feb 12, 2022 - Zephir Parser 1.5.0
- = Changes:
+ = Added:
- - Enabled support of PHP8.1
+ - Added support of `false` return type
@@ -107,6 +107,8 @@
+
+
diff --git a/parser/parser.h b/parser/parser.h
index 90479487..9c3426c6 100644
--- a/parser/parser.h
+++ b/parser/parser.h
@@ -598,6 +598,10 @@ static void xx_ret_type(zval *ret, int type)
parser_get_string(ret, "this");
return;
+ case XX_T_TYPE_FALSE:
+ parser_get_string(ret, "false");
+ return;
+
default:
fprintf(stderr, "unknown type?\n");
}
diff --git a/parser/scanner.h b/parser/scanner.h
index 8ccb6685..f05d2a3b 100644
--- a/parser/scanner.h
+++ b/parser/scanner.h
@@ -47,6 +47,7 @@
#define XX_T_TYPE_NULL 334
#define XX_T_TYPE_THIS 335
#define XX_T_TYPE_MIXED 336
+#define XX_T_TYPE_FALSE 337
#define XX_T_NAMESPACE 350
#define XX_T_CLASS 351
diff --git a/parser/zephir.lemon b/parser/zephir.lemon
index 4315c280..1d7ecd8d 100644
--- a/parser/zephir.lemon
+++ b/parser/zephir.lemon
@@ -702,6 +702,14 @@ xx_method_return_type_item(R) ::= THIS . {
}
}
+xx_method_return_type_item(R) ::= FALSE . {
+ {
+ zval type;
+ xx_ret_type(&type, XX_T_TYPE_FALSE);
+ xx_ret_return_type_item(&R, &type, NULL, 0, 0, status->scanner_state);
+ }
+}
+
xx_method_return_type_item(R) ::= xx_parameter_type(T) NOT . {
xx_ret_return_type_item(&R, &T, NULL, 1, 0, status->scanner_state);
}
@@ -950,6 +958,10 @@ xx_parameter_type(R) ::= TYPE_MIXED . {
xx_ret_type(&R, XX_TYPE_MIXED);
}
+xx_parameter_type(R) ::= TYPE_FALSE . {
+ xx_ret_type(&R, XX_TYPE_FALSE);
+}
+
xx_parameter_type(R) ::= TYPE_OBJECT . {
xx_ret_type(&R, XX_TYPE_OBJECT);
}
diff --git a/tests/functions/return-types/false.phpt b/tests/functions/return-types/false.phpt
new file mode 100644
index 00000000..9c000195
--- /dev/null
+++ b/tests/functions/return-types/false.phpt
@@ -0,0 +1,175 @@
+--TEST--
+Function definition with `false` return type
+--SKIPIF--
+
+--FILE--
+ false { return false; }
+
+function unionReturn() -> int | false { return 1; }
+ZEP;
+
+$ir = zephir_parse_file($code, '(eval code)');
+var_dump($ir);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ array(7) {
+ ["type"]=>
+ string(8) "function"
+ ["name"]=>
+ string(12) "singleReturn"
+ ["statements"]=>
+ array(1) {
+ [0]=>
+ array(5) {
+ ["type"]=>
+ string(6) "return"
+ ["expr"]=>
+ array(5) {
+ ["type"]=>
+ string(4) "bool"
+ ["value"]=>
+ string(5) "false"
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(49)
+ }
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(51)
+ }
+ }
+ ["return-type"]=>
+ array(6) {
+ ["type"]=>
+ string(11) "return-type"
+ ["list"]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["type"]=>
+ string(21) "return-type-parameter"
+ ["data-type"]=>
+ string(5) "false"
+ ["mandatory"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(35)
+ }
+ }
+ ["void"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(35)
+ }
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(8)
+ }
+ [1]=>
+ array(7) {
+ ["type"]=>
+ string(8) "function"
+ ["name"]=>
+ string(11) "unionReturn"
+ ["statements"]=>
+ array(1) {
+ [0]=>
+ array(5) {
+ ["type"]=>
+ string(6) "return"
+ ["expr"]=>
+ array(5) {
+ ["type"]=>
+ string(3) "int"
+ ["value"]=>
+ string(1) "1"
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(49)
+ }
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(51)
+ }
+ }
+ ["return-type"]=>
+ array(6) {
+ ["type"]=>
+ string(11) "return-type"
+ ["list"]=>
+ array(2) {
+ [0]=>
+ array(6) {
+ ["type"]=>
+ string(21) "return-type-parameter"
+ ["data-type"]=>
+ string(3) "int"
+ ["mandatory"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(31)
+ }
+ [1]=>
+ array(6) {
+ ["type"]=>
+ string(21) "return-type-parameter"
+ ["data-type"]=>
+ string(5) "false"
+ ["mandatory"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(39)
+ }
+ }
+ ["void"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(39)
+ }
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(3)
+ ["char"]=>
+ int(8)
+ }
+}
diff --git a/tests/functions/return-types/float.phpt b/tests/functions/return-types/float.phpt
new file mode 100644
index 00000000..f7ad09f3
--- /dev/null
+++ b/tests/functions/return-types/float.phpt
@@ -0,0 +1,60 @@
+--TEST--
+Function definition with `float` return type
+--SKIPIF--
+
+--FILE--
+ float { }
+ZEP;
+
+$ir = zephir_parse_file($code, '(eval code)');
+var_dump($ir);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ array(6) {
+ ["type"]=>
+ string(8) "function"
+ ["name"]=>
+ string(4) "test"
+ ["return-type"]=>
+ array(6) {
+ ["type"]=>
+ string(11) "return-type"
+ ["list"]=>
+ array(1) {
+ [0]=>
+ array(6) {
+ ["type"]=>
+ string(21) "return-type-parameter"
+ ["data-type"]=>
+ string(6) "double"
+ ["mandatory"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(27)
+ }
+ }
+ ["void"]=>
+ int(0)
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(27)
+ }
+ ["file"]=>
+ string(11) "(eval code)"
+ ["line"]=>
+ int(1)
+ ["char"]=>
+ int(9)
+ }
+}
diff --git a/tests/functions/return-types/int.phpt b/tests/functions/return-types/int.phpt
index 38a6c8a9..85823992 100644
--- a/tests/functions/return-types/int.phpt
+++ b/tests/functions/return-types/int.phpt
@@ -1,5 +1,5 @@
--TEST--
-Function definition with mandatory return type
+Function definition with `int` return type
--SKIPIF--
--FILE--
diff --git a/tests/functions/return-types/mixed.phpt b/tests/functions/return-types/mixed.phpt
index d85bad8d..a7f19dce 100644
--- a/tests/functions/return-types/mixed.phpt
+++ b/tests/functions/return-types/mixed.phpt
@@ -1,5 +1,5 @@
--TEST--
-Function definition with void
+Function definition with `mixed` return type
--SKIPIF--
--FILE--
diff --git a/zephir_parser.h b/zephir_parser.h
index 675b51dc..cc8c328a 100644
--- a/zephir_parser.h
+++ b/zephir_parser.h
@@ -15,7 +15,7 @@ extern zend_module_entry zephir_parser_module_entry;
#define phpext_zephir_parser_ptr &zephir_parser_module_entry
#define PHP_ZEPHIR_PARSER_NAME "zephir_parser"
-#define PHP_ZEPHIR_PARSER_VERSION "1.4.2"
+#define PHP_ZEPHIR_PARSER_VERSION "1.5.0"
#define PHP_ZEPHIR_PARSER_AUTHOR "Zephir Team and contributors"
#define PHP_ZEPHIR_PARSER_DESCRIPTION "The Zephir Parser delivered as a C extension for the PHP language."