0
votes

I have a report-generating class that extends a pdf class. The report-generating class is written in 5.0 style, where each method has a permission ( public, private, etc or whatever you call it). The base class was written in 4.0 style and doesn't have public, private, etc declaration for methods or variables.

I've recently turned on strict standards on our development machine, and now I'm getting errors that Strict standards: Declaration of reportPdf::stream() should be compatible with that of Cpdf::stream()

But no matter what declaration I give to stream(), public, private, protected, or no permission at all, I still get this error.

Can I fix this? Or must I turn off strict standards while I'm working on this.

Migrating to a newer class is not an option at this point because it's too much work to for the functionality payoff. It works fine when strict standards are turned off.


Edit: I did some testing, and here's the matrix of results. No matter what, Strict Standards still complains.

protected function stream() { ...

Fatal error: Access level to reportPdf::stream() must be public (as in class Cpdf) in

public function stream() { ...

Strict standards: Declaration of reportPdf::stream() should be compatible with that of Cpdf::stream()

private function stream() { ...

Fatal error: Access level to reportPdf::stream() must be public (as in class Cpdf)

function stream() { ...

Strict standards: Declaration of reportPdf::stream() should be compatible with that of Cpdf::stream()

Also note that stream has 0 arguments, just like its parent class :(

1

1 Answers

0
votes

There is no point in code cleanliness if that makes the application fail. (= turn E_STRICT off)

That being said, I think the discrepancy lies most certainly in the parameters, not in the access modifiers. PHP would give another error else.

The stream() method might have more or fewer arguments in your derived reportPdf class, than in the pdf writer. If so, you can trick PHP by reversing the order in which in the classes are defined. See http://bugs.php.net/bug.php?id=46851