bobbingwide / oik-shortcodes

Shortcode, block and API server
https://www.oik-plugins.com/oik-plugins/oik-shortcode-server/
GNU General Public License v2.0
1 stars 0 forks source link

Fatal error: Cannot use "static" when no class scope is active #62

Closed bobbingwide closed 1 year ago

bobbingwide commented 5 years ago

When parsing Yoast SEO v9.4 the routine failed with the following messages.

File:600,834,src/exceptions/missing-method.php,src/exceptions/missing-method.php,578
Parsing file: missing-method
Processing: src/exceptions/missing-method.php
Processing file: wordpress-seo,src/exceptions/missing-method.php
Processing: src/exceptions/missing-method.php, wordpress-seo, plugin
<p>Creating file: src/exceptions/missing-method.php</p>
Processing file: wordpress-seo,src/exceptions/missing-method.php ended
Processing valid: wordpress-seo src/exceptions/missing-method.php plugin
Processing API: Missing_Method::, src/exceptions/missing-method.php, wordpress-seo, plugin
API: Missing_Method::

Processing classref: Missing_Method::,src/exceptions/missing-method.php
Processing API: Missing_Method::for_class, src/exceptions/missing-method.php, wordpress-seo, plugin
API: Missing_Method::for_class

Processing: for_class,Missing_Method::for_class,src/exceptions/missing-method.php

Fatal error: Cannot use "static" when no class scope is active in /tmp/oikscloaTvWBKQ on line 3

This is the same sort of problem as #8.

The temporary file contained

<?php //for_class
function oiksc_dummy_function_90( $method, $class_name ) {
        return new static(
            sprintf(
                /* translators: %1$s expands to the method name. %2$s expands to the class name */
                __( 'Method %1$s() does not exist in class %2$s', 'wordpress-seo' ),
                $method,
                $class_name
            )
        );
    }

Workaround

Fiddle the code temporarily. Change the source file, replacing static with ttatic. Note: There may be other cases where return new self() is used.

Proposed solution

tbc

bobbingwide commented 5 years ago

This fix may also work for problems noted when parsing WooCommerce 3.5.2

Processing classref: ActionScheduler_InvalidActionException::,includes/libraries/action-scheduler/classes/ActionScheduler_InvalidActionException.php
Processing API: ActionScheduler_InvalidActionException::from_decoding_args, includes/libraries/action-scheduler/classes/ActionScheduler_InvalidActionException.php, woocommerce, plugin
API: ActionScheduler_InvalidActionException::from_decoding_args

Processing: from_decoding_args,ActionScheduler_InvalidActionException::from_decoding_args,includes/libraries/action-scheduler/classes/ActionScheduler_InvalidActionException.php

Fatal error: Cannot use "static" when no class scope is active in /tmp/oikscloaugdqXA on line 8
bobbingwide commented 2 years ago

Problem occurred with EDD, processing Carbon::instance,includes/libraries/Carbon.php Temporary file was:

<?php //instance
function oiksc_dummy_function_10(DateTime $dt)
        {
                if ($dt instanceof static) {
                        return clone $dt;
                }

                return new Ttatic($dt->format('Y-m-d H:i:s.u'), $dt->getTimezone());
        }

Changing the static to Ttatic once again resolved the problem.

bobbingwide commented 1 year ago

Released in v1.41.2