Skip to content

Commit

Permalink
v3
Browse files Browse the repository at this point in the history
  • Loading branch information
introwit committed Nov 12, 2018
1 parent a457145 commit 6e7a790
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
All notable changes to the Laravel Mail Viewer be documented in this file

## v3.0.0 (13-11-2018)
- If the constructor dependency is not type hinted it will trust the user input in the config file as a replacement. [PR for this feature](https://github.com/JoggApp/laravel-mail-viewer/pull/15)
- Big thanks & credits to [Junhai](https://github.com/starvsion) for making this possible :)

## v2.2.0 (11-10-2018)
- The package now uses DB transactions. [PR for this feature](https://github.com/JoggApp/laravel-mail-viewer/pull/12)
- Big thanks & credits to [Wouter Peschier](https://github.com/kielabokkie) for making this possible :)
Expand Down
8 changes: 5 additions & 3 deletions src/MailViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ public static function prepareMails(array $mailables): array

$constructorParameters = [];

for($i = 0; $i < count( $reflection->getConstructor()->getParameters()); $i++) {
for ($i = 0; $i < count($reflection->getConstructor()->getParameters()); $i++) {
$parameter = $reflection->getConstructor()->getParameters()[$i];

if (empty($parameter->getType())) {
$constructorParameters[$i] = $givenParameters[$i];
$constructorParameters[$i] = $givenParameters[$i];
continue;
}

$constructorParameters[] = $parameter->getType()->getName() == 'int' ? 'integer' : $parameter->getType()->getName();
}

if ($constructorParameters !== $givenParameters) {
throw new Exception(
"The arguments passed for {$mailable} in the config/mailviewer.php file do not match with the constructor
Expand Down
3 changes: 2 additions & 1 deletion tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ protected function getEnvironmentSetUp($app)
[],
\stdClass::class,
'Some name',
7
7,
null
],
TestEmailWithState::class => [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/Mail/TestEmailWithDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestEmailWithDependencies extends Mailable
*
* @return void
*/
public function __construct(array $arr, \stdClass $someObject, string $name, int $number)
public function __construct(array $arr, \stdClass $someObject, string $name, int $number, $nonTypeHintedVar)
{
//
}
Expand Down

0 comments on commit 6e7a790

Please sign in to comment.