diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9193d27 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [] + +jobs: + unit-tests: + runs-on: ubuntu-latest + strategy: + matrix: + php_version: [8.0, 8.1, 8.2, 8.3] + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + tools: composer:v2 + extensions: apcu + + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Dependencies + run: composer install --no-interaction --prefer-dist --optimize-autoloader + + - run: cp ./tests/Includes/Config.yaml ./src/Config/Config.yaml + + - run: php src/Vendor/bin/phpunit tests + + PHPStan: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: php-actions/composer@v6 + - uses: php-actions/phpstan@v3 + with: + configuration: phpstan.neon + memory_limit: 256M + version: latest diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index b106fc2..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: PHPStan - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build-test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: php-actions/composer@v6 - - uses: php-actions/phpstan@v3 - with: - configuration: phpstan.neon - memory_limit: 256M - version: latest diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml deleted file mode 100644 index 8868460..0000000 --- a/.github/workflows/unittests.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Unit Tests - -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - build-test: - runs-on: ubuntu-latest - strategy: - matrix: - php_version: [8.0, 8.1, 8.2, 8.3] - - steps: - - uses: actions/checkout@v4 - - uses: php-actions/composer@v6 - with: - dev: yes - php_version: ${{ matrix.php_version }} - php_extensions: apcu - - - run: cp ./tests/Includes/Config.yaml ./src/Config/Config.yaml - - - run: php src/Vendor/bin/phpunit tests diff --git a/.gitignore b/.gitignore index 2c57bfe..6e0774e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules src/Cache/* src/Config/Config.yaml -src/Config/Pages.yaml \ No newline at end of file +src/Config/Pages.yaml +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..7eb240c --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,15 @@ +in(__DIR__) + ->exclude([ + 'src/Vendor', + ]) +; + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + ]) + ->setFinder($finder) +; \ No newline at end of file diff --git a/composer.json b/composer.json index 58fc7df..93d9ec4 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "antcms/antloader": "^2.0.0", "elgigi/commonmark-emoji": "^2.0", "embed/embed": "^4.4", + "flightphp/core": "^3.8", "league/commonmark": "^2.3", "nyholm/psr7": "^1.8", "shapecode/twig-string-loader": "^1.1", @@ -32,8 +33,9 @@ "sort-packages": true }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.54", "phpstan/phpstan": "^1.9", "phpunit/phpunit": "^9.5", - "rector/rector": "^0.15.4" + "rector/rector": "^1.0.4" } } diff --git a/composer.lock b/composer.lock index 6d2d1cc..3d5c50c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0a8bd78b6cb54c56ae2a1cb8f677a80b", + "content-hash": "03393e43b5795db631955696c829e7ce", "packages": [ { "name": "antcms/antloader", @@ -204,16 +204,16 @@ }, { "name": "composer/pcre", - "version": "3.1.2", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace" + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4775f35b2d70865807c89d32c8e7385b86eb0ace", - "reference": "4775f35b2d70865807c89d32c8e7385b86eb0ace", + "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", "shasum": "" }, "require": { @@ -255,7 +255,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.2" + "source": "https://github.com/composer/pcre/tree/3.1.3" }, "funding": [ { @@ -271,7 +271,7 @@ "type": "tidelift" } ], - "time": "2024-03-07T15:38:35+00:00" + "time": "2024-03-19T10:26:25+00:00" }, { "name": "dflydev/dot-access-data", @@ -475,6 +475,79 @@ ], "time": "2023-12-10T12:30:47+00:00" }, + { + "name": "flightphp/core", + "version": "v3.8.1", + "source": { + "type": "git", + "url": "https://github.com/flightphp/core.git", + "reference": "0011efd42c40f4c600612e425ad598ec8cd6bae7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/flightphp/core/zipball/0011efd42c40f4c600612e425ad598ec8cd6bae7", + "reference": "0011efd42c40f4c600612e425ad598ec8cd6bae7", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.4|^8.0|^8.1|^8.2|^8.3" + }, + "replace": { + "mikecao/flight": "2.0.2" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "league/container": "^4.2", + "level-2/dice": "^4.0", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5", + "rregeer/phpunit-coverage-check": "^0.3.1", + "squizlabs/php_codesniffer": "^3.8" + }, + "suggest": { + "latte/latte": "Latte template engine", + "phpstan/phpstan": "PHP Static Analyzer", + "tracy/tracy": "Tracy debugger" + }, + "type": "library", + "autoload": { + "files": [ + "flight/autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike Cao", + "email": "mike@mikecao.com", + "homepage": "http://www.mikecao.com/", + "role": "Original Developer" + }, + { + "name": "Franyer Sánchez", + "email": "franyeradriansanchez@gmail.com", + "homepage": "https://faslatam.000webhostapp.com", + "role": "Maintainer" + }, + { + "name": "n0nag0n", + "email": "n0nag0n@sky-9.com", + "role": "Maintainer" + } + ], + "description": "Flight is a fast, simple, extensible framework for PHP. Flight enables you to quickly and easily build RESTful web applications. This is the maintained fork of mikecao/flight", + "homepage": "http://flightphp.com", + "support": { + "issues": "https://github.com/flightphp/core/issues", + "source": "https://github.com/flightphp/core/tree/v3.8.1" + }, + "time": "2024-04-11T04:28:40+00:00" + }, { "name": "league/commonmark", "version": "2.4.2", @@ -2310,16 +2383,16 @@ }, { "name": "twig/twig", - "version": "v3.9.0", + "version": "v3.9.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "47857eebb197745f66369b76c044a2359e3cc5b9" + "reference": "a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/47857eebb197745f66369b76c044a2359e3cc5b9", - "reference": "47857eebb197745f66369b76c044a2359e3cc5b9", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58", + "reference": "a842d75fed59cdbcbd3a3ad7fb9eb768fc350d58", "shasum": "" }, "require": { @@ -2373,7 +2446,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.9.0" + "source": "https://github.com/twigphp/Twig/tree/v3.9.3" }, "funding": [ { @@ -2385,10 +2458,157 @@ "type": "tidelift" } ], - "time": "2024-04-16T16:04:21+00:00" + "time": "2024-04-18T11:59:33+00:00" } ], "packages-dev": [ + { + "name": "composer/semver", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-08-31T09:50:34+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/4f988f8fdf580d53bdb2d1278fe93d1ed5462255", + "reference": "4f988f8fdf580d53bdb2d1278fe93d1ed5462255", + "shasum": "" + }, + "require": { + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", + "psr/log": "^1 || ^2 || ^3" + }, + "require-dev": { + "phpstan/phpstan": "^1.0", + "phpstan/phpstan-strict-rules": "^1.1", + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without Xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/3.0.4" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2024-03-26T18:29:49+00:00" + }, { "name": "doctrine/instantiator", "version": "1.5.0", @@ -2459,6 +2679,99 @@ ], "time": "2022-12-30T00:15:36+00:00" }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v3.54.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2aecbc8640d7906c38777b3dcab6f4ca79004d08", + "reference": "2aecbc8640d7906c38777b3dcab6f4ca79004d08", + "shasum": "" + }, + "require": { + "composer/semver": "^3.4", + "composer/xdebug-handler": "^3.0.3", + "ext-filter": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^7.4 || ^8.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/polyfill-mbstring": "^1.28", + "symfony/polyfill-php80": "^1.28", + "symfony/polyfill-php81": "^1.28", + "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" + }, + "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", + "infection/infection": "^0.27.11", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.1", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.7", + "php-cs-fixer/accessible-object": "^1.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", + "phpunit/phpunit": "^9.6 || ^10.5.5 || ^11.0.2", + "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" + }, + "suggest": { + "ext-dom": "For handling output formats in XML", + "ext-mbstring": "For handling non-UTF8 characters." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.54.0" + }, + "funding": [ + { + "url": "https://github.com/keradus", + "type": "github" + } + ], + "time": "2024-04-17T08:12:13+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.11.1", @@ -2696,16 +3009,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.62", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "cd5c8a1660ed3540b211407c77abf4af193a6af9" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/cd5c8a1660ed3540b211407c77abf4af193a6af9", - "reference": "cd5c8a1660ed3540b211407c77abf4af193a6af9", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -2748,13 +3061,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-13T12:27:20+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3077,16 +3386,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.17", + "version": "9.6.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd" + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1a156980d78a6666721b7e8e8502fe210b587fcd", - "reference": "1a156980d78a6666721b7e8e8502fe210b587fcd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", "shasum": "" }, "require": { @@ -3160,7 +3469,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.17" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" }, "funding": [ { @@ -3176,25 +3485,25 @@ "type": "tidelift" } ], - "time": "2024-02-23T13:14:51+00:00" + "time": "2024-04-05T04:35:58+00:00" }, { "name": "rector/rector", - "version": "0.15.25", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "015935c7ed9e48a4f5895ba974f337e20a263841" + "reference": "6e04d0eb087aef707fa0c5686d33d6ff61f4a555" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/015935c7ed9e48a4f5895ba974f337e20a263841", - "reference": "015935c7ed9e48a4f5895ba974f337e20a263841", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/6e04d0eb087aef707fa0c5686d33d6ff61f4a555", + "reference": "6e04d0eb087aef707fa0c5686d33d6ff61f4a555", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.14" + "phpstan/phpstan": "^1.10.57" }, "conflict": { "rector/rector-doctrine": "*", @@ -3202,15 +3511,13 @@ "rector/rector-phpunit": "*", "rector/rector-symfony": "*" }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, "bin": [ "bin/rector" ], "type": "library", - "extra": { - "branch-alias": { - "dev-main": "0.15-dev" - } - }, "autoload": { "files": [ "bootstrap.php" @@ -3229,7 +3536,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.15.25" + "source": "https://github.com/rectorphp/rector/tree/1.0.4" }, "funding": [ { @@ -3237,7 +3544,7 @@ "type": "github" } ], - "time": "2023-04-20T16:07:39+00:00" + "time": "2024-04-05T09:01:07+00:00" }, { "name": "sebastian/cli-parser", @@ -4202,6 +4509,836 @@ ], "time": "2020-09-28T06:39:44+00:00" }, + { + "name": "symfony/console", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/c3ebc83d031b71c39da318ca8b7a07ecc67507ed", + "reference": "c3ebc83d031b71c39da318ca8b7a07ecc67507ed", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-mbstring": "~1.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/string": "^5.4|^6.0" + }, + "conflict": { + "symfony/dependency-injection": "<5.4", + "symfony/dotenv": "<5.4", + "symfony/event-dispatcher": "<5.4", + "symfony/lock": "<5.4", + "symfony/process": "<5.4" + }, + "provide": { + "psr/log-implementation": "1.0|2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/event-dispatcher": "^5.4|^6.0", + "symfony/lock": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/var-dumper": "^5.4|^6.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Eases the creation of beautiful and testable command line interfaces", + "homepage": "https://symfony.com", + "keywords": [ + "cli", + "command line", + "console", + "terminal" + ], + "support": { + "source": "https://github.com/symfony/console/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "2eaf8e63bc5b8cefabd4a800157f0d0c094f677a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/2eaf8e63bc5b8cefabd4a800157f0d0c094f677a", + "reference": "2eaf8e63bc5b8cefabd4a800157f0d0c094f677a", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/event-dispatcher-contracts": "^2|^3" + }, + "conflict": { + "symfony/dependency-injection": "<5.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^5.4|^6.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "7bc61cc2db649b4637d331240c5346dcc7708051" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7bc61cc2db649b4637d331240c5346dcc7708051", + "reference": "7bc61cc2db649b4637d331240c5346dcc7708051", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:55:41+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/3d49eec03fda1f0fc19b7349fbbe55ebc1004214", + "reference": "3d49eec03fda1f0fc19b7349fbbe55ebc1004214", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-20T17:44:14+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/6a180d1c45e0d9797470ca9eb46215692de00fa3", + "reference": "6a180d1c45e0d9797470ca9eb46215692de00fa3", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-php81", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/process", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "2114fd60f26a296cc403a7939ab91478475a33d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/2114fd60f26a296cc403a7939ab91478475a33d4", + "reference": "2114fd60f26a296cc403a7939ab91478475a33d4", + "shasum": "" + }, + "require": { + "php": ">=8.0.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Executes commands in sub-processes", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/process/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "011e781839dd1d2eb8119f65ac516a530f60226d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/011e781839dd1d2eb8119f65ac516a530f60226d", + "reference": "011e781839dd1d2eb8119f65ac516a530f60226d", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/service-contracts": "^1|^2|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a way to profile code", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/stopwatch/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, + { + "name": "symfony/string", + "version": "v6.0.19", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/d9e72497367c23e08bf94176d2be45b00a9d232a", + "reference": "d9e72497367c23e08bf94176d2be45b00a9d232a", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.0" + }, + "require-dev": { + "symfony/error-handler": "^5.4|^6.0", + "symfony/http-client": "^5.4|^6.0", + "symfony/translation-contracts": "^2.0|^3.0", + "symfony/var-exporter": "^5.4|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v6.0.19" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-01-01T08:36:10+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.3", diff --git a/readme.md b/readme.md index 85cbbe5..ac57496 100644 --- a/readme.md +++ b/readme.md @@ -1,70 +1,3 @@ # AntCMS -[![PHPStan](https://github.com/AntCMS-org/AntCMS/actions/workflows/phpstan.yml/badge.svg)](https://github.com/AntCMS-org/AntCMS/actions/workflows/phpstan.yml) -[![Unit Tests](https://github.com/AntCMS-org/AntCMS/actions/workflows/unittests.yml/badge.svg)](https://github.com/AntCMS-org/AntCMS/actions/workflows/unittests.yml) - -A tiny and fast CMS system for static websites. - -## What is AntCMS? - -AntCMS is a lightweight CMS system designed for simplicity, speed, and small size. It is a flat-file CMS, meaning it lacks advanced features but benefits from improved speed and reduced complexity. - -### How fast is AntCMS? - -AntCMS is designed for speed, with a simple backend and caching capabilities that allow it to quickly render and deliver pages to users in milliseconds. This speed is further enhanced by the use of Tailwind CSS in the default theme, which is only 25KB. -Our unit tests also ensure that rendering markdown content takes less than 0.015 seconds, as demonstrated by the following recent results: `Markdown rendering speed with cache: 0.000289 VS without: 0.003414`. - -### How does it work? - -Using AntCMS is simple. First, you need an HTML template with special elements for AntCMS. Then, you can write your content using the popular [markdown](https://www.markdownguide.org/cheat-sheet/) formatting syntax. AntCMS will convert the markdown to HTML, integrate it into the template, and send it to the viewer. This process is already quick, but AntCMS also has caching capabilities that can further improve rendering times. - -AntCMS will also automatically leverage the APCu extension for caching, which helps to further improve your website's response time. - -### Theming with AntCMS - -AntCMS stores its themes in the `/Themes` directory. Each theme consists of a simple page layout template. A theme may also have an `/Assets` folder within its directory, which can be accessed directly from the server. Any files stored outside of this folder will be inaccessible. - -Here is an example of the default theme folder structure: - -- `/Themes` - - `/Default` - - `/Templates` - - `default.html.twig` - - `nav.html.twig` - - `/Assets` - - `tailwind.css` - -To change the active theme, simply edit `Config.yaml` and set the `activeTheme` option to match the folder name of your custom theme. - -### Configuring AntCMS - -AntCMS stores its configuration in the human-readable "yaml" file format. The main configuration files are `Config.yaml`, `Pages.yaml`, and `Users.yaml`. These files will be automatically generated by AntCMS if they do not exist. - -#### Options in `Config/Config.yaml` - -- `siteInfo:` - - `siteTitle: AntCMS` - This configuration sets the title of your AntCMS website. -- `forceHTTPS: true` - Set to 'true' by default, enables HTTPs redirection. -- `activeTheme: Default` - Sets what theme AntCMS should use. should match the folder name of the theme you want to use. -- `enableCache: true` - Enables or disables file caching in AntCMS. -- `debug: true`- Enabled or disables debug mode. -- `baseURL: antcms.example.com/` - Used to set the baseURL for your AntCMS instance, without the protocol. This will be automatically generated for you, but can be changed if needed. - -#### Options in `Config/Pages.yaml` - -The `Pages.yaml` file holds a list of your pages. This file is automatically generated if it doesn't exist. At the moment, AntCMS doesn't automatically regenerate this for you, so for new content to appear you will need to delete the `Pages.yaml` file. -The order of which files are stored inside of the `Pages.yaml` file dictates what order they will be displayed in the browser window. -Here's what the `Pages.yaml` file looks like: - -- `pageTitle: 'Hello World'` - This defines what the title of the page is in the navbar. -- `fullPagePath: /antcms.example.com/public_html/Content/index.md` - This defines the full path to your page, as PHP would use to access it. -- `functionalPagePath: /index.md` - This is the actual path you would use to access the page from online. Ex: `antcms.example.com/index.php` -- `showInNav: true` - If you'd like to hide a page from the navbar, set this to false and it will be hidden. - -#### The Admin Plugin - -AntCMS has a very simple admin plugin that you can access it by visiting `antcms.example.com/admin`. -It will then require you to authenticate using your AntCMS credentials and from there will give you a few simple actions such as editing your config, a page, or regenerating the page list. -The admin plugin also features a live preview of the content you are creating, but it's important to note that the preview doesn't support all of the markdown syntax that AntCMS does, such as emojis. - -Note: when editing the config, if you 'save' it and it didn't update, this means you made an error in the config file and AntCMS prevented the file from being saved. +AntCMS is being largely rebuilt for better, faser, easier functionality. \ No newline at end of file diff --git a/rector.php b/rector.php index a8a51cc..307c871 100644 --- a/rector.php +++ b/rector.php @@ -2,34 +2,14 @@ declare(strict_types=1); -use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; -use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector; use Rector\Config\RectorConfig; -use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector; -use Rector\Php80\Rector\FunctionLike\MixedTypeRector; -use Rector\Php80\Rector\FunctionLike\UnionTypesRector; -use Rector\Set\ValueObject\SetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - $rectorConfig->skip([ - __DIR__ . '/src/Vendor', - __DIR__ . '/src/Cache', - UnionTypesRector::class, - MixedTypeRector::class, - EncapsedStringsToSprintfRector::class, - ConsistentPregDelimiterRector::class, - RemoveAnnotationRector::class, - ]); - - $rectorConfig->sets([ - SetList::PHP_80, - SetList::CODE_QUALITY, - SetList::CODING_STYLE, - SetList::NAMING, - SetList::DEAD_CODE, - ]); -}; + ]) + ->withSkipPath(__DIR__ . '/src/Vendor') + ->withDeadCodeLevel(42) + ->withTypeCoverageLevel(37) + ->withPhpSets(); diff --git a/src/AntCMS/AntAuth.php b/src/AntCMS/AntAuth.php index a04389c..7668c02 100644 --- a/src/AntCMS/AntAuth.php +++ b/src/AntCMS/AntAuth.php @@ -35,10 +35,8 @@ public function isAuthenticated() * Check if the user is authenticated using the credentials in the config file. * If the plain text password in the config file is still present, it will be hashed and the config file will be updated. * If the user is not authenticated, it will call AntAuth::requireAuth() - * - * @return void */ - public function checkAuth() + public function checkAuth(): void { $username = $_SERVER['PHP_AUTH_USER'] ?? null; $password = $_SERVER['PHP_AUTH_PW'] ?? null; @@ -74,10 +72,8 @@ public function checkAuth() /** * Send an authentication challenge to the browser, with the realm set to the site title in config. - * - * @return void */ - private function requireAuth() + private function requireAuth(): void { setcookie("auth", "valid"); @@ -88,7 +84,7 @@ private function requireAuth() exit; } - public function invalidateSession() + public function invalidateSession(): void { $this->authenticated = false; $this->requireAuth(); diff --git a/src/AntCMS/AntCMS.php b/src/AntCMS/AntCMS.php index c5abf02..982ce90 100644 --- a/src/AntCMS/AntCMS.php +++ b/src/AntCMS/AntCMS.php @@ -8,7 +8,7 @@ class AntCMS { - protected $antTwig; + protected \AntCMS\AntTwig $antTwig; public function __construct() { @@ -21,17 +21,17 @@ public function __construct() * @param string $page The name of the page to be rendered * @return string The rendered HTML of the page */ - public function renderPage(string $page) + public function renderPage(string $page): string { $start_time = hrtime(true); $content = $this->getPage($page); - $themeConfig = Self::getThemeConfig(); + $themeConfig = self::getThemeConfig(); if (!$content || !is_array($content)) { $this->renderException("404"); } - $pageTemplate = $this->getPageLayout(null, $page, $content['template']); + $pageTemplate = static::getPageLayout(null, $page, $content['template']); $params = [ 'AntCMSTitle' => $content['title'], @@ -54,12 +54,12 @@ public function renderPage(string $page) /** * Returns the default layout of the active theme unless otherwise specified. - * + * * @param string|null $theme optional - the theme to get the page layout for. * @param string $currentPage optional - What page is the active page. * @return string the default page layout */ - public static function getPageLayout(string $theme = null, string $currentPage = '', string | null $template = null) + public static function getPageLayout(string $theme = null, string $currentPage = '', string | null $template = null): string { $layout = empty($template) ? 'default' : $template; $pageTemplate = self::getThemeTemplate($layout, $theme); @@ -68,13 +68,13 @@ public static function getPageLayout(string $theme = null, string $currentPage = /** * Render an exception page with the provided exception code. - * + * * @param string $exceptionCode The exception code to be displayed on the error page * @param int $httpCode The HTTP response code to return, 404 by default. - * @param string $exceptionString An optional parameter to define a custom string to be displayed along side the exception. - * @return never + * @param string $exceptionString An optional parameter to define a custom string to be displayed along side the exception. + * @return never */ - public function renderException(string $exceptionCode, int $httpCode = 404, string $exceptionString = 'That request caused an exception to be thrown.') + public function renderException(string $exceptionCode, int $httpCode = 404, string $exceptionString = 'That request caused an exception to be thrown.'): void { $exceptionString .= " (Code {$exceptionCode})"; $pageTemplate = self::getPageLayout(); @@ -95,10 +95,10 @@ public function renderException(string $exceptionCode, int $httpCode = 404, stri exit; } - /** - * @return array|false + /** + * @return array|false */ - public function getPage(string $page) + public function getPage(string $page): array|false { $page = strtolower($page); $pagePath = AntTools::convertFunctionaltoFullpath($page); @@ -118,11 +118,10 @@ public function getPage(string $page) } } - /** - * @param string|null $theme - * @return string + /** + * @param string|null $theme */ - public static function getThemeTemplate(string $layout = 'default', string $theme = null) + public static function getThemeTemplate(string $layout = 'default', string $theme = null): string { $theme ??= AntConfig::currentConfig('activeTheme'); @@ -132,7 +131,7 @@ public static function getThemeTemplate(string $layout = 'default', string $them $basePath = AntTools::repairFilePath(antThemePath . DIRECTORY_SEPARATOR . $theme); - if (strpos($layout, '_') !== false) { + if (str_contains($layout, '_')) { $layoutPrefix = explode('_', $layout)[0]; $templatePath = $basePath . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . $layoutPrefix; $defaultTemplates = AntTools::repairFilePath(antThemePath . '/Default/Templates' . '/' . $layoutPrefix); @@ -175,10 +174,10 @@ public static function getThemeTemplate(string $layout = 'default', string $them return $template; } - /** - * @return array + /** + * @return array */ - public static function getPageHeaders(string $pageContent) + public static function getPageHeaders(string $pageContent): array { $pageHeaders = [ 'title' => 'AntCMS', @@ -220,10 +219,7 @@ public static function getSiteInfo() return AntConfig::currentConfig('siteInfo'); } - /** - * @return void - */ - public function serveContent(string $path) + public function serveContent(string $path): void { if (!file_exists($path)) { $this->renderException('404'); @@ -235,7 +231,7 @@ public function serveContent(string $path) exit; } - public static function redirect(string $url) + public static function redirect(string $url): void { $url = '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . $url); header("Location: $url"); @@ -244,7 +240,7 @@ public static function redirect(string $url) public static function getThemeConfig(string|null $theme = null) { - $theme = $theme ?? AntConfig::currentConfig('activeTheme'); + $theme ??= AntConfig::currentConfig('activeTheme'); if (!is_dir(antThemePath . '/' . $theme)) { $theme = 'Default'; diff --git a/src/AntCMS/AntCache.php b/src/AntCMS/AntCache.php index 1d8ebd0..f4df818 100644 --- a/src/AntCMS/AntCache.php +++ b/src/AntCMS/AntCache.php @@ -17,7 +17,7 @@ class AntCache */ public function __construct(null|string $mode = null) { - $mode = $mode ?? AntConfig::currentConfig('cacheMode') ?? 'auto'; + $mode ??= AntConfig::currentConfig('cacheMode') ?? 'auto'; if ($mode == 'auto') { if (extension_loaded('apcu') && apcu_enabled()) { $mode = 'apcu'; @@ -26,19 +26,12 @@ public function __construct(null|string $mode = null) } } - switch ($mode) { - case 'none': - $this->CacheInterface = new ArrayAdapter(0, true, 0, 150); - break; - case 'filesystem': - $this->CacheInterface = new FilesystemAdapter('', self::$defaultLifespan, AntCachePath); - break; - case 'apcu': - $this->CacheInterface = new ApcuAdapter('AntCMS_' . hash('md5', __DIR__), self::$defaultLifespan); - break; - default: - throw new \Exception("Invalid cache type. Must be 'auto', 'filesystem', 'apcu', or 'none'."); - } + $this->CacheInterface = match ($mode) { + 'none' => new ArrayAdapter(0, true, 0, 150), + 'filesystem' => new FilesystemAdapter('', self::$defaultLifespan, AntCachePath), + 'apcu' => new ApcuAdapter('AntCMS_' . hash('md5', __DIR__), self::$defaultLifespan), + default => throw new \Exception("Invalid cache type. Must be 'auto', 'filesystem', 'apcu', or 'none'."), + }; } public function __call(string $name, array $arguments): mixed @@ -53,12 +46,12 @@ public function __call(string $name, array $arguments): mixed /** * Generates a unique cache key for the associated content and a salt value. * The salt is used to ensure that each cache key is unique to each component, even if multiple components are using the same source content but caching different results. - * + * * @param string $content The content to generate a cache key for. * @param string $salt An optional salt value to use in the cache key generation. Default is 'cache'. * @return string The generated cache key. */ - public function createCacheKey(string $content, string $salt = 'cache') + public function createCacheKey(string $content, string $salt = 'cache'): string { return hash(self::getHashAlgo(), $content . $salt); } @@ -66,12 +59,12 @@ public function createCacheKey(string $content, string $salt = 'cache') /** * Generates a unique cache key for a file and a salt value. * The salt is used to ensure that each cache key is unique to each component, even if multiple components are using the same source content but caching different results. - * + * * @param string $filePath The file path to create a cache key for. * @param string $salt An optional salt value to use in the cache key generation. Default is 'cache'. * @return string The generated cache key. */ - public function createCacheKeyFile(string $filePath, string $salt = 'cache') + public function createCacheKeyFile(string $filePath, string $salt = 'cache'): string { return hash_file(self::getHashAlgo(), $filePath) . $salt; } diff --git a/src/AntCMS/AntConfig.php b/src/AntCMS/AntConfig.php index 602ef26..8c92128 100644 --- a/src/AntCMS/AntConfig.php +++ b/src/AntCMS/AntConfig.php @@ -7,7 +7,7 @@ class AntConfig { - private static $ConfigKeys = [ + private static array $ConfigKeys = [ 'siteInfo', 'forceHTTPS', 'activeTheme', @@ -19,9 +19,8 @@ class AntConfig /** * Generates the default config file and saves it. - * @return void */ - public static function generateConfig() + public static function generateConfig(): void { $defaultOptions = [ 'siteInfo' => [ @@ -37,12 +36,12 @@ public static function generateConfig() ] ]; - Self::saveConfig($defaultOptions); + self::saveConfig($defaultOptions); } /** * Retrieves the current configuration from the AntCMS config file. - * + * * @param string|null $key The key of the configuration item to retrieve. Use dot notation to specify nested keys. * @return mixed The configuration array or a specific value if the key is specified. */ @@ -59,9 +58,9 @@ public static function currentConfig(?string $key = null) } /** - * @param array $array - * @param array $keys - * @return mixed + * @param array $array + * @param array $keys + * @return mixed */ private static function getArrayValue(array $array, array $keys) { @@ -76,12 +75,11 @@ private static function getArrayValue(array $array, array $keys) /** * Saves the AntCMS configuration - * + * * @param array $config The config data to be saved. - * @return bool * @throws exception */ - public static function saveConfig(array $config) + public static function saveConfig(array $config): bool { foreach (self::$ConfigKeys as $ConfigKey) { if (!array_key_exists($ConfigKey, $config)) { diff --git a/src/AntCMS/AntMarkdown.php b/src/AntCMS/AntMarkdown.php index b4b44ed..5137064 100644 --- a/src/AntCMS/AntMarkdown.php +++ b/src/AntCMS/AntMarkdown.php @@ -21,8 +21,8 @@ class AntMarkdown { - /** - * @return string + /** + * @return string */ public static function renderMarkdown(string $md) { @@ -63,9 +63,7 @@ public static function renderMarkdown(string $md) $environment->addExtension(new DefaultAttributesExtension()); $markdownConverter = new MarkdownConverter($environment); - - $renderedContent = $markdownConverter->convert($md); - return $renderedContent; + return $markdownConverter->convert($md); }); } } diff --git a/src/AntCMS/AntPages.php b/src/AntCMS/AntPages.php index d451ce0..54911df 100644 --- a/src/AntCMS/AntPages.php +++ b/src/AntCMS/AntPages.php @@ -12,11 +12,10 @@ class AntPages { - /** @return void */ - public static function generatePages() + public static function generatePages(): void { $pages = AntTools::getFileList(antContentPath, 'md', true); - $pageList = array(); + $pageList = []; foreach ($pages as $page) { $page = AntTools::repairFilePath($page); @@ -35,14 +34,9 @@ public static function generatePages() $pageFunctionalPath = substr($pageFunctionalPath, 0, -5); } - $currentPage = array( - 'pageTitle' => $pageHeader['title'], - 'fullPagePath' => $page, - 'functionalPagePath' => ($pageFunctionalPath == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : rtrim($pageFunctionalPath, DIRECTORY_SEPARATOR), - 'showInNav' => true, - ); + $currentPage = ['pageTitle' => $pageHeader['title'], 'fullPagePath' => $page, 'functionalPagePath' => ($pageFunctionalPath == DIRECTORY_SEPARATOR) ? DIRECTORY_SEPARATOR : rtrim($pageFunctionalPath, DIRECTORY_SEPARATOR), 'showInNav' => true]; - // Move the index page to the first item in the page list, so it appears as the first item in the navbar. + // Move the index page to the first item in the page list, so it appears as the first item in the navbar. if ($pageFunctionalPath == DIRECTORY_SEPARATOR) { array_unshift($pageList, $currentPage); } else { @@ -64,7 +58,7 @@ public static function getPages(): array public static function generateNavigation(string $navTemplate = '', string $currentPage = ''): string { $pages = AntPages::getPages(); - $antCache = new AntCache; + $antCache = new AntCache(); $theme = AntConfig::currentConfig('activeTheme'); $cacheKey = $antCache->createCacheKey(json_encode($pages), $theme . $currentPage); @@ -77,15 +71,14 @@ public static function generateNavigation(string $navTemplate = '', string $curr $pages[$key]['url'] = $url; $pages[$key]['active'] = $currentPage == $page['functionalPagePath']; - //Remove pages that are hidden from the nav from the array before sending it to twig. + //Remove pages that are hidden from the nav from the array before sending it to twig. if (!(bool)$page['showInNav']) { unset($pages[$key]); } } $antTwig = new AntTwig(); - $navHTML = $antTwig->renderWithTiwg($navTemplate, array('pages' => $pages)); - return $navHTML; + return $antTwig->renderWithTiwg($navTemplate, ['pages' => $pages]); }); } } diff --git a/src/AntCMS/AntPlugin.php b/src/AntCMS/AntPlugin.php index 5049af6..27d2f3b 100644 --- a/src/AntCMS/AntPlugin.php +++ b/src/AntCMS/AntPlugin.php @@ -5,14 +5,13 @@ abstract class AntPlugin { /** - * @param array $route - * @return mixed + * @param array $route */ - public function handlePluginRoute(array $route) + public function handlePluginRoute(array $route): void { die("Plugin did not define a handlePluginRoute function"); } /** @return string */ - abstract function getName(); + abstract public function getName(); } diff --git a/src/AntCMS/AntPluginLoader.php b/src/AntCMS/AntPluginLoader.php index cf3d654..fc37064 100644 --- a/src/AntCMS/AntPluginLoader.php +++ b/src/AntCMS/AntPluginLoader.php @@ -7,9 +7,9 @@ class AntPluginLoader { /** @return array */ - public function loadPlugins() + public function loadPlugins(): array { - $plugins = array(); + $plugins = []; $files = AntTools::getFileList(antPluginPath, null, true); diff --git a/src/AntCMS/AntRouting.php b/src/AntCMS/AntRouting.php index 2d83f74..0731dd0 100644 --- a/src/AntCMS/AntRouting.php +++ b/src/AntCMS/AntRouting.php @@ -4,8 +4,6 @@ class AntRouting { - private string $baseUrl; - private string $requestUri; private array $uriExploded; private array $indexes = ['/', '/index.php', '/index.html', '', 'index.php', 'index.html']; @@ -14,11 +12,9 @@ class AntRouting * @param string $baseUrl The base site URL. Ex: domain.com * @param string $requestUri The current request URI. Ex: /page/example */ - public function __construct(string $baseUrl, string $requestUri) + public function __construct(private string $baseUrl, private string $requestUri) { - $this->baseUrl = $baseUrl; - $this->requestUri = $requestUri; - $this->setExplodedUri($requestUri); + $this->setExplodedUri($this->requestUri); } /** @@ -33,7 +29,7 @@ public function setRequestUri(string $requestUri): void /** * Used to add to the start of the request URI. Primarially used for plugin routing. * For example: this is used internally to rewrite /profile/edit to /plugin/profile/edit - * + * * @param string $append What to append to the start of the request URI. */ public function requestUriUnshift(string $append): void @@ -60,7 +56,7 @@ public function redirectHttps(): void /** * Used to check if the current request URI matches a specified route. * Supports using '*' as a wild-card. Ex: '/admin/*' will match '/admin/somthing' and '/admin' - * + * * @param string $uri The Route to compare against the current URI. */ public function checkMatch(string $uri): bool @@ -83,8 +79,8 @@ public function checkMatch(string $uri): bool return true; } - /** - * Attempts to detect what plugin is associated with the current URI and then routes to the matching one. + /** + * Attempts to detect what plugin is associated with the current URI and then routes to the matching one. */ public function routeToPlugin(): void { @@ -104,7 +100,7 @@ public function routeToPlugin(): void // plugin not found header("HTTP/1.0 404 Not Found"); - echo ("Error 404"); + echo("Error 404"); exit; } diff --git a/src/AntCMS/AntTools.php b/src/AntCMS/AntTools.php index 8f6c23f..e96a7da 100644 --- a/src/AntCMS/AntTools.php +++ b/src/AntCMS/AntTools.php @@ -4,14 +4,14 @@ class AntTools { - /** - * @return array + /** + * @return array */ - public static function getFileList(string $dir, ?string $extension = null, ?bool $returnPath = false) + public static function getFileList(string $dir, ?string $extension = null, ?bool $returnPath = false): array { $dir = new \RecursiveDirectoryIterator($dir); $iterator = new \RecursiveIteratorIterator($dir); - $files = array(); + $files = []; foreach ($iterator as $file) { if (pathinfo($file, PATHINFO_EXTENSION) == $extension || $extension == null) { $files[] = ($returnPath) ? $file->getPathname() : $file->getFilename(); @@ -21,10 +21,7 @@ public static function getFileList(string $dir, ?string $extension = null, ?bool return $files; } - /** - * @return string - */ - public static function repairFilePath(string $path) + public static function repairFilePath(string $path): string { $newPath = realpath($path); if (!$newPath) { @@ -43,7 +40,7 @@ public static function repairFilePath(string $path) * @param string $url The URL to repair. Note: this function will not work correctly if the URL provided has its own protocol (like HTTS://). * @return string The repaired URL */ - public static function repairURL(string $url) + public static function repairURL(string $url): string { $newURL = str_replace('\\\\', '/', $url); $newURL = str_replace('\\', '/', $newURL); @@ -51,7 +48,7 @@ public static function repairURL(string $url) return str_replace('//', '/', $newURL); } - public static function convertFunctionaltoFullpath(string $path) + public static function convertFunctionaltoFullpath(string $path): string { $pagePath = AntTools::repairFilePath(antContentPath . '/' . $path); @@ -66,7 +63,7 @@ public static function convertFunctionaltoFullpath(string $path) return AntTools::repairFilePath($pagePath); } - public static function valuesNotNull(array $required, array $actual) + public static function valuesNotNull(array $required, array $actual): bool { foreach ($required as $key) { if (!key_exists($key, $actual) or is_null($actual[$key])) { diff --git a/src/AntCMS/AntTwig.php b/src/AntCMS/AntTwig.php index 0dcc9cc..f2ce579 100644 --- a/src/AntCMS/AntTwig.php +++ b/src/AntCMS/AntTwig.php @@ -6,7 +6,7 @@ class AntTwig { - protected $twigEnvironment; + protected \Twig\Environment $twigEnvironment; protected $theme; public function __construct(string $theme = null) @@ -23,10 +23,10 @@ public function __construct(string $theme = null) 'debug' => AntConfig::currentConfig('debug'), ]); - $this->twigEnvironment->addExtension(new \AntCMS\AntTwigFilters); + $this->twigEnvironment->addExtension(new \AntCMS\AntTwigFilters()); } - public function renderWithSubLayout(string $layout, array $params = array()) + public function renderWithSubLayout(string $layout, array $params = []): string { $subLayout = AntCMS::getThemeTemplate($layout, $this->theme); $mainLayout = AntCMS::getPageLayout($this->theme); @@ -38,7 +38,7 @@ public function renderWithSubLayout(string $layout, array $params = array()) return $this->twigEnvironment->render($mainLayout, $params); } - public function renderWithTiwg(string $content = '', array $params = array()) + public function renderWithTiwg(string $content = '', array $params = []): string { $siteInfo = AntCMS::getSiteInfo(); $params['AntCMSSiteTitle'] = $siteInfo['siteTitle']; diff --git a/src/AntCMS/AntTwigFilters.php b/src/AntCMS/AntTwigFilters.php index 54f7f7b..e66c94c 100644 --- a/src/AntCMS/AntTwigFilters.php +++ b/src/AntCMS/AntTwigFilters.php @@ -9,7 +9,7 @@ class AntTwigFilters extends AbstractExtension { - public function getFilters() + public function getFilters(): array { return [ new TwigFilter('absUrl', [$this, 'absUrl']), diff --git a/src/AntCMS/AntUsers.php b/src/AntCMS/AntUsers.php index 00e7d8b..c38fba2 100644 --- a/src/AntCMS/AntUsers.php +++ b/src/AntCMS/AntUsers.php @@ -6,18 +6,17 @@ class AntUsers { public static function getUser($username) { - $users = Self::getUsers(); + $users = self::getUsers(); return $users[$username] ?? null; } /** This function is used to get all the info of a user that is safe to publicize. * Mostly intended to create an array that can be safely passed to twig and used to display user information on the page, such as their name. - * @param mixed $username - * @return array + * @return array */ - public static function getUserPublicalKeys($username) + public static function getUserPublicalKeys(mixed $username) { - $user = Self::getUser($username); + $user = self::getUser($username); if (is_null($user)) { return []; } @@ -34,13 +33,13 @@ public static function getUsers() } } - public static function addUser($data) + public static function addUser(array $data): bool { $data['username'] = trim($data['username']); $data['name'] = trim($data['name']); - Self::validateUsername($data['username']); + self::validateUsername($data['username']); - $users = Self::getUsers(); + $users = self::getUsers(); if (key_exists($data['username'], $users)) { return false; } @@ -57,7 +56,7 @@ public static function addUser($data) return AntYaml::saveFile(antUsersList, $users); } - public static function updateUser($username, $newData) + public static function updateUser($username, array $newData): bool { foreach ($newData as $key => $value) { if (empty($value)) { @@ -85,7 +84,7 @@ public static function updateUser($username, $newData) if (isset($newData['username'])) { $newData['username'] = trim($newData['username']); - Self::validateUsername($newData['username']); + self::validateUsername($newData['username']); if (key_exists($newData['username'], $users) && $newData['username'] !== $username) { throw new \Exception("Username is already taken."); } @@ -98,7 +97,7 @@ public static function updateUser($username, $newData) return AntYaml::saveFile(antUsersList, $users); } - public static function setupFirstUser($data) + public static function setupFirstUser(array $data): bool { if (file_exists(antUsersList)) { AntCMS::redirect('/'); @@ -106,7 +105,7 @@ public static function setupFirstUser($data) $data['username'] = trim($data['username']); $data['name'] = trim($data['name']); - Self::validateUsername($data['username']); + self::validateUsername($data['username']); $users = [ $data['username'] => [ @@ -119,7 +118,7 @@ public static function setupFirstUser($data) return AntYaml::saveFile(antUsersList, $users); } - private static function validateUsername($username) + private static function validateUsername($username): bool { $pattern = '/^[\p{L}\p{M}*0-9]+$/u'; if (!preg_match($pattern, $username)) { diff --git a/src/AntCMS/AntYaml.php b/src/AntCMS/AntYaml.php index 9000d77..8773d2c 100644 --- a/src/AntCMS/AntYaml.php +++ b/src/AntCMS/AntYaml.php @@ -23,8 +23,8 @@ public static function parseFile(string $file, bool $fileCache = false): array }); } - /** - * @param array $data + /** + * @param array $data */ public static function saveFile(string $file, array $data): bool { @@ -32,8 +32,8 @@ public static function saveFile(string $file, array $data): bool return (bool) file_put_contents($file, $yaml); } - /** - * @return array|null + /** + * @return array|null */ public static function parseYaml(string $yaml): ?array { diff --git a/src/Bootstrap.php b/src/Bootstrap.php new file mode 100644 index 0000000..6315ebd --- /dev/null +++ b/src/Bootstrap.php @@ -0,0 +1,24 @@ + $classMapPath]); +$loader->addNamespace('AntCMS\\', __DIR__ . DIRECTORY_SEPARATOR . 'AntCMS'); +$loader->addNamespace('Plugins\\', __DIR__ . DIRECTORY_SEPARATOR . 'Plugins'); + +$loader->checkClassMap(); +$loader->register(); diff --git a/src/Constants.php b/src/Constants.php deleted file mode 100644 index d59359b..0000000 --- a/src/Constants.php +++ /dev/null @@ -1,13 +0,0 @@ - $route - * @return void + * @param array $route */ - public function handlePluginRoute(array $route) + public function handlePluginRoute(array $route): void { $currentStep = $route[0] ?? 'none'; - $this->auth = new AntAuth; + $this->auth = new AntAuth(); $this->auth->checkAuth(); - $this->antCMS = new AntCMS; + $this->antCMS = new AntCMS(); $this->AntTwig = new AntTwig(); array_shift($route); @@ -41,12 +40,15 @@ public function handlePluginRoute(array $route) case 'config': $this->configureAntCMS($route); + // no break case 'pages': $this->managePages($route); + // no break case 'users': $this->userManagement($route); + // no break default: $params = [ 'AntCMSTitle' => 'AntCMS Admin Dashboard', @@ -62,10 +64,10 @@ public function handlePluginRoute(array $route) } /** - * @param array $route - * @return never + * @param array $route + * @return never */ - private function configureAntCMS(array $route) + private function configureAntCMS(array $route): void { if ($this->auth->getRole() != 'admin') { $this->antCMS->renderException("You are not permitted to visit this page."); @@ -73,12 +75,7 @@ private function configureAntCMS(array $route) $currentConfig = AntConfig::currentConfig(); $currentConfigFile = file_get_contents(antConfigFile); - $params = array( - 'AntCMSTitle' => 'AntCMS Configuration', - 'AntCMSDescription' => 'The AntCMS configuration screen', - 'AntCMSAuthor' => 'AntCMS', - 'AntCMSKeywords' => '', - ); + $params = ['AntCMSTitle' => 'AntCMS Configuration', 'AntCMSDescription' => 'The AntCMS configuration screen', 'AntCMSAuthor' => 'AntCMS', 'AntCMSKeywords' => '']; switch ($route[0] ?? 'none') { case 'edit': @@ -112,7 +109,7 @@ private function configureAntCMS(array $route) $currentConfig[$key][$subkey] = implode(', ', $subvalue); } } - } else if (is_bool($value)) { + } elseif (is_bool($value)) { $currentConfig[$key] = ($value) ? 'true' : 'false'; } } @@ -125,18 +122,13 @@ private function configureAntCMS(array $route) } /** - * @param array $route - * @return never + * @param array $route + * @return never */ - private function managePages(array $route) + private function managePages(array $route): void { $pages = AntPages::getPages(); - $params = array( - 'AntCMSTitle' => 'AntCMS Page Management', - 'AntCMSDescription' => 'The AntCMS page management screen', - 'AntCMSAuthor' => 'AntCMS', - 'AntCMSKeywords' => '', - ); + $params = ['AntCMSTitle' => 'AntCMS Page Management', 'AntCMSDescription' => 'The AntCMS page management screen', 'AntCMSAuthor' => 'AntCMS', 'AntCMSKeywords' => '']; switch ($route[0] ?? 'none') { case 'regenerate': @@ -241,18 +233,13 @@ private function managePages(array $route) exit; } - private function userManagement(array $route) + private function userManagement(array $route): void { if ($this->auth->getRole() != 'admin') { $this->antCMS->renderException("You are not permitted to visit this page."); } - $params = array( - 'AntCMSTitle' => 'AntCMS User Management', - 'AntCMSDescription' => 'The AntCMS user management screen', - 'AntCMSAuthor' => 'AntCMS', - 'AntCMSKeywords' => '', - ); + $params = ['AntCMSTitle' => 'AntCMS User Management', 'AntCMSDescription' => 'The AntCMS user management screen', 'AntCMSAuthor' => 'AntCMS', 'AntCMSKeywords' => '']; switch ($route[0] ?? 'none') { case 'add': @@ -318,10 +305,7 @@ private function userManagement(array $route) exit; } - /** - * @return string - */ - private function boolToWord(bool $value) + private function boolToWord(bool $value): string { return $value ? 'true' : 'false'; } diff --git a/src/Plugins/Profile/ProfilePlugin.php b/src/Plugins/Profile/ProfilePlugin.php index 792df49..2e7a8cd 100644 --- a/src/Plugins/Profile/ProfilePlugin.php +++ b/src/Plugins/Profile/ProfilePlugin.php @@ -12,10 +12,10 @@ class ProfilePlugin extends AntPlugin protected $antTwig; - public function handlePluginRoute(array $route) + public function handlePluginRoute(array $route): void { - $this->antAuth = new AntAuth; - $this->antTwig = new AntTwig; + $this->antAuth = new AntAuth(); + $this->antTwig = new AntTwig(); $currentStep = $route[0] ?? 'none'; $params = [ diff --git a/src/Plugins/Robotstxt/RobotstxtPlugin.php b/src/Plugins/Robotstxt/RobotstxtPlugin.php index a451396..137755f 100644 --- a/src/Plugins/Robotstxt/RobotstxtPlugin.php +++ b/src/Plugins/Robotstxt/RobotstxtPlugin.php @@ -6,7 +6,7 @@ class RobotstxtPlugin extends AntPlugin { - public function handlePluginRoute(array $route) + public function handlePluginRoute(array $route): void { $protocol = AntConfig::currentConfig('forceHTTPS') ? 'https' : 'http'; $baseURL = AntConfig::currentConfig('baseURL'); diff --git a/src/Plugins/Sitemap/SitemapPlugin.php b/src/Plugins/Sitemap/SitemapPlugin.php index abf4d41..db10c0f 100644 --- a/src/Plugins/Sitemap/SitemapPlugin.php +++ b/src/Plugins/Sitemap/SitemapPlugin.php @@ -7,7 +7,7 @@ class SitemapPlugin extends AntPlugin { - public function handlePluginRoute(array $route) + public function handlePluginRoute(array $route): void { $protocol = AntConfig::currentConfig('forceHTTPS') ? 'https' : 'http'; $baseURL = AntConfig::currentConfig('baseURL'); @@ -22,7 +22,7 @@ public function handlePluginRoute(array $route) $domElement->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $domDocument->appendChild($domElement); - $urls = array(); + $urls = []; foreach ($pages as $key => $value) { $urls[$key]['url'] = $value['functionalPagePath']; $urls[$key]['lastchange'] = date('Y-m-d', filemtime($value['fullPagePath'])); diff --git a/src/index.php b/src/index.php index 2c22174..0af4d10 100644 --- a/src/index.php +++ b/src/index.php @@ -4,13 +4,7 @@ ini_set('display_errors', '1'); require_once __DIR__ . DIRECTORY_SEPARATOR . 'Vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; -require_once __DIR__ . DIRECTORY_SEPARATOR . 'Constants.php'; - -$classMapPath = __DIR__ . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR . 'classMap.php'; -$loader = new AntCMS\AntLoader(['path' => $classMapPath]); -$loader->addNamespace('AntCMS\\', __DIR__ . DIRECTORY_SEPARATOR . 'AntCMS'); -$loader->checkClassMap(); -$loader->register(); +require_once __DIR__ . DIRECTORY_SEPARATOR . 'Bootstrap.php'; use AntCMS\AntCMS; use AntCMS\AntConfig; diff --git a/tests/CMSTest.php b/tests/CMSTest.php index e01c8dd..ad33700 100644 --- a/tests/CMSTest.php +++ b/tests/CMSTest.php @@ -8,7 +8,7 @@ class CMSTest extends TestCase { - public function testgetSiteInfo() + public function testgetSiteInfo(): void { $siteInfo = AntCMS::getSiteInfo(); @@ -17,11 +17,11 @@ public function testgetSiteInfo() $this->assertEquals('AntCMS', $siteInfo['siteTitle']); } - public function testRenderPage() + public function testRenderPage(): void { AntPages::generatePages(); - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $pagePath = '/index.md'; $result = $antCMS->renderPage($pagePath); @@ -29,21 +29,21 @@ public function testRenderPage() $this->assertIsString($result); } - public function testGetPageLayout() + public function testGetPageLayout(): void { //We need to generate the Pages.yaml file so that the nav list can be generated. AntPages::generatePages(); - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $pageLayout = $antCMS->getPageLayout(); $this->assertNotEmpty($pageLayout); $this->assertIsString($pageLayout); } - public function testGetPage() + public function testGetPage(): void { - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $result = $antCMS->getPage('/index.md'); $this->assertNotEmpty($result); @@ -55,27 +55,27 @@ public function testGetPage() $this->assertArrayHasKey('keywords', $result); } - public function testGetPageFailed() + public function testGetPageFailed(): void { - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $result = $antCMS->getPage('/thisdoesnotexist.md'); $this->assertEquals(false, $result); $this->assertIsBool($result); } - public function testGetThemeTemplate() + public function testGetThemeTemplate(): void { - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $result = $antCMS->getThemeTemplate(); $this->assertNotEmpty($result); $this->assertIsString($result); } - public function testGetThemeTemplateFallback() + public function testGetThemeTemplateFallback(): void { - $antCMS = new AntCMS; + $antCMS = new AntCMS(); $result = $antCMS->getThemeTemplate('atemplatethatjusdoesntexist'); $this->assertNotEmpty($result); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index c3405a6..d2b7287 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -7,25 +7,18 @@ class ConfigTest extends TestCase { - public function testGetConfig() + public function testGetConfig(): void { $config = AntConfig::currentConfig(); - $expectedKeys = array( - 'siteInfo', - 'forceHTTPS', - 'activeTheme', - 'cacheMode', - 'debug', - 'baseURL' - ); + $expectedKeys = ['siteInfo', 'forceHTTPS', 'activeTheme', 'cacheMode', 'debug', 'baseURL']; foreach ($expectedKeys as $expectedKey) { $this->assertArrayHasKey($expectedKey, $config, "Expected key '{$expectedKey}' not found in config array"); } } - public function testSaveConfigFailed() + public function testSaveConfigFailed(): void { $Badconfig = [ 'cacheMode' => 'none', @@ -40,7 +33,7 @@ public function testSaveConfigFailed() $this->assertNotTrue($result); } - public function testSaveConfigPassed() + public function testSaveConfigPassed(): void { $currentConfig = AntConfig::currentConfig(); diff --git a/tests/Includes/Include.php b/tests/Includes/Include.php index 16ccd49..a6c9a0b 100644 --- a/tests/Includes/Include.php +++ b/tests/Includes/Include.php @@ -1,11 +1,6 @@ $classMapPath]); -$loader->addNamespace('AntCMS\\', $srcdir . DIRECTORY_SEPARATOR . 'AntCMS'); -$loader->checkClassMap(); -$loader->register(); +include_once $srcdir . DIRECTORY_SEPARATOR . 'Bootstrap.php'; diff --git a/tests/MarkdownTest.php b/tests/MarkdownTest.php index d688462..c80df85 100644 --- a/tests/MarkdownTest.php +++ b/tests/MarkdownTest.php @@ -9,13 +9,13 @@ class MarkdownTest extends TestCase { - public function testCanRenderMarkdown() + public function testCanRenderMarkdown(): void { $result = trim(AntMarkdown::renderMarkdown("# Test Content!")); $this->assertEquals('

Test Content!

', $result); } - public function testMarkdownIsFast() + public function testMarkdownIsFast(): void { $markdown = file_get_contents(antContentPath . DIRECTORY_SEPARATOR . 'index.md'); $totalTime = 0; @@ -34,15 +34,13 @@ public function testMarkdownIsFast() $averageTime = $totalTime / 10; - $callback = new Callback(static function ($averageTime) { - return $averageTime < 0.015; - }); + $callback = new Callback(static fn ($averageTime): bool => $averageTime < 0.015); $this->assertThat($averageTime, $callback, 'AntMarkdown::renderMarkdown took too long on average!'); } - public function testMarkdownCacheWorks() + public function testMarkdownCacheWorks(): void { $markdown = file_get_contents(antContentPath . DIRECTORY_SEPARATOR . 'index.md'); $currentConfig = AntConfig::currentConfig(); diff --git a/tests/PagesTest.php b/tests/PagesTest.php index 7e5a133..decd8c5 100644 --- a/tests/PagesTest.php +++ b/tests/PagesTest.php @@ -8,7 +8,7 @@ class PagesTest extends TestCase { - public function testGetGenerateAndGetPages() + public function testGetGenerateAndGetPages(): void { AntPages::generatePages(); $result = AntPages::getPages(); @@ -17,8 +17,9 @@ public function testGetGenerateAndGetPages() $this->assertIsArray($result); } - public function testGetNavigation(){ - $antCMS = new AntCMS; + public function testGetNavigation(): void + { + $antCMS = new AntCMS(); $pageTemplate = $antCMS->getThemeTemplate(); $navLayout = $antCMS->getThemeTemplate('nav'); diff --git a/tests/ToolsTest.php b/tests/ToolsTest.php index 50aae9a..c94f0e4 100644 --- a/tests/ToolsTest.php +++ b/tests/ToolsTest.php @@ -7,21 +7,10 @@ class ToolsTest extends TestCase { - public function testPathRepair() + public function testPathRepair(): void { - $badPaths = array( - "path/to/file", - "path\\to\\file", - "/path/to/file", - "C:\\path\\to\\file", - "~/path/to/file" - ); - $expectedPaths = array( - "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", - "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", - "C:" . DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", - "~" . DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file" - ); + $badPaths = ["path/to/file", "path\\to\\file", "/path/to/file", "C:\\path\\to\\file", "~/path/to/file"]; + $expectedPaths = ["path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", "C:" . DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file", "~" . DIRECTORY_SEPARATOR . "path" . DIRECTORY_SEPARATOR . "to" . DIRECTORY_SEPARATOR . "file"]; foreach ($badPaths as $index => $badPath) { @@ -30,24 +19,10 @@ public function testPathRepair() } } - public function testUrlRepair() + public function testUrlRepair(): void { - $badUrls = array( - "example.com\path", - "example.com/path/", - "example.com//path", - "example.com/path/to//file", - "example.com\path\\to\\file", - "example.com\path\\to\\file?download=yes" - ); - $expectedUrls = array( - "example.com/path", - "example.com/path/", - "example.com/path", - "example.com/path/to/file", - "example.com/path/to/file", - "example.com/path/to/file?download=yes" - ); + $badUrls = ["example.com\path", "example.com/path/", "example.com//path", "example.com/path/to//file", "example.com\path\\to\\file", "example.com\path\\to\\file?download=yes"]; + $expectedUrls = ["example.com/path", "example.com/path/", "example.com/path", "example.com/path/to/file", "example.com/path/to/file", "example.com/path/to/file?download=yes"]; foreach ($badUrls as $index => $badurl) { @@ -56,7 +31,7 @@ public function testUrlRepair() } } - public function testGetFileList() + public function testGetFileList(): void { $basedir = dirname(__DIR__, 1); $srcdir = $basedir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Content'; @@ -66,7 +41,7 @@ public function testGetFileList() $this->assertNotEmpty($result); } - public function testGetFileListWithExtension() + public function testGetFileListWithExtension(): void { $basedir = dirname(__DIR__, 1); $srcdir = $basedir . DIRECTORY_SEPARATOR . 'src';