Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #142 from Qoraiche/patch/port-v3-to-v2
Browse files Browse the repository at this point in the history
fix: restore missing logic in parameter resolution
  • Loading branch information
ReeceM authored Dec 10, 2020
2 parents 4c9bc96 + 078218c commit 3560fef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,23 @@ see #107, #106
### Addition
- Revert Laravel 8 support
- Console command for installing assets see PR #111

## Version 2.2.1
Patch Release.

### Fixes

- Fixes the string error that happens when the constructor params have a string type hint, issue #103
see #113

## Version 2.2.2
This is a patch release of the package for a PSR-4 warning

### Fix

- The namespace and the file structure of the console command were corrected to PSR-4 standards thanks @ivebe, see #115


## Version 2.2.3
### Fix
- port version 3 fix back into v2, see #140, #141
35 changes: 17 additions & 18 deletions src/MailEclipse.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,14 +623,7 @@ public static function handleMailableViewDataArgs($mailable)
return;
}
} else {
try {
$missingParam = self::getMissingParams($arg, $params);
$filteredparams[] = is_null($missingParam)
? new Mocked($arg, \ReeceM\Mocker\Utils\VarStore::singleton())
: $missingParam;
} catch (\Exception $error) {
$filteredparams[] = $arg;
}
$filteredparams = self::getMissingParams($arg, $params);
}
}

Expand All @@ -649,7 +642,7 @@ public static function handleMailableViewDataArgs($mailable)
/**
* Gets any missing params that may not be collectable in the reflection.
*
* @param string $arg the argument string|array
* @param string $arg the argument string|
* @param array $params the reflection param list
*
* @return array|string|\ReeceM\Mocker\Mocked
Expand All @@ -667,19 +660,25 @@ private static function getMissingParams($arg, $params)
*/
$reflection = collect($params)->where('name', $arg)->first()->getType();

if (is_null($reflection)) {
return $arg;
}

if (version_compare(phpversion(), '7.1', '>=')) {
$reflectionType = $reflection->getName();
$type = ! is_null($reflection)
? self::TYPES[$reflection->getName()]
: null;
} else {
$reflectionType = /** @scrutinizer ignore-deprecated */ $reflection->__toString();
$type = ! is_null($reflection)
? self::TYPES[
/** @scrutinizer ignore-deprecated */
$reflection->__toString()]
: null;
}

return array_key_exists($reflectionType, self::TYPES)
? self::TYPES[$reflectionType]
: $reflectionType;
try {
return ! is_null($type)
? $type
: new Mocked($arg, \ReeceM\Mocker\Utils\VarStore::singleton());
} catch (\Exception $e) {
return $arg;
}
}

private static function getMailableViewData($mailable, $mailable_data)
Expand Down

0 comments on commit 3560fef

Please sign in to comment.