From 4c22530159fad1726b858748cf3c0360e16dcc78 Mon Sep 17 00:00:00 2001 From: AlexNDRmac Date: Tue, 5 Oct 2021 23:06:26 +0300 Subject: [PATCH 1/7] Add release notes parser, store Phar after build [ci skip] --- .github/workflows/release.yml | 10 ++++++++++ release-notes.md | 13 +++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 release-notes.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8d0857b2..6a8adc41b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,11 +55,21 @@ jobs: - name: Build Zephir PHAR run: .ci/build-phar.sh + - name: Upload Zephir Phar + uses: actions/upload-artifact@v2 + with: + name: zephir.phar + path: zephir.phar + - name: Get the release version id: get-version run: | echo ::set-output name=version::${GITHUB_REF#refs/tags/} + - name: Prepare Release Notes + run: | + ./.ci/release-notes.sh ./CHANGELOG.md > ./release-notes.md + - name: Create Release uses: ncipollo/release-action@v1 with: diff --git a/release-notes.md b/release-notes.md new file mode 100644 index 000000000..86fb4d259 --- /dev/null +++ b/release-notes.md @@ -0,0 +1,13 @@ +### Fixed +- Fixed multiple return types in stubs [#2283](https://github.com/zephir-lang/zephir/issues/2283) +- Fixed `bool` return type in stubs [#2272](https://github.com/zephir-lang/zephir/issues/2272) + +### Changed +- Removed `.zep` from stubs filenames [#2273](https://github.com/zephir-lang/zephir/issues/2273) + +## [0.14.0] - 2021-09-18 +### Added +- Added support for `require_once` [#2253](https://github.com/zephir-lang/zephir/issues/2253) + +### Changed +- Bumped minimal version of Zephir Parser to `1.4.1`. [#2284](https://github.com/zephir-lang/zephir/issues/2284) From 59336dd119095878fd34ad81c484c618c12687d5 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 21:49:53 +0100 Subject: [PATCH 2/7] #2308 - Fix support of `string` type in struct globals --- Library/Code/Builder/Struct.php | 6 ++++++ config.json | 4 ++++ ext/php_stub.h | 1 + ext/stub.c | 2 ++ ext/stub/globals.zep.c | 37 +++++++++++++++++++++++++++++++++ ext/stub/globals.zep.h | 16 ++++++++++++++ stub/globals.zep | 13 ++++++++++++ tests/Extension/GlobalsTest.php | 17 +++++++++++++++ 8 files changed, 96 insertions(+) diff --git a/Library/Code/Builder/Struct.php b/Library/Code/Builder/Struct.php index c59ac0170..86a8558f3 100644 --- a/Library/Code/Builder/Struct.php +++ b/Library/Code/Builder/Struct.php @@ -122,6 +122,9 @@ public function getCDefault(string $name, array $global, string $namespace): str case 'bool': return ''; + case 'string': + return "\t".$namespace.'_globals->'.$this->simpleName.'.'.$name.' = ZSTR_VAL(zend_string_init(ZEND_STRL("'.$global['default'].'"), 0));'; + case 'int': case 'uint': case 'long': @@ -192,6 +195,9 @@ protected function convertToCType(string $type): string case 'hash': return 'HashTable* '; + case 'string': + return 'zend_string* '; + case 'int': case 'uint': case 'long': diff --git a/config.json b/config.json index 95978e34e..1e8bc5e62 100644 --- a/config.json +++ b/config.json @@ -119,6 +119,10 @@ "type": "bool", "default": true }, + "orm.cache_prefix": { + "type": "string", + "default": "prefix-string-" + }, "extension.test_ini_variable": { "type": "bool", "default": true, diff --git a/ext/php_stub.h b/ext/php_stub.h index 33ecd7055..92fc8f89a 100644 --- a/ext/php_stub.h +++ b/ext/php_stub.h @@ -26,6 +26,7 @@ typedef struct _zephir_struct_db { typedef struct _zephir_struct_orm { int cache_level; zend_bool cache_enable; + zend_string* cache_prefix; } zephir_struct_orm; typedef struct _zephir_struct_extension { diff --git a/ext/stub.c b/ext/stub.c index 26e7660a0..fa0ee3d4d 100644 --- a/ext/stub.c +++ b/ext/stub.c @@ -254,6 +254,7 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("stub.orm.cache_enable", "1", PHP_INI_ALL, OnUpdateBool, orm.cache_enable, zend_stub_globals, stub_globals) + STD_PHP_INI_BOOLEAN("extension.test_ini_variable", "1", PHP_INI_ALL, OnUpdateBool, extension.test_ini_variable, zend_stub_globals, stub_globals) STD_PHP_INI_BOOLEAN("ini-entry.my_setting_1", "1", PHP_INI_ALL, OnUpdateBool, my_setting_1, zend_stub_globals, stub_globals) STD_PHP_INI_BOOLEAN("stub.test_setting_1", "1", PHP_INI_ALL, OnUpdateBool, test_setting_1, zend_stub_globals, stub_globals) @@ -520,6 +521,7 @@ static void php_zephir_init_globals(zend_stub_globals *stub_globals) stub_globals->db.my_setting_3 = 7.5; stub_globals->orm.cache_level = 3; + stub_globals->orm.cache_prefix = ZSTR_VAL(zend_string_init(ZEND_STRL("prefix-string-"), 0)); stub_globals->my_setting_1 = 1; stub_globals->test_setting_1 = 1; diff --git a/ext/stub/globals.zep.c b/ext/stub/globals.zep.c index 06647de6a..6f79b795a 100644 --- a/ext/stub/globals.zep.c +++ b/ext/stub/globals.zep.c @@ -149,6 +149,31 @@ PHP_METHOD(Stub_Globals, setDefaultGlobalsOrmCacheLevel) ZEPHIR_GLOBAL(orm).cache_level = zval_get_long(value); } +PHP_METHOD(Stub_Globals, setDefaultGlobalsOrmCachePrefix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *value_param = NULL; + zval value; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&value); +#if PHP_VERSION_ID >= 80000 + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(value) + ZEND_PARSE_PARAMETERS_END(); +#endif + + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &value_param); + zephir_get_strval(&value, value_param); + + + ZEPHIR_GLOBAL(orm).cache_prefix = ZSTR_VAL(zval_get_string(&value)); + ZEPHIR_MM_RESTORE(); +} + /** * @return mixed */ @@ -257,3 +282,15 @@ PHP_METHOD(Stub_Globals, getDefaultGlobalsOrmCacheLevel) RETURN_LONG(ZEPHIR_GLOBAL(orm).cache_level); } +/** + * @return mixed + */ +PHP_METHOD(Stub_Globals, getDefaultGlobalsOrmCachePrefix) +{ + zval *this_ptr = getThis(); + + + + RETURN_STRING(ZEPHIR_GLOBAL(orm).cache_prefix); +} + diff --git a/ext/stub/globals.zep.h b/ext/stub/globals.zep.h index b8198d31c..c27a3126a 100644 --- a/ext/stub/globals.zep.h +++ b/ext/stub/globals.zep.h @@ -9,6 +9,7 @@ PHP_METHOD(Stub_Globals, setCharValue); PHP_METHOD(Stub_Globals, setStringValue); PHP_METHOD(Stub_Globals, setBoolValue); PHP_METHOD(Stub_Globals, setDefaultGlobalsOrmCacheLevel); +PHP_METHOD(Stub_Globals, setDefaultGlobalsOrmCachePrefix); PHP_METHOD(Stub_Globals, getDefaultGlobals1); PHP_METHOD(Stub_Globals, getDefaultGlobals2); PHP_METHOD(Stub_Globals, getDefaultGlobals3); @@ -18,6 +19,7 @@ PHP_METHOD(Stub_Globals, getDefaultGlobals6); PHP_METHOD(Stub_Globals, getDefaultGlobals7); PHP_METHOD(Stub_Globals, getDefaultGlobals8); PHP_METHOD(Stub_Globals, getDefaultGlobalsOrmCacheLevel); +PHP_METHOD(Stub_Globals, getDefaultGlobalsOrmCachePrefix); ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stub_globals_setboolvalueusingdotnotation, 0, 1, IS_VOID, 0) @@ -49,6 +51,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stub_globals_setdefaultglobalsor ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_stub_globals_setdefaultglobalsormcacheprefix, 0, 1, IS_VOID, 0) + + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_stub_globals_getdefaultglobals1, 0, 0, 0) ZEND_END_ARG_INFO() @@ -76,6 +83,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_stub_globals_getdefaultglobalsormcachelevel, 0, 0, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_stub_globals_getdefaultglobalsormcacheprefix, 0, 0, 0) +ZEND_END_ARG_INFO() + ZEPHIR_INIT_FUNCS(stub_globals_method_entry) { PHP_ME(Stub_Globals, setBoolValueUsingDotNotation, arginfo_stub_globals_setboolvalueusingdotnotation, ZEND_ACC_PUBLIC) PHP_ME(Stub_Globals, setIntValueUsingDotNotation, arginfo_stub_globals_setintvalueusingdotnotation, ZEND_ACC_PUBLIC) @@ -83,6 +93,7 @@ ZEPHIR_INIT_FUNCS(stub_globals_method_entry) { PHP_ME(Stub_Globals, setStringValue, arginfo_stub_globals_setstringvalue, ZEND_ACC_PUBLIC) PHP_ME(Stub_Globals, setBoolValue, arginfo_stub_globals_setboolvalue, ZEND_ACC_PUBLIC) PHP_ME(Stub_Globals, setDefaultGlobalsOrmCacheLevel, arginfo_stub_globals_setdefaultglobalsormcachelevel, ZEND_ACC_PUBLIC) + PHP_ME(Stub_Globals, setDefaultGlobalsOrmCachePrefix, arginfo_stub_globals_setdefaultglobalsormcacheprefix, ZEND_ACC_PUBLIC) #if PHP_VERSION_ID >= 80000 PHP_ME(Stub_Globals, getDefaultGlobals1, arginfo_stub_globals_getdefaultglobals1, ZEND_ACC_PUBLIC) #else @@ -127,6 +138,11 @@ ZEPHIR_INIT_FUNCS(stub_globals_method_entry) { PHP_ME(Stub_Globals, getDefaultGlobalsOrmCacheLevel, arginfo_stub_globals_getdefaultglobalsormcachelevel, ZEND_ACC_PUBLIC) #else PHP_ME(Stub_Globals, getDefaultGlobalsOrmCacheLevel, NULL, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 + PHP_ME(Stub_Globals, getDefaultGlobalsOrmCachePrefix, arginfo_stub_globals_getdefaultglobalsormcacheprefix, ZEND_ACC_PUBLIC) +#else + PHP_ME(Stub_Globals, getDefaultGlobalsOrmCachePrefix, NULL, ZEND_ACC_PUBLIC) #endif PHP_FE_END }; diff --git a/stub/globals.zep b/stub/globals.zep index 4b36341eb..23af75d59 100644 --- a/stub/globals.zep +++ b/stub/globals.zep @@ -35,6 +35,11 @@ class Globals globals_set("orm.cache_level", value); } + public function setDefaultGlobalsOrmCachePrefix(string value) -> void + { + globals_set("orm.cache_prefix", value); + } + /* Get Default Properties */ /** @@ -108,4 +113,12 @@ class Globals { return globals_get("orm.cache_level"); } + + /** + * @return mixed + */ + public function getDefaultGlobalsOrmCachePrefix() + { + return globals_get("orm.cache_prefix"); + } } diff --git a/tests/Extension/GlobalsTest.php b/tests/Extension/GlobalsTest.php index 0f7fa6687..0b5612eda 100644 --- a/tests/Extension/GlobalsTest.php +++ b/tests/Extension/GlobalsTest.php @@ -83,6 +83,23 @@ public function testSetStringValue(): void $this->test->setStringValue('Long Text without any sense...'); $this->assertSame('Long Text without any sense...', $this->test->getDefaultGlobals8()); + + /** + * Get and set string value from globals struct. + */ + $this->assertSame('prefix-string-', $this->test->getDefaultGlobalsOrmCachePrefix()); + + $this->test->setDefaultGlobalsOrmCachePrefix('1'); + $this->assertSame('1', $this->test->getDefaultGlobalsOrmCachePrefix()); + + $this->test->setDefaultGlobalsOrmCachePrefix('c'); + $this->assertSame('c', $this->test->getDefaultGlobalsOrmCachePrefix()); + + $this->test->setDefaultGlobalsOrmCachePrefix('char'); + $this->assertSame('char', $this->test->getDefaultGlobalsOrmCachePrefix()); + + $this->test->setDefaultGlobalsOrmCachePrefix('Long Text without any sense...'); + $this->assertSame('Long Text without any sense...', $this->test->getDefaultGlobalsOrmCachePrefix()); } public function testSetBoolValueUsingInt(): void From 0c0fdfa42e7e31d775a94a3969f035d9e501dbfc Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 21:52:08 +0100 Subject: [PATCH 3/7] #2308 - Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a10d3c00..be36ea9ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format based on [Keep a Changelog](http://keepachangelog.com) and this project adheres to [Semantic Versioning](http://semver.org). ## [Unreleased] +### Fixed +- Fix support of `string` type in struct globals [#2308](https://github.com/zephir-lang/zephir/issues/2308) ## [0.15.0] - 2021-10-05 ### Added From 4ce4cda16c5617c84523073fc79a51bb69c68fb5 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 21:53:29 +0100 Subject: [PATCH 4/7] #2308 - Refactor `CompilerFileFactory` class --- Library/Compiler/CompilerFileFactory.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Library/Compiler/CompilerFileFactory.php b/Library/Compiler/CompilerFileFactory.php index e65d41f7c..1b2b1659b 100644 --- a/Library/Compiler/CompilerFileFactory.php +++ b/Library/Compiler/CompilerFileFactory.php @@ -9,6 +9,8 @@ * the LICENSE file that was distributed with this source code. */ +declare(strict_types=1); + namespace Zephir\Compiler; use Psr\Log\LoggerInterface; @@ -19,15 +21,12 @@ final class CompilerFileFactory { - private $config; - private $filesystem; - private $logger; - - public function __construct( - Config $config, - FileSystemInterface $filesystem, - LoggerInterface $logger - ) { + private Config $config; + private FileSystemInterface $filesystem; + private LoggerInterface $logger; + + public function __construct(Config $config, FileSystemInterface $filesystem, LoggerInterface $logger) + { $this->config = $config; $this->filesystem = $filesystem; $this->logger = $logger; @@ -43,7 +42,7 @@ public function __construct( * * @return FileInterface */ - public function create($className, $filePath) + public function create(string $className, string $filePath): FileInterface { $compiler = new CompilerFile($this->config, new AliasManager(), $this->filesystem); From bd35c964e4083a0e1b196720bdab4193950e2c1a Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 22:09:26 +0100 Subject: [PATCH 5/7] Bump version to `0.15.1` --- Library/Zephir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Zephir.php b/Library/Zephir.php index 129f5ab39..5bc19b8a0 100644 --- a/Library/Zephir.php +++ b/Library/Zephir.php @@ -16,7 +16,7 @@ */ final class Zephir { - public const VERSION = '0.15.0-$Id$'; + public const VERSION = '0.15.1-$Id$'; public const LOGO = <<<'ASCII' _____ __ _ From f1c86bea7274c6bd5c6f118b4c3436e3c1a7892c Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 22:10:24 +0100 Subject: [PATCH 6/7] Regenerate `ext/` directory --- ext/php_stub.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/php_stub.h b/ext/php_stub.h index 92fc8f89a..12c03fff5 100644 --- a/ext/php_stub.h +++ b/ext/php_stub.h @@ -14,7 +14,7 @@ #define PHP_STUB_VERSION "1.0.0" #define PHP_STUB_EXTNAME "stub" #define PHP_STUB_AUTHOR "Phalcon Team and contributors" -#define PHP_STUB_ZEPVERSION "0.15.0-$Id$" +#define PHP_STUB_ZEPVERSION "0.15.1-$Id$" #define PHP_STUB_DESCRIPTION "Description test for
Test Extension." typedef struct _zephir_struct_db { From d5bcff3476ef2004ef7aaadc561282c07d068a2d Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 8 Oct 2021 22:12:07 +0100 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be36ea9ba..fef2a5bff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format based on [Keep a Changelog](http://keepachangelog.com) and this project adheres to [Semantic Versioning](http://semver.org). ## [Unreleased] + +## [0.15.1] - 2021-10-08 ### Fixed - Fix support of `string` type in struct globals [#2308](https://github.com/zephir-lang/zephir/issues/2308) @@ -555,7 +557,8 @@ and this project adheres to [Semantic Versioning](http://semver.org). [#1524](https://github.com/zephir-lang/zephir/issues/1524) -[Unreleased]: https://github.com/zephir-lang/zephir/compare/0.15.0...HEAD +[Unreleased]: https://github.com/zephir-lang/zephir/compare/0.15.1...HEAD +[0.15.1]: https://github.com/zephir-lang/zephir/compare/0.15.0...0.15.1 [0.15.0]: https://github.com/zephir-lang/zephir/compare/0.14.0...0.15.0 [0.14.0]: https://github.com/zephir-lang/zephir/compare/0.14.0-beta.3...0.14.0 [0.14.0-beta.3]: https://github.com/zephir-lang/zephir/compare/0.14.0-beta.2...0.14.0-beta.3