GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fixed : bug with methods returning void · sitphp/doubles@40bb4f2

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • Double.php
  • tests
    • DoubleTest.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Double.php‎

Copy file name to clipboardExpand all lines: src/Double.php
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ protected static function resolveDoubleCode($double_definition)
781781
$methods_code = [];
782782
foreach ($double_definition['methods'] as $method) {
783783
$reference_params = [];
784+
$method_return_type = null;
784785

785786
// Check method was not already implemented
786787
$method_name = $method instanceof \ReflectionMethod ? $method->getShortName() : $method;
@@ -887,12 +888,19 @@ protected static function resolveDoubleCode($double_definition)
887888
}';
888889
}
889890

891+
if($method_return_type != 'void'){
892+
$method_code .= '$return = ';
893+
}
890894
if ($is_static) {
891-
$method_code .= '$return = self::_double_handleStaticCall(__FUNCTION__, $args); ';
895+
$method_code .= 'self::_double_handleStaticCall(__FUNCTION__, $args); ';
892896
} else {
893-
$method_code .= '$return = $this->_double_handleInstanceCall(__FUNCTION__, $args); ';
897+
$method_code .= '$this->_double_handleInstanceCall(__FUNCTION__, $args); ';
898+
}
899+
if($method_return_type != 'void'){
900+
$method_code .= 'return $return;';
894901
}
895-
$method_code .= 'return $return; }';
902+
$method_code .= ' }';
903+
896904
$methods_code[] = $method_code;
897905
}
898906
$code = substr($code, 0, strrpos($code, "}")) . implode(PHP_EOL, $methods_code) . '}';
Collapse file

‎tests/DoubleTest.php‎

Copy file name to clipboardExpand all lines: tests/DoubleTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,11 @@ public function defaultWithEscape($a = "\\")
568568
return $a;
569569
}
570570

571+
public function returnTypeVoid(): void
572+
{
573+
574+
}
575+
571576
public function returnType(): string
572577
{
573578
return 'string';

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.