Fatal error: Using $this when not in object context in \lib\Preprocessor.php(40) : eval()'d code on line 1 #1
Ok, I cannot get this to work. I'm trying to override a static class as described in the documenation:
But I only get:
I'm on php 5.3.1
The text was updated successfully, but these errors were encountered:
I'm afraid I won't be able to identify the problem without more context. For example, if it's a static class you're trying to override, then why does it have a __toString() method? Also, at what point exactly does the error occur? Is it thrown during redefinition, or only when the redefined method is called?
It would be ideal to see the source of the static class in question, but if that's impossible, answering the above questions should also shed some light on this issue.
I'm not trying to override a tostring method. Actually I try to override a method of joomla's JFactory class.
Here is a small part of the class:
Normally you call the method with JFactory::getMailer(). So I tried to override it with:
I'll have to trace when the error occurs, but I think that it is at redefinition time.
And as for the question, Patchwork was designed with development/testing environments in mind. Consequently, issues like performance and possible security concerns weren't taken that seriously. This doesn't necessarily mean that it will make your site unbearably slow and vulnerable, but there are absolutely no guarantees about that. The performance hit may vary wildly from site to site, so it's recommended that you measure it yourself. As for security, no actual concerns come to my mind, but given the terribly hackish preprocessing mechanism in Patchwork, you may never know.
So, while you can definitely use Patchwork wherever you want, I wouldn't really recommend using it in production.
As of PHP 8.1, passing `null` to not explicitly nullable scalar parameters for PHP native functions is deprecated. In this case, `$class` within `applyWildcard()` may be null, which leads to the following deprecation notice as can be seen when running the tests on PHP 8.1: ``` Deprecated: class_exists(): Passing null to parameter antecedent#1 ($class) of type string is deprecated in path/to/patchwork/src/CallRerouting.php on line 141 ``` By handling `null` separately in the condition, the previous behaviour is maintained. Refs: * https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg * https://www.php.net/manual/en/function.class-exists.php
As of PHP 8.1, passing `null` to not explicitly nullable scalar parameters for PHP native functions is deprecated. In this case, `$class` within `interpretCallable()` may be null, which leads to the following deprecation notice as can be seen when running the tests on PHP 8.1: ``` Deprecated: ltrim(): Passing null to parameter antecedent#1 ($string) of type string is deprecated in path/to/patchwork/src/Utils.php on line 123 ``` By handling `null` separately and setting `$class` to an empty string, the previous behaviour is maintained. Refs: * https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg * https://www.php.net/manual/en/function.ltrim.php