From c57e2755720c50ad940630e64a3bde73c2ea2b2f Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Tue, 24 Dec 2024 13:46:33 +0300 Subject: [PATCH 1/5] ci: Updated Configruration --- .github/workflows/php70.yml | 39 ---------------------------------- .github/workflows/php71.yml | 39 ---------------------------------- .github/workflows/php72.yml | 41 ------------------------------------ .github/workflows/php73.yml | 42 ------------------------------------- .github/workflows/php74.yml | 42 ------------------------------------- .github/workflows/php80.yml | 11 +++++----- .github/workflows/php81.yml | 8 ++++--- .github/workflows/php82.yml | 10 ++++----- .github/workflows/php83.yml | 23 ++++---------------- .github/workflows/php84.yml | 29 ++++++++++++++++++++++--- 10 files changed, 45 insertions(+), 239 deletions(-) delete mode 100644 .github/workflows/php70.yml delete mode 100644 .github/workflows/php71.yml delete mode 100644 .github/workflows/php72.yml delete mode 100644 .github/workflows/php73.yml delete mode 100644 .github/workflows/php74.yml diff --git a/.github/workflows/php70.yml b/.github/workflows/php70.yml deleted file mode 100644 index 67a55a1..0000000 --- a/.github/workflows/php70.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Build PHP 7.0 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - php: [7.0] - - name: PHP${{matrix.php}} - ${{matrix.os}} - - steps: - - name: Clone Repo - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mysqli, mbstring, sqlsrv - tools: phpunit:5.7.27, composer - - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction - - - name: Execute Tests - run: phpunit - - - name: CodeCov - uses: codecov/codecov-action@v1 diff --git a/.github/workflows/php71.yml b/.github/workflows/php71.yml deleted file mode 100644 index 910f92c..0000000 --- a/.github/workflows/php71.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Build PHP 7.1 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - php: [7.1] - - name: PHP${{matrix.php}} - ${{matrix.os}} - - steps: - - name: Clone Repo - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mysqli, mbstring, sqlsrv - tools: phpunit:5.7.27, composer - - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction - - - name: Execute Tests - run: phpunit - - - name: CodeCov - uses: codecov/codecov-action@v1 diff --git a/.github/workflows/php72.yml b/.github/workflows/php72.yml deleted file mode 100644 index 0a56e5b..0000000 --- a/.github/workflows/php72.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Build PHP 7.2 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - php: [7.2] - - name: PHP${{matrix.php}} - ${{matrix.os}} - - steps: - - name: Clone Repo - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mysqli, mbstring, sqlsrv - tools: phpunit:8.5.13 - - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction - - - name: Execute Tests - run: phpunit - - - name: CodeCov - uses: codecov/codecov-action@v1 - - diff --git a/.github/workflows/php73.yml b/.github/workflows/php73.yml deleted file mode 100644 index 671fa79..0000000 --- a/.github/workflows/php73.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build PHP 7.3 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - php: [7.3] - - name: PHP${{matrix.php}} - ${{matrix.os}} - - steps: - - name: Clone Repo - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mysqli, mbstring, sqlsrv - tools: phpunit:8.5.13 - - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction - - - name: Execute Tests - run: phpunit - - - name: CodeCov - uses: codecov/codecov-action@v1 - - - diff --git a/.github/workflows/php74.yml b/.github/workflows/php74.yml deleted file mode 100644 index a929ebe..0000000 --- a/.github/workflows/php74.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build PHP 7.4 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: true - matrix: - os: [ ubuntu-latest ] - php: [7.4] - - name: PHP${{matrix.php}} - ${{matrix.os}} - - steps: - - name: Clone Repo - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: mysqli, mbstring, sqlsrv - tools: phpunit:8.5.13 - - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction - - - name: Execute Tests - run: phpunit - - - name: CodeCov - uses: codecov/codecov-action@v1 - - - diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml index 45b1af6..6b16172 100644 --- a/.github/workflows/php80.yml +++ b/.github/workflows/php80.yml @@ -28,14 +28,13 @@ jobs: extensions: mysqli, mbstring, sqlsrv tools: phpunit:8.5.13 - - name: Shutdown Ubuntu MySQL - run: sudo service mysql stop - - name: Install Dependencies - run: composer install --prefer-dist --no-interaction + run: composer install --prefer-dist --no-interaction --no-dev - name: Execute Tests - run: phpunit + run: phpunit --configuration tests/phpunit.xml - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml index fa63074..70761c2 100644 --- a/.github/workflows/php81.yml +++ b/.github/workflows/php81.yml @@ -31,13 +31,15 @@ jobs: - name: Install Dependencies - run: composer install --prefer-dist --no-interaction + run: composer install --prefer-dist --no-interaction --no-dev - name: Execute Tests - run: phpunit + run: phpunit --configuration tests/phpunit.xml - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} - name: SonarCloud uses: SonarSource/sonarcloud-github-action@master diff --git a/.github/workflows/php82.yml b/.github/workflows/php82.yml index 58aca13..5311f5e 100644 --- a/.github/workflows/php82.yml +++ b/.github/workflows/php82.yml @@ -29,14 +29,14 @@ jobs: extensions: mysqli, mbstring, sqlsrv tools: phpunit:9.5.20, composer - - name: Shutdown Ubuntu MySQL - run: sudo service mysql stop - name: Install Dependencies - run: composer install --prefer-dist --no-interaction + run: composer install --prefer-dist --no-interaction --no-dev - name: Execute Tests - run: phpunit + run: phpunit --configuration tests/phpunit.xml - name: CodeCov - uses: codecov/codecov-action@v1 \ No newline at end of file + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index d83c32a..c41980e 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -28,29 +28,14 @@ jobs: php-version: ${{ matrix.php }} extensions: mysqli, mbstring, sqlsrv tools: phpunit:9.5.20, composer - - - name: Shutdown Ubuntu MySQL - run: sudo service mysql stop - name: Install Dependencies - run: composer install --prefer-dist --no-interaction + run: composer install --prefer-dist --no-interaction --no-dev - name: Execute Tests - run: phpunit + run: phpunit --configuration tests/phpunit.xml - name: CodeCov - uses: codecov/codecov-action@v1 - - release_prod: - name: Prepare Release Branch - needs: - - "test" - runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' - steps: - - uses: actions/checkout@v4 - - uses: google-github-actions/release-please-action@v3 + uses: codecov/codecov-action@v4 with: - release-type: php - config-file: release-please-config.json - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php84.yml b/.github/workflows/php84.yml index c1f2462..8ca570e 100644 --- a/.github/workflows/php84.yml +++ b/.github/workflows/php84.yml @@ -33,10 +33,33 @@ jobs: run: sudo service mysql stop - name: Install Dependencies - run: composer install --prefer-dist --no-interaction + run: composer install --prefer-dist --no-interaction --no-dev - name: Execute Tests - run: phpunit + run: phpunit --configuration tests/phpunit.xml - name: CodeCov - uses: codecov/codecov-action@v1 \ No newline at end of file + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: SonarCloud Code Scan + uses: sonarsource/sonarqube-scan-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + release_prod: + name: Prepare Production Release Branch / Publish Release + needs: + - "test" + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - uses: google-github-actions/release-please-action@v3 + with: + release-type: php + config-file: release-please-config.json + token: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file From 70660bc0985d2169c8b9b0b172204bb50cef91c7 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Tue, 24 Dec 2024 13:48:27 +0300 Subject: [PATCH 2/5] chore: Updated GitAttributes --- .gitattributes | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitattributes b/.gitattributes index 53591f8..29cb459 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,14 @@ # perform LF normalization +# Files and folders here will be not included when creating package * text eol=crlf *.php text eol=crlf *.html text eol=crlf - -# Files and folders here will be not included when creating package /tests export-ignore -/example export-ignore /.github export-ignore /.gitignore export-ignore /.travis.yml export-ignore /phpunit.xml export-ignore -/sonar-project.properties export-ignore \ No newline at end of file +/sonar-project.properties export-ignore +/release-please-config.json +/CHANGELOG.md +/php_cs.php.dist \ No newline at end of file From 7695559beda52cdb8ac95ccab50e26b1f2b315bc Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Tue, 24 Dec 2024 13:48:49 +0300 Subject: [PATCH 3/5] chore: Updated Release Please Config --- release-please-config.json | 40 +++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/release-please-config.json b/release-please-config.json index 3fe3029..2f70c95 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,26 +1,22 @@ { "include-v-in-tag":true, "tag-separator": "-", - "packages":{ - ".":{ - "changelog-path": "CHANGELOG.md", - "changelog-sections": [ - { "type": "feat", "section": "Features" }, - { "type": "feature", "section": "Features" }, - { "type": "fix", "section": "Bug Fixes" }, - { "type": "perf", "section": "Performance Improvements" }, - { "type": "revert", "section": "Reverts" }, - { "type": "docs", "section": "Documentation" }, - { "type": "style", "section": "Styles" }, - { "type": "chore", "section": "Miscellaneous Chores" }, - { "type": "refactor", "section": "Code Refactoring" }, - { "type": "test", "section": "Testing" }, - { "type": "build", "section": "Build System" }, - { "type": "ci", "section": "Continuous Integration" }, - { "type": "ui", "section": "User Interface" }, - { "type": "database", "section": "Database Changes" }, - { "type": "email", "section": "Email Notifications Changes" } - ] - } - } + "changelog-path": "CHANGELOG.md", + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "feature", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "perf", "section": "Performance Improvements" }, + { "type": "revert", "section": "Reverts" }, + { "type": "docs", "section": "Documentation" }, + { "type": "style", "section": "Styles" }, + { "type": "chore", "section": "Miscellaneous Chores" }, + { "type": "refactor", "section": "Code Refactoring" }, + { "type": "test", "section": "Testing" }, + { "type": "build", "section": "Build System" }, + { "type": "ci", "section": "Continuous Integration" }, + { "type": "ui", "section": "User Interface" }, + { "type": "database", "section": "Database Changes" }, + { "type": "email", "section": "Email Notifications Changes" } + ] } \ No newline at end of file From 1f4588f472f8be68fa33995bd6b8b85703c8f000 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Tue, 24 Dec 2024 13:49:42 +0300 Subject: [PATCH 4/5] test: Moved PHPUnit Configuration --- phpunit.xml => tests/phpunit.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename phpunit.xml => tests/phpunit.xml (53%) diff --git a/phpunit.xml b/tests/phpunit.xml similarity index 53% rename from phpunit.xml rename to tests/phpunit.xml index 9d51057..d661394 100644 --- a/phpunit.xml +++ b/tests/phpunit.xml @@ -1,12 +1,12 @@ - + - ./webfiori/email/Email.php - ./webfiori/email/SMTPAccount.php - ./webfiori/email/SMTPServer.php + ../webfiori/email/Email.php + ../webfiori/email/SMTPAccount.php + ../webfiori/email/SMTPServer.php @@ -14,7 +14,7 @@ - ./tests/webfiori/tests/mail + ./webfiori/tests/mail \ No newline at end of file From e27e469dadcd1b89de1f6b456e499190af9f63b4 Mon Sep 17 00:00:00 2001 From: Ibrahim BinAlshikh Date: Tue, 24 Dec 2024 13:55:06 +0300 Subject: [PATCH 5/5] refactor: Fix Null Syntax --- composer.json | 2 +- tests/bootstrap.php | 2 +- webfiori/email/Email.php | 12 ++++++------ webfiori/email/exceptions/SMTPException.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 7c5d1f0..326235d 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ ], "autoload" :{ "psr-4":{ - "webfiori\\email\\":"webfiori\\email" + "webfiori\\email\\":"webfiori/email/" } } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 0c4e9dd..f0b83e2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -18,6 +18,6 @@ define('ROOT_DIR', $rootDir); define('DS', DIRECTORY_SEPARATOR); define('EMAIL_STORAGE_DIR', $rootDir.DS.'mailStorage'); -require_once ROOT_DIR.'/vendor/autoload.php'; +require_once __DIR__.$DS.'..'.$DS.'vendor'.$DS.'autoload.php'; diff --git a/webfiori/email/Email.php b/webfiori/email/Email.php index 0505f97..0a7e49a 100644 --- a/webfiori/email/Email.php +++ b/webfiori/email/Email.php @@ -104,7 +104,7 @@ public function isSent() : bool { * used to send the message. * */ - public function __construct(SMTPAccount $sendAccount = null) { + public function __construct(SMTPAccount|null $sendAccount = null) { $this->log = []; $this->priority = 0; $this->subject = 'Hello Email Message'; @@ -204,7 +204,7 @@ public function addAttachment($fileObjOrFilePath) : bool { * true. False otherwise. * */ - public function addBCC(string $address, string $name = null): bool { + public function addBCC(string $address, string|null $name = null): bool { return $this->addAddressHelper($address, $name, 'bcc'); } /** @@ -241,7 +241,7 @@ public function addBeforeSend(callable $callback, array $extraParams = []) : Ema * true. False otherwise. * */ - public function addCC(string $address, string $name = null) : bool { + public function addCC(string $address, string|null $name = null) : bool { return $this->addAddressHelper($address, $name, 'cc'); } /** @@ -284,7 +284,7 @@ public function addRecipients(array $addresses, string $recipientsType = 'to') : * true. False otherwise. * */ - public function addTo(string $address, string $name = null) : bool { + public function addTo(string $address, string|null $name = null) : bool { return $this->addAddressHelper($address, $name, 'to'); } /** @@ -513,7 +513,7 @@ public function getToStr() : string { * * @throws InvalidNodeNameException */ - public function insert($node, string $parentNodeId = null) { + public function insert($node, string|null $parentNodeId = null) { if (gettype($node) == 'string') { $node = new HTMLNode($node); } @@ -822,7 +822,7 @@ public function storeEmail(string $folderPath) { $file->setRawData($this->getDocument()->toHTML(true).''); $file->write(false, true); } - private function addAddressHelper(string $address, string $name = null, string $type = 'to') : bool { + private function addAddressHelper(string $address, string|null $name = null, string $type = 'to') : bool { if ($name === null || strlen(trim($name)) == 0) { $name = $address; } diff --git a/webfiori/email/exceptions/SMTPException.php b/webfiori/email/exceptions/SMTPException.php index 202a313..d5dae53 100644 --- a/webfiori/email/exceptions/SMTPException.php +++ b/webfiori/email/exceptions/SMTPException.php @@ -12,7 +12,7 @@ */ class SMTPException extends Exception { private $logArr; - public function __construct(string $message = "", int $code = 0, array $log = [], Throwable $previous = null) { + public function __construct(string $message = "", int $code = 0, array $log = [], Throwable|null $previous = null) { parent::__construct($message, $code, $previous); $this->logArr = $log; }