Skip to content

Commit d6922ef

Browse files
villfakrakjoe
authored andcommitted
Fix Bug #74386Phar::__construct(): wrong number of parameters by reflection
1 parent d351c19 commit d6922ef

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-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: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5101,7 +5101,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
51015101
ZEND_ARG_INFO(0, filename)
51025102
ZEND_ARG_INFO(0, flags)
51035103
ZEND_ARG_INFO(0, alias)
5104-
ZEND_ARG_INFO(0, fileformat)
51055104
ZEND_END_ARG_INFO()
51065105

51075106
ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_createDS, 0, 0, 0)
@@ -5311,6 +5310,75 @@ zend_function_entry php_archive_methods[] = {
53115310
PHP_FE_END
53125311
};
53135312

5313+
5314+
ZEND_BEGIN_ARG_INFO_EX(arginfo_data___construct, 0, 0, 1)
5315+
ZEND_ARG_INFO(0, filename)
5316+
ZEND_ARG_INFO(0, flags)
5317+
ZEND_ARG_INFO(0, alias)
5318+
ZEND_ARG_INFO(0, fileformat)
5319+
ZEND_END_ARG_INFO()
5320+
5321+
zend_function_entry php_data_methods[] = {
5322+
PHP_ME(Phar, __construct, arginfo_data___construct, ZEND_ACC_PUBLIC)
5323+
PHP_ME(Phar, __destruct, arginfo_phar__void, ZEND_ACC_PUBLIC)
5324+
PHP_ME(Phar, addEmptyDir, arginfo_phar_emptydir, ZEND_ACC_PUBLIC)
5325+
PHP_ME(Phar, addFile, arginfo_phar_addfile, ZEND_ACC_PUBLIC)
5326+
PHP_ME(Phar, addFromString, arginfo_phar_fromstring, ZEND_ACC_PUBLIC)
5327+
PHP_ME(Phar, buildFromDirectory, arginfo_phar_fromdir, ZEND_ACC_PUBLIC)
5328+
PHP_ME(Phar, buildFromIterator, arginfo_phar_build, ZEND_ACC_PUBLIC)
5329+
PHP_ME(Phar, compressFiles, arginfo_phar_comp, ZEND_ACC_PUBLIC)
5330+
PHP_ME(Phar, decompressFiles, arginfo_phar__void, ZEND_ACC_PUBLIC)
5331+
PHP_ME(Phar, compress, arginfo_phar_comps, ZEND_ACC_PUBLIC)
5332+
PHP_ME(Phar, decompress, arginfo_phar_decomp, ZEND_ACC_PUBLIC)
5333+
PHP_ME(Phar, convertToExecutable, arginfo_phar_conv, ZEND_ACC_PUBLIC)
5334+
PHP_ME(Phar, convertToData, arginfo_phar_conv, ZEND_ACC_PUBLIC)
5335+
PHP_ME(Phar, copy, arginfo_phar_copy, ZEND_ACC_PUBLIC)
5336+
PHP_ME(Phar, count, arginfo_phar__void, ZEND_ACC_PUBLIC)
5337+
PHP_ME(Phar, delete, arginfo_phar_delete, ZEND_ACC_PUBLIC)
5338+
PHP_ME(Phar, delMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5339+
PHP_ME(Phar, extractTo, arginfo_phar_extract, ZEND_ACC_PUBLIC)
5340+
PHP_ME(Phar, getAlias, arginfo_phar__void, ZEND_ACC_PUBLIC)
5341+
PHP_ME(Phar, getPath, arginfo_phar__void, ZEND_ACC_PUBLIC)
5342+
PHP_ME(Phar, getMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5343+
PHP_ME(Phar, getModified, arginfo_phar__void, ZEND_ACC_PUBLIC)
5344+
PHP_ME(Phar, getSignature, arginfo_phar__void, ZEND_ACC_PUBLIC)
5345+
PHP_ME(Phar, getStub, arginfo_phar__void, ZEND_ACC_PUBLIC)
5346+
PHP_ME(Phar, getVersion, arginfo_phar__void, ZEND_ACC_PUBLIC)
5347+
PHP_ME(Phar, hasMetadata, arginfo_phar__void, ZEND_ACC_PUBLIC)
5348+
PHP_ME(Phar, isBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5349+
PHP_ME(Phar, isCompressed, arginfo_phar__void, ZEND_ACC_PUBLIC)
5350+
PHP_ME(Phar, isFileFormat, arginfo_phar_isff, ZEND_ACC_PUBLIC)
5351+
PHP_ME(Phar, isWritable, arginfo_phar__void, ZEND_ACC_PUBLIC)
5352+
PHP_ME(Phar, offsetExists, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5353+
PHP_ME(Phar, offsetGet, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5354+
PHP_ME(Phar, offsetSet, arginfo_phar_offsetSet, ZEND_ACC_PUBLIC)
5355+
PHP_ME(Phar, offsetUnset, arginfo_phar_offsetExists, ZEND_ACC_PUBLIC)
5356+
PHP_ME(Phar, setAlias, arginfo_phar_setAlias, ZEND_ACC_PUBLIC)
5357+
PHP_ME(Phar, setDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC)
5358+
PHP_ME(Phar, setMetadata, arginfo_phar_setMetadata, ZEND_ACC_PUBLIC)
5359+
PHP_ME(Phar, setSignatureAlgorithm, arginfo_phar_setSigAlgo, ZEND_ACC_PUBLIC)
5360+
PHP_ME(Phar, setStub, arginfo_phar_setStub, ZEND_ACC_PUBLIC)
5361+
PHP_ME(Phar, startBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5362+
PHP_ME(Phar, stopBuffering, arginfo_phar__void, ZEND_ACC_PUBLIC)
5363+
/* static member functions */
5364+
PHP_ME(Phar, apiVersion, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5365+
PHP_ME(Phar, canCompress, arginfo_phar_cancompress, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5366+
PHP_ME(Phar, canWrite, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5367+
PHP_ME(Phar, createDefaultStub, arginfo_phar_createDS, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5368+
PHP_ME(Phar, getSupportedCompression,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5369+
PHP_ME(Phar, getSupportedSignatures,arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5370+
PHP_ME(Phar, interceptFileFuncs, arginfo_phar__void, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5371+
PHP_ME(Phar, isValidPharFilename, arginfo_phar_isvalidpharfilename, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5372+
PHP_ME(Phar, loadPhar, arginfo_phar_loadPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5373+
PHP_ME(Phar, mapPhar, arginfo_phar_mapPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5374+
PHP_ME(Phar, running, arginfo_phar_running, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5375+
PHP_ME(Phar, mount, arginfo_phar_mount, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5376+
PHP_ME(Phar, mungServer, arginfo_phar_mungServer, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5377+
PHP_ME(Phar, unlinkArchive, arginfo_phar_ua, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5378+
PHP_ME(Phar, webPhar, arginfo_phar_webPhar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
5379+
PHP_FE_END
5380+
};
5381+
53145382
ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
53155383
ZEND_ARG_INFO(0, filename)
53165384
ZEND_END_ARG_INFO()
@@ -5358,7 +5426,7 @@ void phar_object_init(void) /* {{{ */
53585426

53595427
zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
53605428

5361-
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
5429+
INIT_CLASS_ENTRY(ce, "PharData", php_data_methods);
53625430
phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
53635431

53645432
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)