Skip to content

Instantly share code, notes, and snippets.

@bshaffer
Last active September 1, 2020 23:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bshaffer/904b596beecdfbb0a39cb3cd07728720 to your computer and use it in GitHub Desktop.
Fix for WordPress Plugin error "Fatal error: Cannot declare class ArithmeticError". See below for instructions.
commit c79529943b7aa11ac328b1de6ac10173da35b453
Author: Julien Deniau <julien.deniau@gmail.com>
Date: Wed Sep 5 14:38:59 2018 +0200
add test to prevent lint from failing
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php b/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php
index 6819124..4c981d0 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php
@@ -1,5 +1,7 @@
<?php
-class ArithmeticError extends Error
-{
+if (PHP_VERSION_ID < 70000) {
+ class ArithmeticError extends Error
+ {
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/AssertionError.php b/vendor/symfony/polyfill-php70/Resources/stubs/AssertionError.php
index acb1250..8d58081 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/AssertionError.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/AssertionError.php
@@ -1,5 +1,7 @@
<?php
-class AssertionError extends Error
-{
+if (PHP_VERSION_ID < 70000) {
+ class AssertionError extends Error
+ {
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php b/vendor/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php
index c99278b..d009d06 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php
@@ -1,5 +1,7 @@
<?php
-class DivisionByZeroError extends Error
-{
+if (PHP_VERSION_ID < 70000) {
+ class DivisionByZeroError extends Error
+ {
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/Error.php b/vendor/symfony/polyfill-php70/Resources/stubs/Error.php
index 405847f..702d40b 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/Error.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/Error.php
@@ -1,5 +1,7 @@
<?php
-class Error extends Exception
-{
+if (PHP_VERSION_ID < 70000) {
+ class Error extends Exception
+ {
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/ParseError.php b/vendor/symfony/polyfill-php70/Resources/stubs/ParseError.php
index 2dd447d..b321576 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/ParseError.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/ParseError.php
@@ -1,5 +1,7 @@
<?php
-class ParseError extends Error
-{
+if (PHP_VERSION_ID < 70000) {
+ class ParseError extends Error
+ {
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php b/vendor/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php
index 0cc02c8..3a26fb8 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/SessionUpdateTimestampHandlerInterface.php
@@ -1,23 +1,25 @@
<?php
-interface SessionUpdateTimestampHandlerInterface
-{
- /**
- * Checks if a session identifier already exists or not.
- *
- * @param string $key
- *
- * @return bool
- */
- public function validateId($key);
+if (PHP_VERSION_ID < 70000) {
+ interface SessionUpdateTimestampHandlerInterface
+ {
+ /**
+ * Checks if a session identifier already exists or not.
+ *
+ * @param string $key
+ *
+ * @return bool
+ */
+ public function validateId($key);
- /**
- * Updates the timestamp of a session when its data didn't change.
- *
- * @param string $key
- * @param string $val
- *
- * @return bool
- */
- public function updateTimestamp($key, $val);
+ /**
+ * Updates the timestamp of a session when its data didn't change.
+ *
+ * @param string $key
+ * @param string $val
+ *
+ * @return bool
+ */
+ public function updateTimestamp($key, $val);
+ }
}
diff --git a/vendor/symfony/polyfill-php70/Resources/stubs/TypeError.php b/vendor/symfony/polyfill-php70/Resources/stubs/TypeError.php
index 2bed1b4..027495f 100644
--- a/vendor/symfony/polyfill-php70/Resources/stubs/TypeError.php
+++ b/vendor/symfony/polyfill-php70/Resources/stubs/TypeError.php
@@ -1,5 +1,7 @@
<?php
-class TypeError extends Error
-{
+if (PHP_VERSION_ID < 70000) {
+ class TypeError extends Error
+ {
+ }
}
@bshaffer
Copy link
Author

bshaffer commented Sep 1, 2020

To fix the WordPress Plugin error to SVN with symfony/polyfill-php70 (see symfony/polyfill#276), apply this patch as follows:

# go to your wordpress plugin SVN directory. Here we use "trunk" but this can be applied anywhere
cd /path/to/your/wordpress_plugin/trunk

# curl this patch file. You can also just copy/paste the contents into a file
curl https://gist.github.com/bshaffer/904b596beecdfbb0a39cb3cd07728720/raw > polyfill-php70.diff

# apply the patch
patch -p1 < polyfill-php70.diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment