php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59369 Strict Standards on Override Method
Submitted: 2010-08-16 19:04 UTC Modified: 2010-08-17 05:33 UTC
From: gizmore at wechall dot net Assigned:
Status: Not a bug Package: zip (PECL)
PHP Version: 5_3 SVN-2010-08-16 (dev) OS: Gentoo/GNU/Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gizmore at wechall dot net
New email:
PHP Version: OS:

 

 [2010-08-16 19:04 UTC] gizmore at wechall dot net
Description:
------------
I can not override method ZipArchive::addFile() when deriving class ZipArchive.


Reproduce code:
---------------
<?php
// ERROR: Strict standards: Declaration of MyZipArchive2::addFile() should be compatible with that of ZipArchive::addFile()
final class MyZipArchive2 extends ZipArchive
{
	public function addFile($filename, $localname)
	{
		// Declaration is always wrong, according to strict standards.
	}
}
?>


Expected result:
----------------
compile fine

Actual result:
--------------
ERROR: Strict standards: Declaration of MyZipArchive2::addFile() should be compatible with that of ZipArchive::addFile()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-16 20:31 UTC] pierre dot php at gmail dot com
addFile can take four arguments, two optional.

bool ZipArchive::addFile(string filepath[, string entryname[, int start [, int length]]])

Try it again pleas/e
 [2010-08-16 20:45 UTC] gizmore at wechall dot net
Thank you, the correct prototype is:

public function addFile($filename, $localname=NULL, start=0, $end=0)

So 4 parameters (3 optional) and there are only 2 in total on php.net docs:

http://de2.php.net/manual/en/function.ziparchive-addfile.php
 [2010-08-16 20:51 UTC] gizmore at wechall dot net
Oh, and thank you very very much, maybe close this bug as solved when you updated the documentation.

I am new to pecl bugreports. and my first comment got deleted due clicking :)

BTW: in php 5.2 this was no a strict standards error.

Anyway, thank you for your quick response, this got me bugged a long time.
 [2010-08-17 05:33 UTC] pierre dot php at gmail dot com
Not a bug, was a doc issue.

The strict warning about method signature is new to 5.3.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 08:01:29 2025 UTC