Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #27

Merged
merged 25 commits into from Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
da179c3
big cleanup, improved consistency and test coverage; this breaks BC
SamMousa Mar 23, 2022
e77e8ab
fix: psr3 compliance and cleaned up the logger using the trait from t…
SamMousa Mar 23, 2022
b925c56
rewrote logger to not use service locator pattern and added tests for it
SamMousa Mar 23, 2022
4fb882b
implement interfaces and wrappers for signers and encrypters
SamMousa Mar 24, 2022
47ce95e
fix #28
SamMousa Mar 24, 2022
090a226
fix CS using easy coding standard, remove logging getters and setters…
SamMousa Mar 24, 2022
3c53053
Update src/DkimSignerWrapper.php
SamMousa Mar 24, 2022
5599b51
Update src/SMimeEncrypterWrapper.php
SamMousa Mar 24, 2022
50b7aae
Update src/SymfonyMessageSignerInterface.php
SamMousa Mar 24, 2022
d423914
Update src/SymfonyMessageWrapperInterface.php
SamMousa Mar 24, 2022
923a1b6
Update src/SymfonyMessageEncrypterInterface.php
SamMousa Mar 24, 2022
f6a284e
Update src/SMimeSignerWrapper.php
SamMousa Mar 24, 2022
ffa9fb6
fix: pr feedback
SamMousa Mar 24, 2022
64bd4b0
chore: getTransport is now private
SamMousa Apr 12, 2022
1a8bf25
chore: optimize imports
SamMousa Apr 12, 2022
b6ccfc2
add static analysis and apply fixes
SamMousa Apr 12, 2022
254535a
chore: fix cs
SamMousa Aug 16, 2022
9563579
chore: add test for serialization #35
SamMousa Aug 16, 2022
5a5b6e9
chore: add changelog
SamMousa Aug 16, 2022
8a7bb5d
fix: dont silence exceptions #37
SamMousa Aug 16, 2022
74dc189
fix: remove unused Logger
SamMousa Aug 16, 2022
ed9d662
fix: mailer couldn't be instantiated via yii createobject
SamMousa Aug 17, 2022
5b174e4
feat: allow transportfactory to be unset in mailer
SamMousa Aug 17, 2022
0c13d06
chore: fix cs add captainhook for automatic checks
SamMousa Aug 17, 2022
307f857
Merge remote-tracking branch 'origin/master' into code-cleanup
SamMousa Sep 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/build.yml
Expand Up @@ -24,6 +24,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: pcov
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
Expand All @@ -35,5 +36,9 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Run unit tests without coverage
run: vendor/bin/phpunit --verbose --colors=always
- name: Run unit tests with coverage
run: vendor/bin/phpunit --coverage-text
- name: Static analysis (Psalm)
run: vendor/bin/psalm
- name: Test code style
run: vendor/bin/ecs
8 changes: 4 additions & 4 deletions CHANGELOG.md
@@ -1,12 +1,13 @@
Yii Framework 2 Symfony mailer extension Change Log
================================================

2.0.5 under development
3.0.0 under development
-----------------------

- no changes in this release.

- Enh #27: Extensive rewrite to make it more statically typed and better testable (sammousa)
- Enh #22: Added an exception if there is no transport configuration (Krakozaber)


2.0.4 September 04, 2022
------------------------

Expand Down Expand Up @@ -38,4 +39,3 @@ Yii Framework 2 Symfony mailer extension Change Log
-----------------------

- Initial release.

59 changes: 59 additions & 0 deletions captainhook.json
@@ -0,0 +1,59 @@
{
"commit-msg": {
"enabled": true,
"actions": []
},
"pre-push": {
"enabled": false,
"actions": []
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/phpunit",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/ecs",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/psalm",
"options": [],
"conditions": []
}
]
},
"prepare-commit-msg": {
"enabled": false,
"actions": []
},
"post-commit": {
"enabled": false,
"actions": []
},
"post-merge": {
"enabled": false,
"actions": []
},
"post-checkout": {
"enabled": false,
"actions": []
},
"post-rewrite": {
"enabled": false,
"actions": []
},
"post-change": {
"enabled": false,
"actions": []
}
}
14 changes: 12 additions & 2 deletions composer.json
Expand Up @@ -30,7 +30,11 @@
"symfony/mailer": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "9.5.10"
"phpunit/phpunit": "9.5.10",
"symplify/easy-coding-standard": "^10.1",
"vimeo/psalm": "^4.22",
"captainhook/captainhook": "^5.10",
"captainhook/plugin-composer": "^5.3"
},
"repositories": [
{
Expand All @@ -43,14 +47,20 @@
"yii\\symfonymailer\\": "src"
}
},
"autoload-dev": {
"classmap": [
"vendor/yiisoft/yii2/Yii.php"
]
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
"yiisoft/yii2-composer": true,
"captainhook/plugin-composer": true
}
}
}
27 changes: 27 additions & 0 deletions ecs.php
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// run and fix, one by one
$ecsConfig->import(SetList::ARRAY);
$ecsConfig->import(SetList::DOCBLOCK);
$ecsConfig->import(SetList::PSR_12);

$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
'syntax' => 'short'
]);



};
8 changes: 7 additions & 1 deletion phpunit.xml.dist
Expand Up @@ -5,10 +5,16 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="true"
stopOnFailure="false">
<testsuites>
<testsuite name="Yii2-swiftmailer Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
15 changes: 15 additions & 0 deletions psalm.xml
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
26 changes: 26 additions & 0 deletions src/DkimMessageSigner.php
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace yii\symfonymailer;

use Symfony\Component\Mime\Crypto\DkimSigner;
use Symfony\Component\Mime\Message;

/**
* @codeCoverageIgnore This class is a trivial proxy that requires no testing
*/
class DkimMessageSigner implements MessageSignerInterface
{
private DkimSigner $dkimSigner;

public function __construct(DkimSigner $dkimSigner)
{
$this->dkimSigner = $dkimSigner;
}

public function sign(Message $message, array $options = []): Message
{
return $this->dkimSigner->sign($message, $options);
}
}
163 changes: 0 additions & 163 deletions src/Logger.php

This file was deleted.