From 877a7f826127fc2c8e0e8645b895962108b2c729 Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Sun, 22 Dec 2024 19:19:42 +0300 Subject: [PATCH 1/6] ci: Updated Pipline --- .github/workflows/php71.yml | 39 -------------------- .github/workflows/php72.yml | 41 --------------------- .github/workflows/php73.yml | 42 ---------------------- .github/workflows/php74.yml | 42 ---------------------- .github/workflows/php80.yml | 8 ++--- .github/workflows/php81.yml | 11 +++--- .github/workflows/php82.yml | 9 +++-- .github/workflows/php83.yml | 29 ++++++++++++--- .github/workflows/{php70.yml => php84.yml} | 21 ++++++----- README.md | 6 +--- composer.json | 2 ++ release-please-config.json | 22 ++++++++++++ 12 files changed, 74 insertions(+), 198 deletions(-) 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 rename .github/workflows/{php70.yml => php84.yml} (65%) create mode 100644 release-please-config.json diff --git a/.github/workflows/php71.yml b/.github/workflows/php71.yml deleted file mode 100644 index 5237c9d..0000000 --- a/.github/workflows/php71.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Build PHP 7.1 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -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@v1 - - - 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-source --no-interaction --no-dev - - - 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 0b963cc..0000000 --- a/.github/workflows/php72.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Build PHP 7.2 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -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@v1 - - - 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-source --no-interaction --no-dev - - - 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 25b564f..0000000 --- a/.github/workflows/php73.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build PHP 7.3 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -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@v1 - - - 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-source --no-interaction --no-dev - - - 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 b512a9a..0000000 --- a/.github/workflows/php74.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build PHP 7.4 - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -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@v1 - - - 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-source --no-interaction --no-dev - - - 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 678d936..730d6a6 100644 --- a/.github/workflows/php80.yml +++ b/.github/workflows/php80.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Clone Repo - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -28,8 +28,6 @@ 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-source --no-interaction --no-dev @@ -38,4 +36,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/php81.yml b/.github/workflows/php81.yml index 5a8b65d..307dbce 100644 --- a/.github/workflows/php81.yml +++ b/.github/workflows/php81.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Clone Repo - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -37,10 +37,7 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 - - - name: SonarCloud - uses: SonarSource/sonarcloud-github-action@master + uses: codecov/codecov-action@v4 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + diff --git a/.github/workflows/php82.yml b/.github/workflows/php82.yml index 65d2985..872586f 100644 --- a/.github/workflows/php82.yml +++ b/.github/workflows/php82.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Clone Repo - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -28,9 +28,6 @@ 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-source --no-interaction --no-dev @@ -39,4 +36,6 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 \ No newline at end of file + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index a68dba8..8cae497 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Clone Repo - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -28,9 +28,6 @@ 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-source --no-interaction --no-dev @@ -39,4 +36,26 @@ jobs: run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + env: + CODECOV_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/master' + 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 }} diff --git a/.github/workflows/php70.yml b/.github/workflows/php84.yml similarity index 65% rename from .github/workflows/php70.yml rename to .github/workflows/php84.yml index f8588b9..58c796d 100644 --- a/.github/workflows/php70.yml +++ b/.github/workflows/php84.yml @@ -1,39 +1,44 @@ -name: Build PHP 7.0 +name: Build PHP 8.4 on: push: - branches: [ master ] + branches: [ master, dev ] pull_request: branches: [ master ] jobs: test: runs-on: ${{ matrix.os }} - + strategy: fail-fast: true matrix: os: [ ubuntu-latest ] - php: [7.0] + php: [8.4] name: PHP${{matrix.php}} - ${{matrix.os}} steps: - name: Clone Repo - uses: actions/checkout@v1 + 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 + tools: phpunit:9.5.20, composer + - name: Shutdown Ubuntu MySQL + run: sudo service mysql stop + - name: Install Dependencies run: composer install --prefer-source --no-interaction --no-dev - + - name: Execute Tests run: phpunit - name: CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index 3deeda3..c1ab209 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,11 @@ According to [json.org](https://www.json.org/json-en.html), JSON is a data excha ## Supported PHP Versions | Build Status | |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| -| | -| | -| | -| | -| | | | | | | | | | +| | ## Installation If you are using composer to manage your dependencies, then it is possible to install the library by including the entry `"webfiori/jsonx":"*"` in the `require` section of your `composer.json` file to install the latest release. diff --git a/composer.json b/composer.json index 24fc888..a52be3c 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,8 @@ "name": "webfiori/jsonx", "type": "library", "description": "PHP library for creating well-formatted JSON strings.", + "type":"library", + "version":"3.3.0", "keywords": [ "JSON", "PHP", "JSONx" ], diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..2f70c95 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,22 @@ +{ + "include-v-in-tag":true, + "tag-separator": "-", + "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 71a221b40ed977a7c28f0e9bec6f9b5cb9152d70 Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Sun, 22 Dec 2024 19:20:06 +0300 Subject: [PATCH 2/6] Update php83.yml --- .github/workflows/php83.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php83.yml b/.github/workflows/php83.yml index 8cae497..5867896 100644 --- a/.github/workflows/php83.yml +++ b/.github/workflows/php83.yml @@ -4,7 +4,7 @@ on: push: branches: [ master, dev ] pull_request: - branches: [ master ] + branches: [ master, dev ] jobs: test: From d82823d1cd438219c8bffaad2e000994cd6732f4 Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Sun, 22 Dec 2024 19:22:18 +0300 Subject: [PATCH 3/6] fix: Use of New Null Syntax --- webfiori/json/JsonConverter.php | 4 ++-- webfiori/json/Property.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/webfiori/json/JsonConverter.php b/webfiori/json/JsonConverter.php index 7650d32..312a5c6 100644 --- a/webfiori/json/JsonConverter.php +++ b/webfiori/json/JsonConverter.php @@ -252,7 +252,7 @@ private static function checkJsonType($val, $valType, $propsStyle, $lettersCase, return $retVal; } - private static function checkJsonXType($datatype, $value, Property $prop = null, $isArrayValue = false) { + private static function checkJsonXType($datatype, $value, ?Property $prop, $isArrayValue = false) { $retVal = self::$Tab; $propX = new Property('x', $value); $propX->setStyle($prop->getStyle()); @@ -367,7 +367,7 @@ private static function objToJson($probVal, string $style, string $lettersCase) return $retVal; } - private static function objToJsonX(Property $prop, $val = null) { + private static function objToJsonX(Property $prop, ?mixed $val) { $asJson = self::objectToJson($val); if (count($asJson->getProperties()) == 0) { diff --git a/webfiori/json/Property.php b/webfiori/json/Property.php index c9bf987..03171db 100644 --- a/webfiori/json/Property.php +++ b/webfiori/json/Property.php @@ -83,7 +83,7 @@ class Property { * * @since 1.0 */ - public function __construct(string $name, $value, string $style = null, string $case = 'same') { + public function __construct(string $name, $value, ?string $style, string $case = 'same') { $this->name = ''; $this->setStyle('none'); From bd6bd120ab7528c3d256ada6a6f94913e51fc39a Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Mon, 23 Dec 2024 11:31:14 +0300 Subject: [PATCH 4/6] Update JsonConverter.php --- webfiori/json/JsonConverter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfiori/json/JsonConverter.php b/webfiori/json/JsonConverter.php index 312a5c6..1ffee12 100644 --- a/webfiori/json/JsonConverter.php +++ b/webfiori/json/JsonConverter.php @@ -367,7 +367,7 @@ private static function objToJson($probVal, string $style, string $lettersCase) return $retVal; } - private static function objToJsonX(Property $prop, ?mixed $val) { + private static function objToJsonX(Property $prop, mixed $val) { $asJson = self::objectToJson($val); if (count($asJson->getProperties()) == 0) { From 4220c96facdaa8dc14df995b622c3b1bc484a1cc Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Mon, 23 Dec 2024 11:57:39 +0300 Subject: [PATCH 5/6] Update Property.php --- webfiori/json/Property.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webfiori/json/Property.php b/webfiori/json/Property.php index 03171db..6e72028 100644 --- a/webfiori/json/Property.php +++ b/webfiori/json/Property.php @@ -83,7 +83,7 @@ class Property { * * @since 1.0 */ - public function __construct(string $name, $value, ?string $style, string $case = 'same') { + public function __construct(string $name, $value, ?string $style = 'none', string $case = 'same') { $this->name = ''; $this->setStyle('none'); From 538cdeb20553e6038f86d96f120c6047a98f40cb Mon Sep 17 00:00:00 2001 From: Ibrahim Date: Mon, 23 Dec 2024 11:59:06 +0300 Subject: [PATCH 6/6] Update JsonTest.php --- tests/webfiori/tests/json/JsonTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/webfiori/tests/json/JsonTest.php b/tests/webfiori/tests/json/JsonTest.php index 2ad991e..bf3b3c5 100644 --- a/tests/webfiori/tests/json/JsonTest.php +++ b/tests/webfiori/tests/json/JsonTest.php @@ -12,7 +12,7 @@ class JsonTest extends TestCase { */ public function testToJsonFile00() { $json = new Json(); - $json->toJsonFile('json-file', ROOT.DIRECTORY_SEPARATOR.'json-output'); + $json->toJsonFile('json-file', ROOT.DIRECTORY_SEPARATOR.'json-output', true); $outputPath = ROOT.DIRECTORY_SEPARATOR.'json-output'.DIRECTORY_SEPARATOR.'json-file.json'; $this->assertTrue(file_exists($outputPath)); }