Skip to content

Commit 2dee44c

Browse files
villfakrakjoe
authored andcommitted
Fix Bug #74386 Phar::__construct(): wrong number of parameters by reflection
1 parent 8dcfec9 commit 2dee44c

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ PHP NEWS
1818
- FTP:
1919
. Fixed bug #74598 (ftp:// wrapper ignores context arg). (Sara)
2020

21+
- PHAR:
22+
. Fixed bug #74386 (Phar::__construct reflection incorrect). (villfa)
23+
2124
- Streams:
2225
. Fixed bug #74556 (stream_socket_get_name() returns '\0'). (Sara)
2326

ext/phar/phar_object.c

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5149,7 +5149,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
51495149
ZEND_ARG_INFO(0, filename)
51505150
ZEND_ARG_INFO(0, flags)
51515151
ZEND_ARG_INFO(0, alias)
5152-
ZEND_ARG_INFO(0, fileformat)
51535152
ZEND_END_ARG_INFO()
51545153

51555154
PHAR_ARG_INFO
@@ -5397,6 +5396,79 @@ zend_function_entry php_archive_methods[] = {
53975396
PHP_FE_END
53985397
};
53995398

5399+
PHAR_ARG_INFO
5400+
ZEND_BEGIN_ARG_INFO_EX(arginfo_data___construct, 0, 0, 1)
5401+
ZEND_ARG_INFO(0, filename)
5402+
ZEND_ARG_INFO(0, flags)
5403+
ZEND_ARG_INFO(0, alias)
5404+
ZEND_ARG_INFO(0, fileformat)
5405+
ZEND_END_ARG_INFO()
5406+
5407+
zend_function_entry php_data_methods[] = {
5408+
#if !HAVE_SPL
5409+
PHP_ME(Phar, __construct, arginfo_data___construct, ZEND_ACC_PRIVATE)
5410+
#else
5411+
PHP_ME(Phar, __construct, arginfo_data___construct, ZEND_ACC_PUBLIC)
5412+
PHP_ME(Phar, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC)
5413+
PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir, ZEND_ACC_PUBLIC)
5414+
PHP_ME(Phar, addFile, arginfo_phar_addfile, ZEND_ACC_PUBLIC)
5415+
PHP_ME(Phar, addFromString, arginfo_phar_fromstring, ZEND_ACC_PUBLIC)
5416+
PHP_ME(Phar, buildFromDirectory, arginfo_phar_fromdir, ZEND_ACC_PUBLIC)
5417+
PHP_ME(Phar, buildFromIterator, arginfo_phar_build, ZEND_ACC_PUBLIC)
5418+
PHP_ME(Phar, compressFiles, arginfo_phar_comp, ZEND_ACC_PUBLIC)
5419+
PHP_ME(Phar, decompressFiles, arginfo_phar__void, ZEND_ACC_PUBLIC)
5420+
PHP_ME(Phar, compress, arginfo_phar_comps, ZEND_ACC_PUBLIC)
5421+
PHP_ME(Phar, decompress, arginfo_phar_decomp, ZEND_ACC_PUBLIC)
5422+
PHP_ME(Phar, convertToExecutable, arginfo_phar_conv, ZEND_ACC_PUBLIC)
5423+
PHP_ME(Phar, convertToData, arginfo_phar_conv, ZEND_ACC_PUBLIC)
5424+
PHP_ME(Phar, copy, arginfo_phar_copy, ZEND_ACC_PUBLIC)
5425+
PHP_ME(Phar, count, arginfo_phar__void, ZEND_ACC_PUBLIC)
5426+
PHP_ME(Phar, delete, arginfo_phar_delete, ZEND_ACC_PUBLIC)
5427+
PHP_ME(Phar, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5428+
PHP_ME(Phar, extractTo, arginfo_phar_extract, ZEND_ACC_PUBLIC)
5429+
PHP_ME(Phar, getAlias, arginfo_phar__void, ZEND_ACC_PUBLIC)
5430+
PHP_ME(Phar, getPath, arginfo_phar__void, ZEND_ACC_PUBLIC)
5431+
PHP_ME(Phar, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5432+
PHP_ME(Phar, getModified, arginfo_phar__void, ZEND_ACC_PUBLIC)
5433+
PHP_ME(Phar, getSignature, arginfo_phar__void, ZEND_ACC_PUBLIC)
5434+
PHP_ME(Phar, getStub, arginfo_phar__void, ZEND_ACC_PUBLIC)
5435+
PHP_ME(Phar, getVersion, arginfo_phar__void, ZEND_ACC_PUBLIC)
5436+
PHP_ME(Phar, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5437+
PHP_ME(Phar, isBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5438+
PHP_ME(Phar, isCompressed, arginfo_phar__void, ZEND_ACC_PUBLIC)
5439+
PHP_ME(Phar, isFileFormat, arginfo_phar_isff, ZEND_ACC_PUBLIC)
5440+
PHP_ME(Phar, isWritable, arginfo_phar__void, ZEND_ACC_PUBLIC)
5441+
PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5442+
PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5443+
PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC)
5444+
PHP_ME(Phar, offsetUnset, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5445+
PHP_ME(Phar, setAlias, arginfo_phar_setAlias, ZEND_ACC_PUBLIC)
5446+
PHP_ME(Phar, setDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC)
5447+
PHP_ME(Phar, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC)
5448+
PHP_ME(Phar, setSignatureAlgorithm, arginfo_phar_setSigAlgo, ZEND_ACC_PUBLIC)
5449+
PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC)
5450+
PHP_ME(Phar, startBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5451+
PHP_ME(Phar, stopBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5452+
#endif
5453+
/* static member functions */
5454+
PHP_ME(Phar, apiVersion, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5455+
PHP_ME(Phar, canCompress, arginfo_phar_cancompress, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5456+
PHP_ME(Phar, canWrite, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5457+
PHP_ME(Phar, createDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5458+
PHP_ME(Phar, getSupportedCompression,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5459+
PHP_ME(Phar, getSupportedSignatures,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5460+
PHP_ME(Phar, interceptFileFuncs, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5461+
PHP_ME(Phar, isValidPharFilename, arginfo_phar_isvalidpharfilename, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5462+
PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5463+
PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5464+
PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5465+
PHP_ME(Phar, mount, arginfo_phar_mount, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5466+
PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5467+
PHP_ME(Phar, unlinkArchive, arginfo_phar_ua, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5468+
PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5469+
PHP_FE_END
5470+
};
5471+
54005472
#if HAVE_SPL
54015473
PHAR_ARG_INFO
54025474
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
@@ -5449,7 +5521,7 @@ void phar_object_init(void) /* {{{ */
54495521

54505522
zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
54515523

5452-
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
5524+
INIT_CLASS_ENTRY(ce, "PharData", php_data_methods);
54535525
phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
54545526

54555527
zend_class_implements(phar_ce_data, 2, spl_ce_Countable, zend_ce_arrayaccess);

ext/phar/tests/bug74386.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Phar: bug #74386: Phar::__construct(): wrong number of parameters by reflection
3+
--SKIPIF--
4+
<?php if (!extension_loaded("phar") || !extension_loaded('reflection')) die("skip"); ?>
5+
--FILE--
6+
<?php
7+
$r = new ReflectionMethod(Phar::class, '__construct');
8+
var_dump($r->getNumberOfRequiredParameters());
9+
var_dump($r->getNumberOfParameters());
10+
11+
$r = new ReflectionMethod(PharData::class, '__construct');
12+
var_dump($r->getNumberOfRequiredParameters());
13+
var_dump($r->getNumberOfParameters());
14+
?>
15+
===DONE===
16+
--EXPECT--
17+
int(1)
18+
int(3)
19+
int(1)
20+
int(4)
21+
===DONE===

0 commit comments

Comments
 (0)