Skip to content

Commit 977190b

Browse files
committed
Improve string class constant code generation
1 parent 5a86802 commit 977190b

File tree

8 files changed

+71
-158
lines changed

8 files changed

+71
-158
lines changed

build/gen_stub.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,20 @@ private function getClassConstDeclaration(EvaluatedValue $value, iterable $allCo
20002000
{
20012001
$constName = $this->getVariableLikeName();
20022002

2003+
if ($value->type->isString()) {
2004+
$cConstValue = $value->getCConstValue($allConstInfos);
2005+
$constValue = $cConstValue ?: '"' . addslashes($value->value) . '"';
2006+
2007+
$template = "\tzend_declare_class_constant_string(class_entry, $constName, $constValue, %s, NULL);\n";
2008+
$flagsCode = generateVersionDependentFlagCode(
2009+
$template,
2010+
$this->getFlagsByPhpVersion(),
2011+
$this->phpVersionIdMinimumCompatibility
2012+
);
2013+
2014+
return "\n" . implode("", $flagsCode);
2015+
}
2016+
20032017
$zvalCode = $value->initializeZval("const_{$constName}_value", $allConstInfos);
20042018

20052019
$code = "\n" . $zvalCode;

ext/date/php_date_arginfo.h

Lines changed: 27 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/locale/locale_arginfo.h

Lines changed: 13 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/intl/uchar/uchar_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pdo/pdo_dbh_arginfo.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/zip/php_zip.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ extern zend_module_entry zip_module_entry;
3333

3434
#define PHP_ZIP_VERSION "1.21.1"
3535

36+
#ifdef HAVE_LIBZIP_VERSION
37+
#define LIBZIP_VERSION_STR zip_libzip_version()
38+
#else
39+
#define LIBZIP_VERSION_STR LIBZIP_VERSION
40+
#endif
41+
3642
#define ZIP_OPENBASEDIR_CHECKPATH(filename) php_check_open_basedir(filename)
3743

3844
typedef struct _ze_zip_rsrc {

ext/zip/php_zip.stub.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ class ZipArchive implements Countable
633633
*/
634634
public const EM_UNKNOWN = UNKNOWN;
635635

636+
/**
637+
* @var string
638+
* @cvalue LIBZIP_VERSION_STR
639+
*/
640+
public const LIBZIP_VERSION = UNKNOWN;
641+
636642
/** @readonly */
637643
public int $lastId;
638644
/** @readonly */

ext/zip/php_zip_arginfo.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)