Skip to content

Commit

Permalink
Merge pull request #1 from mlocati/patch-zf-zend-code
Browse files Browse the repository at this point in the history
Patch Zend Code for PHP 7.3 compatibility
  • Loading branch information
mlocati authored Dec 3, 2018
2 parents 983576b + d7ce763 commit cbf4350
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
},
"tedivm/jshrink:1.1.0": {
"Fix continue switch in FileGenerator and MethodReflection": "tedivm/jshrink/fix-minifier-loop.patch"
},
"zendframework/zend-code:2.6.3": {
"Fix continue switch in FileGenerator and MethodReflection": "zendframework/zend-code/switch-continue.patch"
}
}
}
Expand Down
86 changes: 86 additions & 0 deletions zendframework/zend-code/switch-continue.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
From 473be1000f25aadcf09b815d7210707121e79681 Mon Sep 17 00:00:00 2001
From: Michele Locati <michele@locati.it>
Date: Thu, 29 Nov 2018 14:11:36 +0100
Subject: [PATCH] Use break instead of continue in switch statements

---
src/Generator/FileGenerator.php | 6 +++---
src/Reflection/MethodReflection.php | 14 +++++++-------
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php
index f9dfba23..8eb8326b 100644
--- a/src/Generator/FileGenerator.php
+++ b/src/Generator/FileGenerator.php
@@ -132,13 +132,13 @@ class FileGenerator extends AbstractGenerator
switch (strtolower(str_replace(['.', '-', '_'], '', $name))) {
case 'filename':
$fileGenerator->setFilename($value);
- continue;
+ break;
case 'class':
$fileGenerator->setClass(($value instanceof ClassGenerator) ? $value : ClassGenerator::fromArray($value));
- continue;
+ break;
case 'requiredfiles':
$fileGenerator->setRequiredFiles($value);
- continue;
+ break;
default:
if (property_exists($fileGenerator, $name)) {
$fileGenerator->{$name} = $value;
diff --git a/src/Reflection/MethodReflection.php b/src/Reflection/MethodReflection.php
index ecd654fc..3f8850b7 100644
--- a/src/Reflection/MethodReflection.php
+++ b/src/Reflection/MethodReflection.php
@@ -269,22 +269,22 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac
//closure test
if ($firstBrace && $tokenType == "T_FUNCTION") {
$body .= $tokenValue;
- continue;
+ break;
}
$capture = false;
- continue;
+ break;
}
break;

case "{":
if ($capture === false) {
- continue;
+ break;
}

if ($firstBrace === false) {
$firstBrace = true;
if ($bodyOnly === true) {
- continue;
+ break;
}
}

@@ -293,7 +293,7 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac

case "}":
if ($capture === false) {
- continue;
+ break;
}

//check to see if this is the last brace
@@ -311,12 +311,12 @@ class MethodReflection extends PhpReflectionMethod implements ReflectionInterfac

default:
if ($capture === false) {
- continue;
+ break;
}

// if returning body only wait for first brace before capturing
if ($bodyOnly === true && $firstBrace !== true) {
- continue;
+ break;
}

$body .= $tokenValue;

0 comments on commit cbf4350

Please sign in to comment.