From ee8b8c0699c4e92ff5623b1c9f5902344b1cfc46 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" <51850998+paulbalandan@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:10:54 +0800 Subject: [PATCH 001/212] Use php-cs-fixer as coding style tool (#4770) --- .gitattributes | 1 + .github/workflows/test-phpunit.yml | 4 ++-- .gitignore | 2 ++ .php-cs-fixer.dist.php | 34 ++++++++++++++++++++++++++++++ admin/framework/composer.json | 6 +++--- composer.json | 4 ++-- utils/PhpCsFixer/CodeIgniter4.php | 26 +++++++++++++++++++++++ 7 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 .php-cs-fixer.dist.php create mode 100644 utils/PhpCsFixer/CodeIgniter4.php diff --git a/.gitattributes b/.gitattributes index 1a7b3deb77e8..bf0e1f766d96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -25,6 +25,7 @@ utils/ export-ignore rector.php export-ignore phpunit.xml.dist export-ignore phpstan.neon.dist export-ignore +.php-cs-fixer.dist.php export-ignore # The source user guide, either user_guide_src/ export-ignore diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index 1b547fb76884..9b9da589720f 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -122,7 +122,7 @@ jobs: - name: Install dependencies run: | composer update --ansi --no-interaction - composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan codeigniter4/codeigniter4-standard squizlabs/php_codesniffer + composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config php -r 'file_put_contents("vendor/laminas/laminas-zendframework-bridge/src/autoload.php", "");' env: COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} @@ -140,7 +140,7 @@ jobs: - if: github.repository_owner == 'codeigniter4' && matrix.php-versions == '7.4' name: Run Coveralls run: | - composer global require php-coveralls/php-coveralls:^2.4 + composer global require --ansi php-coveralls/php-coveralls:^2.4 php-coveralls --coverage_clover=build/logs/clover.xml -v env: COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index b769053b4a4b..74c6d0ce6c4f 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,5 @@ nb-configuration.xml /results/ /phpunit*.xml /.phpunit.*.cache + +/.php-cs-fixer.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 000000000000..d1680e4c635d --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,34 @@ +files() + ->in([ + __DIR__ . '/app', // @todo relocate when `header_comment` is enabled + __DIR__ . '/public', // @todo relocate when `header_comment` is enabled + __DIR__ . '/system', + __DIR__ . '/tests', + __DIR__ . '/utils', + ]) + ->exclude(['ThirdParty']) + ->notName('#Foobar.php$#') + ->append([ + __FILE__, + __DIR__ . '/rector.php', + __DIR__ . '/spark', + ]); + +$overrides = []; + +$options = [ + 'cacheFile' => 'build/.php-cs-fixer.cache', + 'finder' => $finder, +]; + +// @todo change to `forLibrary()` when `header_comment` is enabled +return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects(); diff --git a/admin/framework/composer.json b/admin/framework/composer.json index e5e88487cfe6..5e226ff38b42 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -15,12 +15,12 @@ "psr/log": "^1.1" }, "require-dev": { - "codeigniter4/codeigniter4-standard": "^1.0", "fakerphp/faker": "^1.9", + "friendsofphp/php-cs-fixer": "^3.0", "mikey179/vfsstream": "^1.6", + "nexusphp/cs-config": "^3.1", "phpunit/phpunit": "^9.1", - "predis/predis": "^1.1", - "squizlabs/php_codesniffer": "^3.3" + "predis/predis": "^1.1" }, "suggest": { "ext-fileinfo": "Improves mime type detection for files" diff --git a/composer.json b/composer.json index ef2e937e7dce..afefbb7b38fd 100644 --- a/composer.json +++ b/composer.json @@ -15,15 +15,15 @@ "psr/log": "^1.1" }, "require-dev": { - "codeigniter4/codeigniter4-standard": "^1.0", "fakerphp/faker": "^1.9", + "friendsofphp/php-cs-fixer": "^3.0", "mikey179/vfsstream": "^1.6", + "nexusphp/cs-config": "^3.1", "nexusphp/tachycardia": "^1.0", "phpstan/phpstan": "0.12.88", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1", "rector/rector": "0.11.8", - "squizlabs/php_codesniffer": "^3.3", "symplify/package-builder": "^9.3" }, "suggest": { diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php new file mode 100644 index 000000000000..96b03cd32f8b --- /dev/null +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -0,0 +1,26 @@ +name = 'CodeIgniter4 Revised Coding Standards'; + + $this->rules = []; + + $this->requiredPHPVersion = 70300; + + $this->autoActivateIsRiskyAllowed = true; + } +} From e04d17b390baa4f36918a277faad72b8436083fe Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" <51850998+paulbalandan@users.noreply.github.com> Date: Fri, 4 Jun 2021 22:51:52 +0800 Subject: [PATCH 002/212] Convert tabs to 4 spaces (#4771) --- .php-cs-fixer.dist.php | 35 +- admin/framework/composer.json | 90 +- admin/module/composer.json | 72 +- .../2020-02-22-222222_example_migration.php | 98 +- .../_support/Database/Seeds/ExampleSeeder.php | 62 +- .../tests/_support/DatabaseTestCase.php | 96 +- .../tests/_support/Libraries/ConfigReader.php | 8 +- .../tests/_support/Models/ExampleModel.php | 30 +- .../module/tests/_support/SessionTestCase.php | 40 +- .../tests/database/ExampleDatabaseTest.php | 52 +- .../tests/session/ExampleSessionTest.php | 20 +- admin/module/tests/unit/ExampleTest.php | 18 +- admin/starter/app/Config/Paths.php | 126 +- admin/starter/composer.json | 78 +- .../2020-02-22-222222_example_migration.php | 98 +- .../_support/Database/Seeds/ExampleSeeder.php | 62 +- .../tests/_support/DatabaseTestCase.php | 96 +- .../tests/_support/Libraries/ConfigReader.php | 6 +- .../tests/_support/Models/ExampleModel.php | 30 +- .../tests/_support/SessionTestCase.php | 40 +- .../tests/database/ExampleDatabaseTest.php | 52 +- .../tests/session/ExampleSessionTest.php | 20 +- admin/starter/tests/unit/HealthTest.php | 90 +- admin/userguide/composer.json | 2 +- app/Config/App.php | 912 +-- app/Config/Autoload.php | 124 +- app/Config/Cache.php | 286 +- app/Config/ContentSecurityPolicy.php | 298 +- app/Config/Cookie.php | 204 +- app/Config/Database.php | 152 +- app/Config/DocTypes.php | 52 +- app/Config/Email.php | 322 +- app/Config/Encryption.php | 98 +- app/Config/Events.php | 50 +- app/Config/Exceptions.php | 90 +- app/Config/Filters.php | 94 +- app/Config/Format.php | 130 +- app/Config/Generators.php | 60 +- app/Config/Honeypot.php | 60 +- app/Config/Images.php | 44 +- app/Config/Kint.php | 56 +- app/Config/Logger.php | 274 +- app/Config/Migrations.php | 88 +- app/Config/Mimes.php | 1024 +-- app/Config/Modules.php | 84 +- app/Config/Pager.php | 58 +- app/Config/Paths.php | 126 +- app/Config/Routes.php | 4 +- app/Config/Security.php | 160 +- app/Config/Services.php | 18 +- app/Config/Toolbar.php | 116 +- app/Config/UserAgents.php | 450 +- app/Config/Validation.php | 56 +- app/Config/View.php | 66 +- app/Controllers/BaseController.php | 60 +- app/Controllers/Home.php | 8 +- app/Views/errors/cli/error_exception.php | 92 +- app/Views/errors/html/error_exception.php | 64 +- composer.json | 134 +- rector.php | 104 +- spark | 8 +- system/API/ResponseTrait.php | 816 +- system/Autoloader/Autoloader.php | 628 +- system/Autoloader/FileLocator.php | 860 +- system/BaseModel.php | 3526 ++++----- system/CLI/BaseCommand.php | 458 +- system/CLI/CLI.php | 2282 +++--- system/CLI/CommandRunner.php | 108 +- system/CLI/Commands.php | 378 +- system/CLI/Console.php | 94 +- system/CLI/Exceptions/CLIException.php | 28 +- system/CLI/GeneratorTrait.php | 774 +- system/Cache/CacheFactory.php | 106 +- system/Cache/CacheInterface.php | 218 +- system/Cache/Exceptions/CacheException.php | 78 +- system/Cache/Handlers/BaseHandler.php | 150 +- system/Cache/Handlers/DummyHandler.php | 326 +- system/Cache/Handlers/FileHandler.php | 1050 +-- system/Cache/Handlers/MemcachedHandler.php | 704 +- system/Cache/Handlers/PredisHandler.php | 572 +- system/Cache/Handlers/RedisHandler.php | 656 +- system/Cache/Handlers/WincacheHandler.php | 384 +- system/CodeIgniter.php | 2184 ++--- system/Commands/Cache/ClearCache.php | 114 +- system/Commands/Cache/InfoCache.php | 116 +- system/Commands/Database/CreateDatabase.php | 288 +- system/Commands/Database/Migrate.php | 182 +- system/Commands/Database/MigrateRefresh.php | 122 +- system/Commands/Database/MigrateRollback.php | 192 +- system/Commands/Database/MigrateStatus.php | 304 +- system/Commands/Database/Seed.php | 114 +- system/Commands/Encryption/GenerateKey.php | 402 +- .../Commands/Generators/CommandGenerator.php | 208 +- .../Commands/Generators/ConfigGenerator.php | 144 +- .../Generators/ControllerGenerator.php | 244 +- .../Commands/Generators/EntityGenerator.php | 112 +- .../Commands/Generators/FilterGenerator.php | 112 +- system/Commands/Generators/MigrateCreate.php | 116 +- .../Generators/MigrationGenerator.php | 218 +- system/Commands/Generators/ModelGenerator.php | 230 +- .../Commands/Generators/ScaffoldGenerator.php | 212 +- .../Commands/Generators/SeederGenerator.php | 112 +- .../Generators/SessionMigrationGenerator.php | 188 +- .../Generators/ValidationGenerator.php | 112 +- system/Commands/Help.php | 114 +- .../Commands/Housekeeping/ClearDebugbar.php | 92 +- system/Commands/Housekeeping/ClearLogs.php | 124 +- system/Commands/ListCommands.php | 242 +- system/Commands/Server/Serve.php | 206 +- system/Commands/Server/rewrite.php | 4 +- system/Commands/Utilities/Environment.php | 290 +- system/Commands/Utilities/Namespaces.php | 126 +- system/Commands/Utilities/Routes.php | 164 +- system/Common.php | 2340 +++--- system/ComposerScripts.php | 298 +- system/Config/AutoloadConfig.php | 214 +- system/Config/BaseConfig.php | 368 +- system/Config/BaseService.php | 580 +- system/Config/Config.php | 60 +- system/Config/DotEnv.php | 522 +- system/Config/Factories.php | 648 +- system/Config/Factory.php | 44 +- system/Config/ForeignCharacters.php | 188 +- system/Config/Routes.php | 4 +- system/Config/Services.php | 1584 ++-- system/Config/View.php | 154 +- system/Controller.php | 316 +- system/Cookie/CloneableCookieInterface.php | 184 +- system/Cookie/Cookie.php | 1602 ++-- system/Cookie/CookieInterface.php | 358 +- system/Cookie/CookieStore.php | 556 +- system/Cookie/Exceptions/CookieException.php | 206 +- system/Database/BaseBuilder.php | 6992 ++++++++--------- system/Database/BaseConnection.php | 3730 ++++----- system/Database/BasePreparedQuery.php | 444 +- system/Database/BaseResult.php | 1228 +-- system/Database/BaseUtils.php | 744 +- system/Database/Config.php | 288 +- system/Database/ConnectionInterface.php | 366 +- system/Database/Database.php | 320 +- system/Database/Exceptions/DataException.php | 132 +- .../Database/Exceptions/DatabaseException.php | 12 +- system/Database/Forge.php | 2612 +++--- system/Database/Migration.php | 100 +- system/Database/MigrationRunner.php | 2084 ++--- system/Database/ModelFactory.php | 60 +- system/Database/MySQLi/Builder.php | 70 +- system/Database/MySQLi/Connection.php | 1354 ++-- system/Database/MySQLi/Forge.php | 468 +- system/Database/MySQLi/PreparedQuery.php | 140 +- system/Database/MySQLi/Result.php | 344 +- system/Database/MySQLi/Utils.php | 58 +- system/Database/Postgre/Builder.php | 814 +- system/Database/Postgre/Connection.php | 1178 +-- system/Database/Postgre/Forge.php | 424 +- system/Database/Postgre/PreparedQuery.php | 194 +- system/Database/Postgre/Result.php | 274 +- system/Database/Postgre/Utils.php | 58 +- system/Database/PreparedQueryInterface.php | 94 +- system/Database/Query.php | 960 +-- system/Database/QueryInterface.php | 212 +- system/Database/ResultInterface.php | 432 +- system/Database/SQLSRV/Builder.php | 1492 ++-- system/Database/SQLSRV/Connection.php | 1154 +-- system/Database/SQLSRV/Forge.php | 778 +- system/Database/SQLSRV/PreparedQuery.php | 206 +- system/Database/SQLSRV/Result.php | 344 +- system/Database/SQLSRV/Utils.php | 48 +- system/Database/SQLite3/Builder.php | 120 +- system/Database/SQLite3/Connection.php | 958 +-- system/Database/SQLite3/Forge.php | 560 +- system/Database/SQLite3/PreparedQuery.php | 148 +- system/Database/SQLite3/Result.php | 316 +- system/Database/SQLite3/Table.php | 752 +- system/Database/SQLite3/Utils.php | 38 +- system/Database/Seeder.php | 374 +- system/Debug/Exceptions.php | 1004 +-- system/Debug/Iterator.php | 220 +- system/Debug/Timer.php | 256 +- system/Debug/Toolbar.php | 944 +-- .../Toolbar/Collectors/BaseCollector.php | 528 +- system/Debug/Toolbar/Collectors/Config.php | 38 +- system/Debug/Toolbar/Collectors/Database.php | 360 +- system/Debug/Toolbar/Collectors/Events.php | 282 +- system/Debug/Toolbar/Collectors/Files.php | 206 +- system/Debug/Toolbar/Collectors/History.php | 272 +- system/Debug/Toolbar/Collectors/Logs.php | 178 +- system/Debug/Toolbar/Collectors/Routes.php | 306 +- system/Debug/Toolbar/Collectors/Timers.php | 96 +- system/Debug/Toolbar/Collectors/Views.php | 284 +- system/Debug/Toolbar/Views/toolbar.tpl.php | 4 +- system/Email/Email.php | 4918 ++++++------ system/Encryption/EncrypterInterface.php | 44 +- system/Encryption/Encryption.php | 336 +- .../Exceptions/EncryptionException.php | 118 +- system/Encryption/Handlers/BaseHandler.php | 120 +- system/Encryption/Handlers/OpenSSLHandler.php | 196 +- system/Encryption/Handlers/SodiumHandler.php | 252 +- system/Entity/Cast/ArrayCast.php | 36 +- system/Entity/Cast/BaseCast.php | 48 +- system/Entity/Cast/BooleanCast.php | 14 +- system/Entity/Cast/CSVCast.php | 28 +- system/Entity/Cast/CastInterface.php | 36 +- system/Entity/Cast/DatetimeCast.php | 58 +- system/Entity/Cast/FloatCast.php | 14 +- system/Entity/Cast/IntegerCast.php | 14 +- system/Entity/Cast/JsonCast.php | 88 +- system/Entity/Cast/ObjectCast.php | 14 +- system/Entity/Cast/StringCast.php | 14 +- system/Entity/Cast/TimestampCast.php | 24 +- system/Entity/Cast/URICast.php | 14 +- system/Entity/Entity.php | 1156 +-- system/Entity/Exceptions/CastException.php | 112 +- system/Events/Events.php | 574 +- system/Exceptions/CastException.php | 50 +- system/Exceptions/ConfigException.php | 22 +- system/Exceptions/DebugTraceableTrait.php | 40 +- system/Exceptions/DownloadException.php | 52 +- system/Exceptions/FrameworkException.php | 76 +- system/Exceptions/ModelException.php | 16 +- system/Exceptions/PageNotFoundException.php | 56 +- system/Files/Exceptions/FileException.php | 10 +- .../Exceptions/FileNotFoundException.php | 10 +- system/Files/File.php | 392 +- system/Filters/CSRF.php | 100 +- system/Filters/DebugToolbar.php | 54 +- system/Filters/Exceptions/FilterException.php | 46 +- system/Filters/FilterInterface.php | 62 +- system/Filters/Filters.php | 1154 +-- system/Filters/Honeypot.php | 62 +- system/Format/Exceptions/FormatException.php | 96 +- system/Format/Format.php | 102 +- system/Format/FormatterInterface.php | 16 +- system/Format/JSONFormatter.php | 42 +- system/Format/XMLFormatter.php | 146 +- system/HTTP/CLIRequest.php | 410 +- system/HTTP/CURLRequest.php | 1558 ++-- system/HTTP/ContentSecurityPolicy.php | 1566 ++-- system/HTTP/DownloadResponse.php | 714 +- system/HTTP/Exceptions/HTTPException.php | 456 +- system/HTTP/Files/FileCollection.php | 534 +- system/HTTP/Files/UploadedFile.php | 710 +- system/HTTP/Files/UploadedFileInterface.php | 298 +- system/HTTP/Header.php | 402 +- system/HTTP/IncomingRequest.php | 1626 ++-- system/HTTP/Message.php | 240 +- system/HTTP/MessageInterface.php | 164 +- system/HTTP/MessageTrait.php | 488 +- system/HTTP/Negotiate.php | 816 +- system/HTTP/RedirectResponse.php | 284 +- system/HTTP/Request.php | 252 +- system/HTTP/RequestInterface.php | 84 +- system/HTTP/RequestTrait.php | 710 +- system/HTTP/Response.php | 424 +- system/HTTP/ResponseInterface.php | 750 +- system/HTTP/ResponseTrait.php | 1518 ++-- system/HTTP/URI.php | 2448 +++--- system/HTTP/UserAgent.php | 908 +-- system/Helpers/array_helper.php | 418 +- system/Helpers/cookie_helper.php | 158 +- system/Helpers/date_helper.php | 92 +- system/Helpers/filesystem_helper.php | 952 +-- system/Helpers/form_helper.php | 1602 ++-- system/Helpers/html_helper.php | 1230 +-- system/Helpers/inflector_helper.php | 610 +- system/Helpers/number_helper.php | 504 +- system/Helpers/security_helper.php | 74 +- system/Helpers/test_helper.php | 46 +- system/Helpers/text_helper.php | 1448 ++-- system/Helpers/url_helper.php | 1134 +-- system/Helpers/xml_helper.php | 84 +- .../Honeypot/Exceptions/HoneypotException.php | 32 +- system/Honeypot/Honeypot.php | 170 +- system/I18n/Exceptions/I18nException.php | 170 +- system/I18n/Time.php | 2690 +++---- system/I18n/TimeDifference.php | 634 +- system/Images/Exceptions/ImageException.php | 80 +- system/Images/Handlers/BaseHandler.php | 1752 ++--- system/Images/Handlers/GDHandler.php | 1156 +-- system/Images/Handlers/ImageMagickHandler.php | 1008 +-- system/Images/Image.php | 248 +- system/Images/ImageHandlerInterface.php | 324 +- system/Language/Language.php | 608 +- system/Language/en/CLI.php | 68 +- system/Language/en/Cache.php | 8 +- system/Language/en/Cast.php | 18 +- system/Language/en/Core.php | 12 +- system/Language/en/Database.php | 32 +- system/Language/en/Email.php | 38 +- system/Language/en/Encryption.php | 12 +- system/Language/en/Fabricator.php | 6 +- system/Language/en/Files.php | 4 +- system/Language/en/Filters.php | 4 +- system/Language/en/Format.php | 8 +- system/Language/en/HTTP.php | 104 +- system/Language/en/Images.php | 40 +- system/Language/en/Log.php | 4 +- system/Language/en/Migrations.php | 80 +- system/Language/en/Number.php | 22 +- system/Language/en/Pager.php | 18 +- system/Language/en/RESTful.php | 2 +- system/Language/en/Router.php | 4 +- system/Language/en/Security.php | 6 +- system/Language/en/Session.php | 14 +- system/Language/en/Time.php | 38 +- system/Language/en/Validation.php | 110 +- system/Language/en/View.php | 12 +- system/Log/Exceptions/LogException.php | 16 +- system/Log/Handlers/BaseHandler.php | 124 +- system/Log/Handlers/ChromeLoggerHandler.php | 306 +- system/Log/Handlers/ErrorlogHandler.php | 124 +- system/Log/Handlers/FileHandler.php | 236 +- system/Log/Handlers/HandlerInterface.php | 74 +- system/Log/Logger.php | 958 +-- system/Model.php | 1700 ++-- system/Modules/Modules.php | 66 +- system/Pager/Exceptions/PagerException.php | 16 +- system/Pager/Pager.php | 1074 +-- system/Pager/PagerInterface.php | 358 +- system/Pager/PagerRenderer.php | 884 +-- system/Pager/Views/default_head.php | 4 +- system/RESTful/BaseResource.php | 96 +- system/RESTful/ResourceController.php | 172 +- system/RESTful/ResourcePresenter.php | 168 +- .../Router/Exceptions/RedirectException.php | 12 +- system/Router/Exceptions/RouterException.php | 84 +- system/Router/RouteCollection.php | 3206 ++++---- system/Router/RouteCollectionInterface.php | 438 +- system/Router/Router.php | 1480 ++-- system/Router/RouterInterface.php | 108 +- .../Security/Exceptions/SecurityException.php | 26 +- system/Security/Security.php | 868 +- system/Security/SecurityInterface.php | 130 +- .../Session/Exceptions/SessionException.php | 68 +- system/Session/Handlers/ArrayHandler.php | 200 +- system/Session/Handlers/BaseHandler.php | 334 +- system/Session/Handlers/DatabaseHandler.php | 756 +- system/Session/Handlers/FileHandler.php | 766 +- system/Session/Handlers/MemcachedHandler.php | 712 +- system/Session/Handlers/RedisHandler.php | 760 +- system/Session/Session.php | 1974 ++--- system/Session/SessionInterface.php | 406 +- system/Test/CIDatabaseTestCase.php | 2 +- system/Test/CIUnitTestCase.php | 1078 +-- system/Test/Constraints/SeeInDatabase.php | 232 +- system/Test/ControllerResponse.php | 136 +- system/Test/ControllerTestTrait.php | 570 +- system/Test/ControllerTester.php | 546 +- system/Test/DOMParser.php | 624 +- system/Test/DatabaseTestTrait.php | 684 +- system/Test/Fabricator.php | 1172 +-- system/Test/FeatureResponse.php | 8 +- system/Test/FeatureTestCase.php | 802 +- system/Test/FeatureTestTrait.php | 804 +- system/Test/FilterTestTrait.php | 510 +- system/Test/Filters/CITestStreamFilter.php | 58 +- system/Test/Interfaces/FabricatorModel.php | 96 +- system/Test/Mock/MockAppConfig.php | 62 +- system/Test/Mock/MockAutoload.php | 14 +- system/Test/Mock/MockBuilder.php | 8 +- system/Test/Mock/MockCLIConfig.php | 58 +- system/Test/Mock/MockCURLRequest.php | 52 +- system/Test/Mock/MockCache.php | 536 +- system/Test/Mock/MockCodeIgniter.php | 8 +- system/Test/Mock/MockCommon.php | 38 +- system/Test/Mock/MockConnection.php | 592 +- system/Test/Mock/MockEmail.php | 46 +- system/Test/Mock/MockEvents.php | 32 +- system/Test/Mock/MockFileLogger.php | 22 +- system/Test/Mock/MockIncomingRequest.php | 16 +- system/Test/Mock/MockLanguage.php | 90 +- system/Test/Mock/MockLogger.php | 174 +- system/Test/Mock/MockResourceController.php | 24 +- system/Test/Mock/MockResourcePresenter.php | 26 +- system/Test/Mock/MockResponse.php | 32 +- system/Test/Mock/MockResult.php | 204 +- system/Test/Mock/MockSecurity.php | 10 +- system/Test/Mock/MockSecurityConfig.php | 16 +- system/Test/Mock/MockServices.php | 30 +- system/Test/Mock/MockSession.php | 78 +- system/Test/Mock/MockTable.php | 18 +- system/Test/ReflectionHelper.php | 126 +- system/Test/TestLogger.php | 126 +- system/Test/TestResponse.php | 1052 +-- system/Test/bootstrap.php | 36 +- system/Throttle/Throttler.php | 330 +- system/Throttle/ThrottlerInterface.php | 54 +- system/Typography/Typography.php | 716 +- system/Validation/CreditCardRules.php | 522 +- .../Exceptions/ValidationException.php | 48 +- system/Validation/FileRules.php | 612 +- system/Validation/FormatRules.php | 714 +- system/Validation/Rules.php | 840 +- system/Validation/Validation.php | 1592 ++-- system/Validation/ValidationInterface.php | 232 +- system/View/Cell.php | 416 +- system/View/Exceptions/ViewException.php | 58 +- system/View/Filters.php | 620 +- system/View/Parser.php | 1632 ++-- system/View/Plugins.php | 242 +- system/View/RendererInterface.php | 116 +- system/View/Table.php | 1000 +-- system/View/View.php | 986 +-- system/bootstrap.php | 70 +- tests/_support/Autoloader/FatalLocator.php | 78 +- tests/_support/Autoloader/functions.php | 10 +- tests/_support/Cache/RestrictiveHandler.php | 8 +- tests/_support/Commands/AbstractInfo.php | 6 +- tests/_support/Commands/AppInfo.php | 46 +- tests/_support/Commands/InvalidCommand.php | 22 +- tests/_support/Commands/LanguageCommand.php | 60 +- tests/_support/Commands/ParamsReveal.php | 18 +- tests/_support/Commands/Unsuffixable.php | 104 +- tests/_support/Config/BadRegistrar.php | 8 +- tests/_support/Config/Registrar.php | 204 +- tests/_support/Config/Services.php | 42 +- tests/_support/Config/TestRegistrar.php | 28 +- tests/_support/Controllers/Hello.php | 8 +- tests/_support/Controllers/Popcorn.php | 106 +- .../20160428212500_Create_test_tables.php | 262 +- .../_support/Database/Seeds/AnotherSeeder.php | 18 +- .../_support/Database/Seeds/CITestSeeder.php | 268 +- tests/_support/Entity/Cast/CastBase64.php | 48 +- .../Entity/Cast/CastPassParameters.php | 24 +- tests/_support/Filters/Customfilter.php | 18 +- .../_support/Language/SecondMockLanguage.php | 32 +- tests/_support/Language/en/Foo.php | 2 +- tests/_support/Language/en/Language.php | 2 +- tests/_support/Language/en/Nested.php | 10 +- tests/_support/Log/Handlers/TestHandler.php | 82 +- .../2018-01-24-102301_Some_migration.php | 34 +- .../2018-01-24-102302_Another_migration.php | 42 +- tests/_support/Models/EntityModel.php | 20 +- tests/_support/Models/EventModel.php | 164 +- tests/_support/Models/FabricatorModel.php | 34 +- tests/_support/Models/JobModel.php | 20 +- tests/_support/Models/SecondaryModel.php | 18 +- tests/_support/Models/StringifyPkeyModel.php | 4 +- tests/_support/Models/UserModel.php | 26 +- tests/_support/Models/ValidErrorsModel.php | 36 +- tests/_support/Models/ValidModel.php | 42 +- .../Models/WithoutAutoIncrementModel.php | 14 +- tests/_support/Services.php | 96 +- tests/_support/SomeEntity.php | 8 +- tests/_support/Validation/TestRules.php | 12 +- tests/_support/View/SampleClass.php | 80 +- .../View/SampleClassWithInitController.php | 16 +- tests/system/API/ResponseTraitTest.php | 1056 +-- tests/system/Autoloader/AutoloaderTest.php | 476 +- tests/system/Autoloader/FileLocatorTest.php | 418 +- tests/system/CLI/CLITest.php | 926 +-- tests/system/CLI/CommandRunnerTest.php | 212 +- tests/system/CLI/ConsoleTest.php | 142 +- tests/system/Cache/CacheFactoryTest.php | 214 +- .../system/Cache/Handlers/BaseHandlerTest.php | 90 +- .../Cache/Handlers/DummyHandlerTest.php | 142 +- .../system/Cache/Handlers/FileHandlerTest.php | 678 +- .../Cache/Handlers/MemcachedHandlerTest.php | 334 +- .../Cache/Handlers/PredisHandlerTest.php | 336 +- .../Cache/Handlers/RedisHandlerTest.php | 360 +- tests/system/CodeIgniterTest.php | 838 +- tests/system/Commands/BaseCommandTest.php | 56 +- tests/system/Commands/ClearCacheTest.php | 54 +- tests/system/Commands/ClearDebugbarTest.php | 98 +- tests/system/Commands/ClearLogsTest.php | 106 +- .../system/Commands/CommandGeneratorTest.php | 220 +- tests/system/Commands/CommandTest.php | 382 +- tests/system/Commands/ConfigGeneratorTest.php | 60 +- .../Commands/ConfigurableSortImportsTest.php | 106 +- .../Commands/ControllerGeneratorTest.php | 120 +- tests/system/Commands/CreateDatabaseTest.php | 154 +- .../system/Commands/DatabaseCommandsTest.php | 166 +- tests/system/Commands/EntityGeneratorTest.php | 64 +- .../Commands/EnvironmentCommandTest.php | 152 +- tests/system/Commands/FilterGeneratorTest.php | 60 +- tests/system/Commands/GenerateKeyTest.php | 198 +- tests/system/Commands/GeneratorsTest.php | 182 +- tests/system/Commands/HelpCommandTest.php | 88 +- tests/system/Commands/InfoCacheTest.php | 122 +- .../Commands/MigrationGeneratorTest.php | 84 +- .../Commands/MigrationIntegrationTest.php | 96 +- tests/system/Commands/ModelGeneratorTest.php | 210 +- .../system/Commands/ScaffoldGeneratorTest.php | 322 +- tests/system/Commands/SeederGeneratorTest.php | 64 +- .../system/Commands/SessionsCommandsTest.php | 80 +- .../Commands/ValidationGeneratorTest.php | 64 +- tests/system/CommonFunctionsSendTest.php | 88 +- tests/system/CommonFunctionsTest.php | 968 +-- tests/system/CommonSingleServiceTest.php | 140 +- tests/system/Config/BaseConfigTest.php | 498 +- tests/system/Config/ConfigTest.php | 82 +- tests/system/Config/DotEnvTest.php | 426 +- tests/system/Config/FactoriesTest.php | 374 +- tests/system/Config/MimesTest.php | 142 +- tests/system/Config/ServicesTest.php | 750 +- tests/system/Config/fixtures/Encryption.php | 32 +- .../Config/fixtures/RegistrarConfig.php | 8 +- tests/system/Config/fixtures/SimpleConfig.php | 64 +- tests/system/ControllerTest.php | 308 +- tests/system/Cookie/CookieStoreTest.php | 220 +- tests/system/Cookie/CookieTest.php | 556 +- tests/system/Database/BaseConnectionTest.php | 266 +- tests/system/Database/BaseQueryTest.php | 582 +- tests/system/Database/Builder/AliasTest.php | 102 +- tests/system/Database/Builder/BaseTest.php | 56 +- tests/system/Database/Builder/CountTest.php | 128 +- tests/system/Database/Builder/DeleteTest.php | 70 +- .../system/Database/Builder/DistinctTest.php | 32 +- tests/system/Database/Builder/EmptyTest.php | 32 +- tests/system/Database/Builder/FromTest.php | 130 +- tests/system/Database/Builder/GetTest.php | 144 +- tests/system/Database/Builder/GroupTest.php | 728 +- tests/system/Database/Builder/InsertTest.php | 240 +- tests/system/Database/Builder/JoinTest.php | 118 +- tests/system/Database/Builder/LikeTest.php | 326 +- tests/system/Database/Builder/LimitTest.php | 64 +- tests/system/Database/Builder/OrderTest.php | 64 +- tests/system/Database/Builder/PrefixTest.php | 48 +- tests/system/Database/Builder/ReplaceTest.php | 48 +- tests/system/Database/Builder/SelectTest.php | 334 +- .../system/Database/Builder/TruncateTest.php | 30 +- tests/system/Database/Builder/UpdateTest.php | 536 +- tests/system/Database/Builder/WhereTest.php | 704 +- tests/system/Database/ConfigTest.php | 344 +- tests/system/Database/DatabaseSeederTest.php | 60 +- .../DatabaseTestCaseMigrationOnce1Test.php | 82 +- .../DatabaseTestCaseMigrationOnce2Test.php | 78 +- .../system/Database/DatabaseTestCaseTest.php | 96 +- tests/system/Database/Live/AliasTest.php | 24 +- tests/system/Database/Live/BadQueryTest.php | 82 +- tests/system/Database/Live/ConnectTest.php | 118 +- tests/system/Database/Live/CountTest.php | 60 +- tests/system/Database/Live/DEBugTest.php | 38 +- .../Live/DatabaseTestTraitCaseTest.php | 60 +- tests/system/Database/Live/DbUtilsTest.php | 294 +- tests/system/Database/Live/DeleteTest.php | 90 +- tests/system/Database/Live/EmptyTest.php | 30 +- tests/system/Database/Live/EscapeTest.php | 106 +- .../Database/Live/FabricatorLiveTest.php | 104 +- tests/system/Database/Live/ForgeTest.php | 1842 ++--- tests/system/Database/Live/FromTest.php | 42 +- tests/system/Database/Live/GetNumRowsTest.php | 72 +- tests/system/Database/Live/GetTest.php | 584 +- tests/system/Database/Live/GroupTest.php | 704 +- tests/system/Database/Live/IncrementTest.php | 78 +- tests/system/Database/Live/InsertTest.php | 154 +- tests/system/Database/Live/JoinTest.php | 32 +- tests/system/Database/Live/LikeTest.php | 188 +- tests/system/Database/Live/LimitTest.php | 64 +- tests/system/Database/Live/MetadataTest.php | 170 +- tests/system/Database/Live/OrderTest.php | 156 +- .../Database/Live/PreparedQueryTest.php | 154 +- tests/system/Database/Live/PretendTest.php | 36 +- .../Database/Live/SQLite/AlterTableTest.php | 502 +- tests/system/Database/Live/SelectTest.php | 264 +- tests/system/Database/Live/UpdateTest.php | 460 +- tests/system/Database/Live/WhereTest.php | 436 +- .../Database/Live/WriteTypeQueryTest.php | 308 +- .../Migrations/MigrationRunnerTest.php | 618 +- .../Database/Migrations/MigrationTest.php | 38 +- tests/system/Database/ModelFactoryTest.php | 74 +- tests/system/Debug/ExceptionsTest.php | 68 +- tests/system/Debug/TimerTest.php | 206 +- tests/system/DebugTraceableTraitTest.php | 20 +- tests/system/Email/EmailTest.php | 236 +- tests/system/Encryption/EncryptionTest.php | 260 +- .../Handlers/OpenSSLHandlerTest.php | 232 +- .../Encryption/Handlers/SodiumHandlerTest.php | 208 +- tests/system/EntityTest.php | 1988 ++--- tests/system/Events/EventsTest.php | 484 +- tests/system/Files/FileTest.php | 122 +- tests/system/Files/FileWithVfsTest.php | 262 +- tests/system/Filters/CSRFTest.php | 58 +- tests/system/Filters/DebugToolbarTest.php | 54 +- tests/system/Filters/FiltersTest.php | 2098 ++--- tests/system/Filters/HoneypotTest.php | 204 +- .../system/Filters/fixtures/GoogleCurious.php | 14 +- tests/system/Filters/fixtures/GoogleEmpty.php | 14 +- tests/system/Filters/fixtures/GoogleMe.php | 24 +- tests/system/Filters/fixtures/GoogleYou.php | 18 +- .../system/Filters/fixtures/InvalidClass.php | 10 +- tests/system/Filters/fixtures/Multiple1.php | 16 +- tests/system/Filters/fixtures/Multiple2.php | 16 +- tests/system/Filters/fixtures/Role.php | 56 +- tests/system/Format/FormatTest.php | 90 +- tests/system/Format/JSONFormatterTest.php | 74 +- tests/system/Format/XMLFormatterTest.php | 264 +- tests/system/HTTP/CLIRequestTest.php | 1232 +-- tests/system/HTTP/CURLRequestTest.php | 1616 ++-- .../system/HTTP/ContentSecurityPolicyTest.php | 1014 +-- tests/system/HTTP/DownloadResponseTest.php | 488 +- .../system/HTTP/Files/FileCollectionTest.php | 1764 ++--- tests/system/HTTP/Files/FileMovingTest.php | 562 +- tests/system/HTTP/HeaderTest.php | 294 +- .../HTTP/IncomingRequestDetectingTest.php | 292 +- tests/system/HTTP/IncomingRequestTest.php | 1342 ++-- tests/system/HTTP/MessageTest.php | 526 +- tests/system/HTTP/NegotiateTest.php | 340 +- tests/system/HTTP/RedirectResponseTest.php | 382 +- tests/system/HTTP/RequestTest.php | 1334 ++-- tests/system/HTTP/ResponseCookieTest.php | 576 +- tests/system/HTTP/ResponseSendTest.php | 242 +- tests/system/HTTP/ResponseTest.php | 852 +- tests/system/HTTP/URITest.php | 1822 ++--- tests/system/HTTP/UserAgentTest.php | 216 +- tests/system/Helpers/ArrayHelperTest.php | 878 +-- tests/system/Helpers/CookieHelperTest.php | 328 +- tests/system/Helpers/DateHelperTest.php | 34 +- tests/system/Helpers/FilesystemHelperTest.php | 1008 +-- tests/system/Helpers/FormHelperTest.php | 1508 ++-- tests/system/Helpers/HTMLHelperTest.php | 728 +- tests/system/Helpers/InflectorHelperTest.php | 592 +- tests/system/Helpers/NumberHelperTest.php | 236 +- tests/system/Helpers/SecurityHelperTest.php | 58 +- tests/system/Helpers/TextHelperTest.php | 710 +- .../Helpers/URLHelper/CurrentUrlTest.php | 588 +- .../system/Helpers/URLHelper/MiscUrlTest.php | 1656 ++-- .../system/Helpers/URLHelper/SiteUrlTest.php | 456 +- tests/system/Helpers/XMLHelperTest.php | 46 +- tests/system/HomeTest.php | 28 +- tests/system/Honeypot/HoneypotTest.php | 292 +- tests/system/I18n/TimeDifferenceTest.php | 472 +- tests/system/I18n/TimeTest.php | 1842 ++--- tests/system/Images/BaseHandlerTest.php | 194 +- tests/system/Images/GDHandlerTest.php | 868 +- .../system/Images/ImageMagickHandlerTest.php | 874 +-- tests/system/Images/ImageTest.php | 164 +- tests/system/Language/LanguageTest.php | 644 +- .../Log/Handlers/ChromeLoggerHandlerTest.php | 92 +- .../Log/Handlers/ErrorlogHandlerTest.php | 48 +- tests/system/Log/Handlers/FileHandlerTest.php | 140 +- tests/system/Log/LoggerTest.php | 554 +- tests/system/Models/CountAllModelTest.php | 174 +- tests/system/Models/DeleteModelTest.php | 378 +- tests/system/Models/EventsModelTest.php | 302 +- tests/system/Models/FindModelTest.php | 580 +- tests/system/Models/GeneralModelTest.php | 294 +- tests/system/Models/InsertModelTest.php | 532 +- tests/system/Models/LiveModelTestCase.php | 78 +- .../system/Models/MiscellaneousModelTest.php | 182 +- tests/system/Models/PaginateModelTest.php | 102 +- tests/system/Models/SaveModelTest.php | 582 +- tests/system/Models/UpdateModelTest.php | 702 +- tests/system/Models/ValidationModelTest.php | 642 +- tests/system/Pager/PagerRendererTest.php | 1284 +-- tests/system/Pager/PagerTest.php | 758 +- .../system/RESTful/ResourceControllerTest.php | 582 +- .../system/RESTful/ResourcePresenterTest.php | 504 +- tests/system/Router/RouteCollectionTest.php | 2490 +++--- tests/system/Router/RouterTest.php | 1172 +-- tests/system/Security/SecurityTest.php | 330 +- tests/system/Session/SessionTest.php | 1038 +-- tests/system/Test/BootstrapFCPATHTest.php | 140 +- tests/system/Test/ControllerTestTraitTest.php | 418 +- tests/system/Test/DOMParserTest.php | 564 +- tests/system/Test/FabricatorTest.php | 674 +- tests/system/Test/FeatureTestTraitTest.php | 716 +- tests/system/Test/FilterTestTraitTest.php | 148 +- tests/system/Test/ReflectionHelperTest.php | 146 +- tests/system/Test/TestCaseEmissionsTest.php | 128 +- tests/system/Test/TestCaseTest.php | 192 +- tests/system/Test/TestResponseTest.php | 840 +- tests/system/Throttle/ThrottleTest.php | 244 +- tests/system/Typography/TypographyTest.php | 240 +- .../system/Validation/CreditCardRulesTest.php | 2480 +++--- tests/system/Validation/FileRulesTest.php | 644 +- tests/system/Validation/FormatRulesTest.php | 2568 +++--- tests/system/Validation/RulesTest.php | 3194 ++++---- tests/system/Validation/ValidationTest.php | 1964 ++--- tests/system/View/CellTest.php | 498 +- tests/system/View/ParserFilterTest.php | 716 +- tests/system/View/ParserPluginTest.php | 218 +- tests/system/View/ParserTest.php | 1876 ++--- tests/system/View/TableTest.php | 1018 +-- tests/system/View/ViewTest.php | 564 +- ...onInstantiationViaNamedConstructorRule.php | 56 +- .../CheckUseStatementsAfterLicenseRule.php | 88 +- utils/PhpCsFixer/CodeIgniter4.php | 16 +- ...rictParameterToFunctionParameterRector.php | 92 +- ...moveErrorSuppressInTryCatchStmtsRector.php | 76 +- .../RemoveVarTagFromClassConstantRector.php | 60 +- ...nderscoreToCamelCaseVariableNameRector.php | 262 +- 682 files changed, 132204 insertions(+), 132201 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index d1680e4c635d..7e02b76a134e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -7,27 +7,28 @@ use Utils\PhpCsFixer\CodeIgniter4; $finder = Finder::create() - ->files() - ->in([ - __DIR__ . '/app', // @todo relocate when `header_comment` is enabled - __DIR__ . '/public', // @todo relocate when `header_comment` is enabled - __DIR__ . '/system', - __DIR__ . '/tests', - __DIR__ . '/utils', - ]) - ->exclude(['ThirdParty']) - ->notName('#Foobar.php$#') - ->append([ - __FILE__, - __DIR__ . '/rector.php', - __DIR__ . '/spark', - ]); + ->files() + ->in([ + __DIR__ . '/admin', // @todo relocate when `header_comment` is enabled + __DIR__ . '/app', // @todo relocate when `header_comment` is enabled + __DIR__ . '/public', // @todo relocate when `header_comment` is enabled + __DIR__ . '/system', + __DIR__ . '/tests', + __DIR__ . '/utils', + ]) + ->exclude(['ThirdParty']) + ->notName('#Foobar.php$#') + ->append([ + __FILE__, + __DIR__ . '/rector.php', + __DIR__ . '/spark', + ]); $overrides = []; $options = [ - 'cacheFile' => 'build/.php-cs-fixer.cache', - 'finder' => $finder, + 'cacheFile' => 'build/.php-cs-fixer.cache', + 'finder' => $finder, ]; // @todo change to `forLibrary()` when `header_comment` is enabled diff --git a/admin/framework/composer.json b/admin/framework/composer.json index 5e226ff38b42..b04834081fb7 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -1,47 +1,47 @@ { - "name": "codeigniter4/framework", - "type": "project", - "description": "The CodeIgniter framework v4", - "homepage": "https://codeigniter.com", - "license": "MIT", - "require": { - "php": "^7.3||^8.0", - "ext-curl": "*", - "ext-intl": "*", - "ext-json": "*", - "ext-mbstring": "*", - "kint-php/kint": "^3.3", - "laminas/laminas-escaper": "^2.6", - "psr/log": "^1.1" - }, - "require-dev": { - "fakerphp/faker": "^1.9", - "friendsofphp/php-cs-fixer": "^3.0", - "mikey179/vfsstream": "^1.6", - "nexusphp/cs-config": "^3.1", - "phpunit/phpunit": "^9.1", - "predis/predis": "^1.1" - }, - "suggest": { - "ext-fileinfo": "Improves mime type detection for files" - }, - "autoload": { - "psr-4": { - "CodeIgniter\\": "system/" - }, - "exclude-from-classmap": [ - "**/Database/Migrations/**" - ] - }, - "scripts": { - "post-update-cmd": [ - "CodeIgniter\\ComposerScripts::postUpdate" - ], - "test": "phpunit" - }, - "support": { - "forum": "http://forum.codeigniter.com/", - "source": "https://github.com/codeigniter4/CodeIgniter4", - "slack": "https://codeigniterchat.slack.com" - } + "name": "codeigniter4/framework", + "type": "project", + "description": "The CodeIgniter framework v4", + "homepage": "https://codeigniter.com", + "license": "MIT", + "require": { + "php": "^7.3 || ^8.0", + "ext-curl": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "kint-php/kint": "^3.3", + "laminas/laminas-escaper": "^2.6", + "psr/log": "^1.1" + }, + "require-dev": { + "fakerphp/faker": "^1.9", + "friendsofphp/php-cs-fixer": "^3.0", + "mikey179/vfsstream": "^1.6", + "nexusphp/cs-config": "^3.1", + "phpunit/phpunit": "^9.1", + "predis/predis": "^1.1" + }, + "suggest": { + "ext-fileinfo": "Improves mime type detection for files" + }, + "autoload": { + "psr-4": { + "CodeIgniter\\": "system/" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "scripts": { + "post-update-cmd": [ + "CodeIgniter\\ComposerScripts::postUpdate" + ], + "test": "phpunit" + }, + "support": { + "forum": "http://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + } } diff --git a/admin/module/composer.json b/admin/module/composer.json index f2b85c785ad8..70197a43010c 100644 --- a/admin/module/composer.json +++ b/admin/module/composer.json @@ -1,38 +1,38 @@ { - "name": "mydomain/mymodule", - "description": "CodeIgniter4 starter module", - "homepage": "https://codeigniter.com", - "license": "MIT", - "require": { - "php": "^7.3||^8.0" - }, - "require-dev": { - "codeigniter4/codeigniter4": "dev-develop", - "fakerphp/faker": "^1.9", - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^9.1" - }, - "suggest": { - "ext-fileinfo": "Improves mime type detection for files" - }, - "autoload-dev": { - "psr-4": { - "Tests\\Support\\": "tests/_support" - } - }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/codeigniter4/codeigniter4" - } - ], - "minimum-stability": "dev", - "scripts": { - "test": "phpunit" - }, - "support": { - "forum": "http://forum.codeigniter.com/", - "source": "https://github.com/codeigniter4/CodeIgniter4", - "slack": "https://codeigniterchat.slack.com" - } + "name": "mydomain/mymodule", + "description": "CodeIgniter4 starter module", + "homepage": "https://codeigniter.com", + "license": "MIT", + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "codeigniter4/codeigniter4": "dev-develop", + "fakerphp/faker": "^1.9", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.1" + }, + "suggest": { + "ext-fileinfo": "Improves mime type detection for files" + }, + "autoload-dev": { + "psr-4": { + "Tests\\Support\\": "tests/_support" + } + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/codeigniter4/codeigniter4" + } + ], + "minimum-stability": "dev", + "scripts": { + "test": "phpunit" + }, + "support": { + "forum": "http://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + } } diff --git a/admin/module/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php b/admin/module/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php index 1bfd4a33c171..557da5a090da 100644 --- a/admin/module/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php +++ b/admin/module/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php @@ -4,58 +4,58 @@ class ExampleMigration extends Migration { - protected $DBGroup = 'tests'; + protected $DBGroup = 'tests'; - public function up() - { - $fields = [ - 'name' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'uid' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'class' => [ - 'type' => 'varchar', - 'constraint' => 63, - ], - 'icon' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'summary' => [ - 'type' => 'varchar', - 'constraint' => 255, - ], - 'created_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - ]; + public function up() + { + $fields = [ + 'name' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'uid' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'class' => [ + 'type' => 'varchar', + 'constraint' => 63, + ], + 'icon' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'summary' => [ + 'type' => 'varchar', + 'constraint' => 255, + ], + 'created_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + 'deleted_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + ]; - $this->forge->addField('id'); - $this->forge->addField($fields); + $this->forge->addField('id'); + $this->forge->addField($fields); - $this->forge->addKey('name'); - $this->forge->addKey('uid'); - $this->forge->addKey(['deleted_at', 'id']); - $this->forge->addKey('created_at'); + $this->forge->addKey('name'); + $this->forge->addKey('uid'); + $this->forge->addKey(['deleted_at', 'id']); + $this->forge->addKey('created_at'); - $this->forge->createTable('factories'); - } + $this->forge->createTable('factories'); + } - public function down() - { - $this->forge->dropTable('factories'); - } + public function down() + { + $this->forge->dropTable('factories'); + } } diff --git a/admin/module/tests/_support/Database/Seeds/ExampleSeeder.php b/admin/module/tests/_support/Database/Seeds/ExampleSeeder.php index 1b14cedaa2dc..50452018a78d 100644 --- a/admin/module/tests/_support/Database/Seeds/ExampleSeeder.php +++ b/admin/module/tests/_support/Database/Seeds/ExampleSeeder.php @@ -4,37 +4,37 @@ class ExampleSeeder extends Seeder { - public function run() - { - $factories = [ - [ - 'name' => 'Test Factory', - 'uid' => 'test001', - 'class' => 'Factories\Tests\NewFactory', - 'icon' => 'fas fa-puzzle-piece', - 'summary' => 'Longer sample text for testing', - ], - [ - 'name' => 'Widget Factory', - 'uid' => 'widget', - 'class' => 'Factories\Tests\WidgetPlant', - 'icon' => 'fas fa-puzzle-piece', - 'summary' => 'Create widgets in your factory', - ], - [ - 'name' => 'Evil Factory', - 'uid' => 'evil-maker', - 'class' => 'Factories\Evil\MyFactory', - 'icon' => 'fas fa-book-dead', - 'summary' => 'Abandon all hope, ye who enter here', - ], - ]; + public function run() + { + $factories = [ + [ + 'name' => 'Test Factory', + 'uid' => 'test001', + 'class' => 'Factories\Tests\NewFactory', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Longer sample text for testing', + ], + [ + 'name' => 'Widget Factory', + 'uid' => 'widget', + 'class' => 'Factories\Tests\WidgetPlant', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Create widgets in your factory', + ], + [ + 'name' => 'Evil Factory', + 'uid' => 'evil-maker', + 'class' => 'Factories\Evil\MyFactory', + 'icon' => 'fas fa-book-dead', + 'summary' => 'Abandon all hope, ye who enter here', + ], + ]; - $builder = $this->db->table('factories'); + $builder = $this->db->table('factories'); - foreach ($factories as $factory) - { - $builder->insert($factory); - } - } + foreach ($factories as $factory) + { + $builder->insert($factory); + } + } } diff --git a/admin/module/tests/_support/DatabaseTestCase.php b/admin/module/tests/_support/DatabaseTestCase.php index 9eb8fb703e90..2adc3a100c5a 100644 --- a/admin/module/tests/_support/DatabaseTestCase.php +++ b/admin/module/tests/_support/DatabaseTestCase.php @@ -4,52 +4,52 @@ class DatabaseTestCase extends CIUnitTestCase { - use DatabaseTestTrait; - - /** - * Should the database be refreshed before each test? - * - * @var boolean - */ - protected $refresh = true; - - /** - * The seed file(s) used for all tests within this test case. - * Should be fully-namespaced or relative to $basePath - * - * @var string|array - */ - protected $seed = 'Tests\Support\Database\Seeds\ExampleSeeder'; - - /** - * The path to the seeds directory. - * Allows overriding the default application directories. - * - * @var string - */ - protected $basePath = SUPPORTPATH . 'Database/'; - - /** - * The namespace(s) to help us find the migration classes. - * Empty is equivalent to running `spark migrate -all`. - * Note that running "all" runs migrations in date order, - * but specifying namespaces runs them in namespace order (then date) - * - * @var string|array|null - */ - protected $namespace = 'Tests\Support'; - - public function setUp(): void - { - parent::setUp(); - - // Extra code to run before each test - } - - public function tearDown(): void - { - parent::tearDown(); - - // Extra code to run after each test - } + use DatabaseTestTrait; + + /** + * Should the database be refreshed before each test? + * + * @var boolean + */ + protected $refresh = true; + + /** + * The seed file(s) used for all tests within this test case. + * Should be fully-namespaced or relative to $basePath + * + * @var string|array + */ + protected $seed = 'Tests\Support\Database\Seeds\ExampleSeeder'; + + /** + * The path to the seeds directory. + * Allows overriding the default application directories. + * + * @var string + */ + protected $basePath = SUPPORTPATH . 'Database/'; + + /** + * The namespace(s) to help us find the migration classes. + * Empty is equivalent to running `spark migrate -all`. + * Note that running "all" runs migrations in date order, + * but specifying namespaces runs them in namespace order (then date) + * + * @var string|array|null + */ + protected $namespace = 'Tests\Support'; + + public function setUp(): void + { + parent::setUp(); + + // Extra code to run before each test + } + + public function tearDown(): void + { + parent::tearDown(); + + // Extra code to run after each test + } } diff --git a/admin/module/tests/_support/Libraries/ConfigReader.php b/admin/module/tests/_support/Libraries/ConfigReader.php index 600d6c3a3c29..e114907aa189 100644 --- a/admin/module/tests/_support/Libraries/ConfigReader.php +++ b/admin/module/tests/_support/Libraries/ConfigReader.php @@ -47,9 +47,9 @@ * loading external values. Used to read actual local values from * a config file. */ -class ConfigReader extends \App\Config\App +class ConfigReader extends \Config\App { - public function __construct() - { - } + public function __construct() + { + } } diff --git a/admin/module/tests/_support/Models/ExampleModel.php b/admin/module/tests/_support/Models/ExampleModel.php index e02aeec30b58..a2f9ea60061a 100644 --- a/admin/module/tests/_support/Models/ExampleModel.php +++ b/admin/module/tests/_support/Models/ExampleModel.php @@ -4,23 +4,23 @@ class ExampleModel extends Model { - protected $table = 'factories'; - protected $primaryKey = 'id'; + protected $table = 'factories'; + protected $primaryKey = 'id'; - protected $returnType = 'object'; - protected $useSoftDeletes = false; + protected $returnType = 'object'; + protected $useSoftDeletes = false; - protected $allowedFields = [ - 'name', - 'uid', - 'class', - 'icon', - 'summary', - ]; + protected $allowedFields = [ + 'name', + 'uid', + 'class', + 'icon', + 'summary', + ]; - protected $useTimestamps = true; + protected $useTimestamps = true; - protected $validationRules = []; - protected $validationMessages = []; - protected $skipValidation = false; + protected $validationRules = []; + protected $validationMessages = []; + protected $skipValidation = false; } diff --git a/admin/module/tests/_support/SessionTestCase.php b/admin/module/tests/_support/SessionTestCase.php index d3a5b43bccfa..c329a19d7f88 100644 --- a/admin/module/tests/_support/SessionTestCase.php +++ b/admin/module/tests/_support/SessionTestCase.php @@ -7,27 +7,27 @@ class SessionTestCase extends CIUnitTestCase { - /** - * @var SessionInterface - */ - protected $session; + /** + * @var SessionInterface + */ + protected $session; - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); - $this->mockSession(); - } + $this->mockSession(); + } - /** - * Pre-loads the mock session driver into $this->session. - * - * @var string - */ - protected function mockSession() - { - $config = config('App'); - $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config); - \Config\Services::injectMock('session', $this->session); - } + /** + * Pre-loads the mock session driver into $this->session. + * + * @var string + */ + protected function mockSession() + { + $config = config('App'); + $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config); + \Config\Services::injectMock('session', $this->session); + } } diff --git a/admin/module/tests/database/ExampleDatabaseTest.php b/admin/module/tests/database/ExampleDatabaseTest.php index 2de0b6ae01bf..5934961c1d78 100644 --- a/admin/module/tests/database/ExampleDatabaseTest.php +++ b/admin/module/tests/database/ExampleDatabaseTest.php @@ -4,39 +4,39 @@ class ExampleDatabaseTest extends \Tests\Support\DatabaseTestCase { - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); - // Extra code to run before each test - } + // Extra code to run before each test + } - public function testModelFindAll() - { - $model = new ExampleModel(); + public function testModelFindAll() + { + $model = new ExampleModel(); - // Get every row created by ExampleSeeder - $objects = $model->findAll(); + // Get every row created by ExampleSeeder + $objects = $model->findAll(); - // Make sure the count is as expected - $this->assertCount(3, $objects); - } + // Make sure the count is as expected + $this->assertCount(3, $objects); + } - public function testSoftDeleteLeavesRow() - { - $model = new ExampleModel(); - $this->setPrivateProperty($model, 'useSoftDeletes', true); - $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); + public function testSoftDeleteLeavesRow() + { + $model = new ExampleModel(); + $this->setPrivateProperty($model, 'useSoftDeletes', true); + $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); - $object = $model->first(); - $model->delete($object->id); + $object = $model->first(); + $model->delete($object->id); - // The model should no longer find it - $this->assertNull($model->find($object->id)); + // The model should no longer find it + $this->assertNull($model->find($object->id)); - // ... but it should still be in the database - $result = $model->builder()->where('id', $object->id)->get()->getResult(); + // ... but it should still be in the database + $result = $model->builder()->where('id', $object->id)->get()->getResult(); - $this->assertCount(1, $result); - } + $this->assertCount(1, $result); + } } diff --git a/admin/module/tests/session/ExampleSessionTest.php b/admin/module/tests/session/ExampleSessionTest.php index 6ec0d011bd8d..b0a91214dea8 100644 --- a/admin/module/tests/session/ExampleSessionTest.php +++ b/admin/module/tests/session/ExampleSessionTest.php @@ -2,17 +2,17 @@ class ExampleSessionTest extends \Tests\Support\SessionTestCase { - public function setUp(): void - { - parent::setUp(); - } + public function setUp(): void + { + parent::setUp(); + } - public function testSessionSimple() - { - $this->session->set('logged_in', 123); + public function testSessionSimple() + { + $this->session->set('logged_in', 123); - $value = $this->session->get('logged_in'); + $value = $this->session->get('logged_in'); - $this->assertEquals(123, $value); - } + $this->assertEquals(123, $value); + } } diff --git a/admin/module/tests/unit/ExampleTest.php b/admin/module/tests/unit/ExampleTest.php index 2bab3125452f..042354ef3cac 100644 --- a/admin/module/tests/unit/ExampleTest.php +++ b/admin/module/tests/unit/ExampleTest.php @@ -2,15 +2,15 @@ class ExampleTest extends \CodeIgniter\Test\CIUnitTestCase { - public function setUp(): void - { - parent::setUp(); - } + public function setUp(): void + { + parent::setUp(); + } - public function testIsDefinedAppPath() - { - $test = defined('APPPATH'); + public function testIsDefinedAppPath() + { + $test = defined('APPPATH'); - $this->assertTrue($test); - } + $this->assertTrue($test); + } } diff --git a/admin/starter/app/Config/Paths.php b/admin/starter/app/Config/Paths.php index 007a6d328e97..5b9739ee5d0b 100644 --- a/admin/starter/app/Config/Paths.php +++ b/admin/starter/app/Config/Paths.php @@ -16,71 +16,71 @@ class Paths { - /** - * --------------------------------------------------------------- - * SYSTEM FOLDER NAME - * --------------------------------------------------------------- - * - * This must contain the name of your "system" folder. Include - * the path if the folder is not in the same directory as this file. - * - * @var string - */ - public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; + /** + * --------------------------------------------------------------- + * SYSTEM FOLDER NAME + * --------------------------------------------------------------- + * + * This must contain the name of your "system" folder. Include + * the path if the folder is not in the same directory as this file. + * + * @var string + */ + public $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system'; - /** - * --------------------------------------------------------------- - * APPLICATION FOLDER NAME - * --------------------------------------------------------------- - * - * If you want this front controller to use a different "app" - * folder than the default one you can set its name here. The folder - * can also be renamed or relocated anywhere on your getServer. If - * you do, use a full getServer path. - * - * @see http://codeigniter.com/user_guide/general/managing_apps.html - * - * @var string - */ - public $appDirectory = __DIR__ . '/..'; + /** + * --------------------------------------------------------------- + * APPLICATION FOLDER NAME + * --------------------------------------------------------------- + * + * If you want this front controller to use a different "app" + * folder than the default one you can set its name here. The folder + * can also be renamed or relocated anywhere on your getServer. If + * you do, use a full getServer path. + * + * @see http://codeigniter.com/user_guide/general/managing_apps.html + * + * @var string + */ + public $appDirectory = __DIR__ . '/..'; - /** - * --------------------------------------------------------------- - * WRITABLE DIRECTORY NAME - * --------------------------------------------------------------- - * - * This variable must contain the name of your "writable" directory. - * The writable directory allows you to group all directories that - * need write permission to a single place that can be tucked away - * for maximum security, keeping it out of the app and/or - * system directories. - * - * @var string - */ - public $writableDirectory = __DIR__ . '/../../writable'; + /** + * --------------------------------------------------------------- + * WRITABLE DIRECTORY NAME + * --------------------------------------------------------------- + * + * This variable must contain the name of your "writable" directory. + * The writable directory allows you to group all directories that + * need write permission to a single place that can be tucked away + * for maximum security, keeping it out of the app and/or + * system directories. + * + * @var string + */ + public $writableDirectory = __DIR__ . '/../../writable'; - /** - * --------------------------------------------------------------- - * TESTS DIRECTORY NAME - * --------------------------------------------------------------- - * - * This variable must contain the name of your "tests" directory. - * - * @var string - */ - public $testsDirectory = __DIR__ . '/../../tests'; + /** + * --------------------------------------------------------------- + * TESTS DIRECTORY NAME + * --------------------------------------------------------------- + * + * This variable must contain the name of your "tests" directory. + * + * @var string + */ + public $testsDirectory = __DIR__ . '/../../tests'; - /** - * --------------------------------------------------------------- - * VIEW DIRECTORY NAME - * --------------------------------------------------------------- - * - * This variable must contain the name of the directory that - * contains the view files used by your application. By - * default this is in `app/Views`. This value - * is used when no value is provided to `Services::renderer()`. - * - * @var string - */ - public $viewDirectory = __DIR__ . '/../Views'; + /** + * --------------------------------------------------------------- + * VIEW DIRECTORY NAME + * --------------------------------------------------------------- + * + * This variable must contain the name of the directory that + * contains the view files used by your application. By + * default this is in `app/Views`. This value + * is used when no value is provided to `Services::renderer()`. + * + * @var string + */ + public $viewDirectory = __DIR__ . '/../Views'; } diff --git a/admin/starter/composer.json b/admin/starter/composer.json index 63112d799057..9f7dc492cbc8 100644 --- a/admin/starter/composer.json +++ b/admin/starter/composer.json @@ -1,41 +1,41 @@ { - "name": "codeigniter4/appstarter", - "type": "project", - "description": "CodeIgniter4 starter app", - "homepage": "https://codeigniter.com", - "license": "MIT", - "require": { - "php": "^7.3||^8.0", - "codeigniter4/framework": "^4" - }, - "require-dev": { - "fakerphp/faker": "^1.9", - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^9.1" - }, - "suggest": { - "ext-fileinfo": "Improves mime type detection for files" - }, - "autoload": { - "psr-4": { - "App\\": "app", - "Config\\": "app/Config" - }, - "exclude-from-classmap": [ - "**/Database/Migrations/**" - ] - }, - "autoload-dev": { - "psr-4": { - "Tests\\Support\\": "tests/_support" - } - }, - "scripts": { - "test": "phpunit" - }, - "support": { - "forum": "http://forum.codeigniter.com/", - "source": "https://github.com/codeigniter4/CodeIgniter4", - "slack": "https://codeigniterchat.slack.com" - } + "name": "codeigniter4/appstarter", + "type": "project", + "description": "CodeIgniter4 starter app", + "homepage": "https://codeigniter.com", + "license": "MIT", + "require": { + "php": "^7.3 || ^8.0", + "codeigniter4/framework": "^4" + }, + "require-dev": { + "fakerphp/faker": "^1.9", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.1" + }, + "suggest": { + "ext-fileinfo": "Improves mime type detection for files" + }, + "autoload": { + "psr-4": { + "App\\": "app", + "Config\\": "app/Config" + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\Support\\": "tests/_support" + } + }, + "scripts": { + "test": "phpunit" + }, + "support": { + "forum": "http://forum.codeigniter.com/", + "source": "https://github.com/codeigniter4/CodeIgniter4", + "slack": "https://codeigniterchat.slack.com" + } } diff --git a/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php b/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php index 1bfd4a33c171..557da5a090da 100644 --- a/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php +++ b/admin/starter/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php @@ -4,58 +4,58 @@ class ExampleMigration extends Migration { - protected $DBGroup = 'tests'; + protected $DBGroup = 'tests'; - public function up() - { - $fields = [ - 'name' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'uid' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'class' => [ - 'type' => 'varchar', - 'constraint' => 63, - ], - 'icon' => [ - 'type' => 'varchar', - 'constraint' => 31, - ], - 'summary' => [ - 'type' => 'varchar', - 'constraint' => 255, - ], - 'created_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - 'updated_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - 'deleted_at' => [ - 'type' => 'datetime', - 'null' => true, - ], - ]; + public function up() + { + $fields = [ + 'name' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'uid' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'class' => [ + 'type' => 'varchar', + 'constraint' => 63, + ], + 'icon' => [ + 'type' => 'varchar', + 'constraint' => 31, + ], + 'summary' => [ + 'type' => 'varchar', + 'constraint' => 255, + ], + 'created_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + 'updated_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + 'deleted_at' => [ + 'type' => 'datetime', + 'null' => true, + ], + ]; - $this->forge->addField('id'); - $this->forge->addField($fields); + $this->forge->addField('id'); + $this->forge->addField($fields); - $this->forge->addKey('name'); - $this->forge->addKey('uid'); - $this->forge->addKey(['deleted_at', 'id']); - $this->forge->addKey('created_at'); + $this->forge->addKey('name'); + $this->forge->addKey('uid'); + $this->forge->addKey(['deleted_at', 'id']); + $this->forge->addKey('created_at'); - $this->forge->createTable('factories'); - } + $this->forge->createTable('factories'); + } - public function down() - { - $this->forge->dropTable('factories'); - } + public function down() + { + $this->forge->dropTable('factories'); + } } diff --git a/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php b/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php index 1b14cedaa2dc..50452018a78d 100644 --- a/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php +++ b/admin/starter/tests/_support/Database/Seeds/ExampleSeeder.php @@ -4,37 +4,37 @@ class ExampleSeeder extends Seeder { - public function run() - { - $factories = [ - [ - 'name' => 'Test Factory', - 'uid' => 'test001', - 'class' => 'Factories\Tests\NewFactory', - 'icon' => 'fas fa-puzzle-piece', - 'summary' => 'Longer sample text for testing', - ], - [ - 'name' => 'Widget Factory', - 'uid' => 'widget', - 'class' => 'Factories\Tests\WidgetPlant', - 'icon' => 'fas fa-puzzle-piece', - 'summary' => 'Create widgets in your factory', - ], - [ - 'name' => 'Evil Factory', - 'uid' => 'evil-maker', - 'class' => 'Factories\Evil\MyFactory', - 'icon' => 'fas fa-book-dead', - 'summary' => 'Abandon all hope, ye who enter here', - ], - ]; + public function run() + { + $factories = [ + [ + 'name' => 'Test Factory', + 'uid' => 'test001', + 'class' => 'Factories\Tests\NewFactory', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Longer sample text for testing', + ], + [ + 'name' => 'Widget Factory', + 'uid' => 'widget', + 'class' => 'Factories\Tests\WidgetPlant', + 'icon' => 'fas fa-puzzle-piece', + 'summary' => 'Create widgets in your factory', + ], + [ + 'name' => 'Evil Factory', + 'uid' => 'evil-maker', + 'class' => 'Factories\Evil\MyFactory', + 'icon' => 'fas fa-book-dead', + 'summary' => 'Abandon all hope, ye who enter here', + ], + ]; - $builder = $this->db->table('factories'); + $builder = $this->db->table('factories'); - foreach ($factories as $factory) - { - $builder->insert($factory); - } - } + foreach ($factories as $factory) + { + $builder->insert($factory); + } + } } diff --git a/admin/starter/tests/_support/DatabaseTestCase.php b/admin/starter/tests/_support/DatabaseTestCase.php index 42cbc6f5c1a0..24469d7fb518 100644 --- a/admin/starter/tests/_support/DatabaseTestCase.php +++ b/admin/starter/tests/_support/DatabaseTestCase.php @@ -5,52 +5,52 @@ class DatabaseTestCase extends CIUnitTestCase { - use DatabaseTestTrait; - - /** - * Should the database be refreshed before each test? - * - * @var boolean - */ - protected $refresh = true; - - /** - * The seed file(s) used for all tests within this test case. - * Should be fully-namespaced or relative to $basePath - * - * @var string|array - */ - protected $seed = 'Tests\Support\Database\Seeds\ExampleSeeder'; - - /** - * The path to the seeds directory. - * Allows overriding the default application directories. - * - * @var string - */ - protected $basePath = SUPPORTPATH . 'Database/'; - - /** - * The namespace(s) to help us find the migration classes. - * Empty is equivalent to running `spark migrate -all`. - * Note that running "all" runs migrations in date order, - * but specifying namespaces runs them in namespace order (then date) - * - * @var string|array|null - */ - protected $namespace = 'Tests\Support'; - - public function setUp(): void - { - parent::setUp(); - - // Extra code to run before each test - } - - public function tearDown(): void - { - parent::tearDown(); - - // Extra code to run after each test - } + use DatabaseTestTrait; + + /** + * Should the database be refreshed before each test? + * + * @var boolean + */ + protected $refresh = true; + + /** + * The seed file(s) used for all tests within this test case. + * Should be fully-namespaced or relative to $basePath + * + * @var string|array + */ + protected $seed = 'Tests\Support\Database\Seeds\ExampleSeeder'; + + /** + * The path to the seeds directory. + * Allows overriding the default application directories. + * + * @var string + */ + protected $basePath = SUPPORTPATH . 'Database/'; + + /** + * The namespace(s) to help us find the migration classes. + * Empty is equivalent to running `spark migrate -all`. + * Note that running "all" runs migrations in date order, + * but specifying namespaces runs them in namespace order (then date) + * + * @var string|array|null + */ + protected $namespace = 'Tests\Support'; + + public function setUp(): void + { + parent::setUp(); + + // Extra code to run before each test + } + + public function tearDown(): void + { + parent::tearDown(); + + // Extra code to run after each test + } } diff --git a/admin/starter/tests/_support/Libraries/ConfigReader.php b/admin/starter/tests/_support/Libraries/ConfigReader.php index 16765acbf2ba..e114907aa189 100644 --- a/admin/starter/tests/_support/Libraries/ConfigReader.php +++ b/admin/starter/tests/_support/Libraries/ConfigReader.php @@ -49,7 +49,7 @@ */ class ConfigReader extends \Config\App { - public function __construct() - { - } + public function __construct() + { + } } diff --git a/admin/starter/tests/_support/Models/ExampleModel.php b/admin/starter/tests/_support/Models/ExampleModel.php index e02aeec30b58..a2f9ea60061a 100644 --- a/admin/starter/tests/_support/Models/ExampleModel.php +++ b/admin/starter/tests/_support/Models/ExampleModel.php @@ -4,23 +4,23 @@ class ExampleModel extends Model { - protected $table = 'factories'; - protected $primaryKey = 'id'; + protected $table = 'factories'; + protected $primaryKey = 'id'; - protected $returnType = 'object'; - protected $useSoftDeletes = false; + protected $returnType = 'object'; + protected $useSoftDeletes = false; - protected $allowedFields = [ - 'name', - 'uid', - 'class', - 'icon', - 'summary', - ]; + protected $allowedFields = [ + 'name', + 'uid', + 'class', + 'icon', + 'summary', + ]; - protected $useTimestamps = true; + protected $useTimestamps = true; - protected $validationRules = []; - protected $validationMessages = []; - protected $skipValidation = false; + protected $validationRules = []; + protected $validationMessages = []; + protected $skipValidation = false; } diff --git a/admin/starter/tests/_support/SessionTestCase.php b/admin/starter/tests/_support/SessionTestCase.php index d3a5b43bccfa..c329a19d7f88 100644 --- a/admin/starter/tests/_support/SessionTestCase.php +++ b/admin/starter/tests/_support/SessionTestCase.php @@ -7,27 +7,27 @@ class SessionTestCase extends CIUnitTestCase { - /** - * @var SessionInterface - */ - protected $session; + /** + * @var SessionInterface + */ + protected $session; - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); - $this->mockSession(); - } + $this->mockSession(); + } - /** - * Pre-loads the mock session driver into $this->session. - * - * @var string - */ - protected function mockSession() - { - $config = config('App'); - $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config); - \Config\Services::injectMock('session', $this->session); - } + /** + * Pre-loads the mock session driver into $this->session. + * + * @var string + */ + protected function mockSession() + { + $config = config('App'); + $this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config); + \Config\Services::injectMock('session', $this->session); + } } diff --git a/admin/starter/tests/database/ExampleDatabaseTest.php b/admin/starter/tests/database/ExampleDatabaseTest.php index 2de0b6ae01bf..5934961c1d78 100644 --- a/admin/starter/tests/database/ExampleDatabaseTest.php +++ b/admin/starter/tests/database/ExampleDatabaseTest.php @@ -4,39 +4,39 @@ class ExampleDatabaseTest extends \Tests\Support\DatabaseTestCase { - public function setUp(): void - { - parent::setUp(); + public function setUp(): void + { + parent::setUp(); - // Extra code to run before each test - } + // Extra code to run before each test + } - public function testModelFindAll() - { - $model = new ExampleModel(); + public function testModelFindAll() + { + $model = new ExampleModel(); - // Get every row created by ExampleSeeder - $objects = $model->findAll(); + // Get every row created by ExampleSeeder + $objects = $model->findAll(); - // Make sure the count is as expected - $this->assertCount(3, $objects); - } + // Make sure the count is as expected + $this->assertCount(3, $objects); + } - public function testSoftDeleteLeavesRow() - { - $model = new ExampleModel(); - $this->setPrivateProperty($model, 'useSoftDeletes', true); - $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); + public function testSoftDeleteLeavesRow() + { + $model = new ExampleModel(); + $this->setPrivateProperty($model, 'useSoftDeletes', true); + $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); - $object = $model->first(); - $model->delete($object->id); + $object = $model->first(); + $model->delete($object->id); - // The model should no longer find it - $this->assertNull($model->find($object->id)); + // The model should no longer find it + $this->assertNull($model->find($object->id)); - // ... but it should still be in the database - $result = $model->builder()->where('id', $object->id)->get()->getResult(); + // ... but it should still be in the database + $result = $model->builder()->where('id', $object->id)->get()->getResult(); - $this->assertCount(1, $result); - } + $this->assertCount(1, $result); + } } diff --git a/admin/starter/tests/session/ExampleSessionTest.php b/admin/starter/tests/session/ExampleSessionTest.php index 6ec0d011bd8d..b0a91214dea8 100644 --- a/admin/starter/tests/session/ExampleSessionTest.php +++ b/admin/starter/tests/session/ExampleSessionTest.php @@ -2,17 +2,17 @@ class ExampleSessionTest extends \Tests\Support\SessionTestCase { - public function setUp(): void - { - parent::setUp(); - } + public function setUp(): void + { + parent::setUp(); + } - public function testSessionSimple() - { - $this->session->set('logged_in', 123); + public function testSessionSimple() + { + $this->session->set('logged_in', 123); - $value = $this->session->get('logged_in'); + $value = $this->session->get('logged_in'); - $this->assertEquals(123, $value); - } + $this->assertEquals(123, $value); + } } diff --git a/admin/starter/tests/unit/HealthTest.php b/admin/starter/tests/unit/HealthTest.php index d5e979afca4e..4779c3efc1f2 100644 --- a/admin/starter/tests/unit/HealthTest.php +++ b/admin/starter/tests/unit/HealthTest.php @@ -4,49 +4,49 @@ class HealthTest extends \CodeIgniter\Test\CIUnitTestCase { - public function setUp(): void - { - parent::setUp(); - } - - public function testIsDefinedAppPath() - { - $test = defined('APPPATH'); - - $this->assertTrue($test); - } - - public function testBaseUrlHasBeenSet() - { - $validation = Services::validation(); - $env = false; - - // Check the baseURL in .env - if (is_file(HOMEPATH . '.env')) - { - $env = (bool) preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')); - } - - if ($env) - { - // BaseURL in .env is a valid URL? - // phpunit.xml.dist sets app.baseURL in $_SERVER - // So if you set app.baseURL in .env, it takes precedence - $config = new Config\App(); - $this->assertTrue( - $validation->check($config->baseURL, 'valid_url'), - 'baseURL "' . $config->baseURL . '" in .env is not valid URL' - ); - } - - // Get the baseURL in app/Config/App.php - // You can't use Config\App, because phpunit.xml.dist sets app.baseURL - $reader = new \Tests\Support\Libraries\ConfigReader(); - - // BaseURL in app/Config/App.php is a valid URL? - $this->assertTrue( - $validation->check($reader->baseURL, 'valid_url'), - 'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL' - ); - } + public function setUp(): void + { + parent::setUp(); + } + + public function testIsDefinedAppPath() + { + $test = defined('APPPATH'); + + $this->assertTrue($test); + } + + public function testBaseUrlHasBeenSet() + { + $validation = Services::validation(); + $env = false; + + // Check the baseURL in .env + if (is_file(HOMEPATH . '.env')) + { + $env = (bool) preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')); + } + + if ($env) + { + // BaseURL in .env is a valid URL? + // phpunit.xml.dist sets app.baseURL in $_SERVER + // So if you set app.baseURL in .env, it takes precedence + $config = new Config\App(); + $this->assertTrue( + $validation->check($config->baseURL, 'valid_url'), + 'baseURL "' . $config->baseURL . '" in .env is not valid URL' + ); + } + + // Get the baseURL in app/Config/App.php + // You can't use Config\App, because phpunit.xml.dist sets app.baseURL + $reader = new \Tests\Support\Libraries\ConfigReader(); + + // BaseURL in app/Config/App.php is a valid URL? + $this->assertTrue( + $validation->check($reader->baseURL, 'valid_url'), + 'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL' + ); + } } diff --git a/admin/userguide/composer.json b/admin/userguide/composer.json index 198450876c89..a8fc259202fd 100644 --- a/admin/userguide/composer.json +++ b/admin/userguide/composer.json @@ -5,7 +5,7 @@ "homepage": "https://codeigniter.com", "license": "MIT", "require": { - "php": "^7.3||^8.0", + "php": "^7.3 || ^8.0", "codeigniter4/framework": "^4" }, "support": { diff --git a/app/Config/App.php b/app/Config/App.php index 86b94d04b217..5c1d3cf16a91 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -6,460 +6,460 @@ class App extends BaseConfig { - /** - * -------------------------------------------------------------------------- - * Base Site URL - * -------------------------------------------------------------------------- - * - * URL to your CodeIgniter root. Typically this will be your base URL, - * WITH a trailing slash: - * - * http://example.com/ - * - * If this is not set then CodeIgniter will try guess the protocol, domain - * and path to your installation. However, you should always configure this - * explicitly and never rely on auto-guessing, especially in production - * environments. - * - * @var string - */ - public $baseURL = 'http://localhost:8080/'; - - /** - * -------------------------------------------------------------------------- - * Index File - * -------------------------------------------------------------------------- - * - * Typically this will be your index.php file, unless you've renamed it to - * something else. If you are using mod_rewrite to remove the page set this - * variable so that it is blank. - * - * @var string - */ - public $indexPage = 'index.php'; - - /** - * -------------------------------------------------------------------------- - * URI PROTOCOL - * -------------------------------------------------------------------------- - * - * This item determines which getServer global should be used to retrieve the - * URI string. The default setting of 'REQUEST_URI' works for most servers. - * If your links do not seem to work, try one of the other delicious flavors: - * - * 'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] - * 'QUERY_STRING' Uses $_SERVER['QUERY_STRING'] - * 'PATH_INFO' Uses $_SERVER['PATH_INFO'] - * - * WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded! - * - * @var string - */ - public $uriProtocol = 'REQUEST_URI'; - - /** - * -------------------------------------------------------------------------- - * Default Locale - * -------------------------------------------------------------------------- - * - * The Locale roughly represents the language and location that your visitor - * is viewing the site from. It affects the language strings and other - * strings (like currency markers, numbers, etc), that your program - * should run under for this request. - * - * @var string - */ - public $defaultLocale = 'en'; - - /** - * -------------------------------------------------------------------------- - * Negotiate Locale - * -------------------------------------------------------------------------- - * - * If true, the current Request object will automatically determine the - * language to use based on the value of the Accept-Language header. - * - * If false, no automatic detection will be performed. - * - * @var boolean - */ - public $negotiateLocale = false; - - /** - * -------------------------------------------------------------------------- - * Supported Locales - * -------------------------------------------------------------------------- - * - * If $negotiateLocale is true, this array lists the locales supported - * by the application in descending order of priority. If no match is - * found, the first locale will be used. - * - * @var string[] - */ - public $supportedLocales = ['en']; - - /** - * -------------------------------------------------------------------------- - * Application Timezone - * -------------------------------------------------------------------------- - * - * The default timezone that will be used in your application to display - * dates with the date helper, and can be retrieved through app_timezone() - * - * @var string - */ - public $appTimezone = 'America/Chicago'; - - /** - * -------------------------------------------------------------------------- - * Default Character Set - * -------------------------------------------------------------------------- - * - * This determines which character set is used by default in various methods - * that require a character set to be provided. - * - * @see http://php.net/htmlspecialchars for a list of supported charsets. - * - * @var string - */ - public $charset = 'UTF-8'; - - /** - * -------------------------------------------------------------------------- - * URI PROTOCOL - * -------------------------------------------------------------------------- - * - * If true, this will force every request made to this application to be - * made via a secure connection (HTTPS). If the incoming request is not - * secure, the user will be redirected to a secure version of the page - * and the HTTP Strict Transport Security header will be set. - * - * @var boolean - */ - public $forceGlobalSecureRequests = false; - - /** - * -------------------------------------------------------------------------- - * Session Driver - * -------------------------------------------------------------------------- - * - * The session storage driver to use: - * - `CodeIgniter\Session\Handlers\FileHandler` - * - `CodeIgniter\Session\Handlers\DatabaseHandler` - * - `CodeIgniter\Session\Handlers\MemcachedHandler` - * - `CodeIgniter\Session\Handlers\RedisHandler` - * - * @var string - */ - public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'; - - /** - * -------------------------------------------------------------------------- - * Session Cookie Name - * -------------------------------------------------------------------------- - * - * The session cookie name, must contain only [0-9a-z_-] characters - * - * @var string - */ - public $sessionCookieName = 'ci_session'; - - /** - * -------------------------------------------------------------------------- - * Session Expiration - * -------------------------------------------------------------------------- - * - * The number of SECONDS you want the session to last. - * Setting to 0 (zero) means expire when the browser is closed. - * - * @var integer - */ - public $sessionExpiration = 7200; - - /** - * -------------------------------------------------------------------------- - * Session Save Path - * -------------------------------------------------------------------------- - * - * The location to save sessions to and is driver dependent. - * - * For the 'files' driver, it's a path to a writable directory. - * WARNING: Only absolute paths are supported! - * - * For the 'database' driver, it's a table name. - * Please read up the manual for the format with other session drivers. - * - * IMPORTANT: You are REQUIRED to set a valid save path! - * - * @var string - */ - public $sessionSavePath = WRITEPATH . 'session'; - - /** - * -------------------------------------------------------------------------- - * Session Match IP - * -------------------------------------------------------------------------- - * - * Whether to match the user's IP address when reading the session data. - * - * WARNING: If you're using the database driver, don't forget to update - * your session table's PRIMARY KEY when changing this setting. - * - * @var boolean - */ - public $sessionMatchIP = false; - - /** - * -------------------------------------------------------------------------- - * Session Time to Update - * -------------------------------------------------------------------------- - * - * How many seconds between CI regenerating the session ID. - * - * @var integer - */ - public $sessionTimeToUpdate = 300; - - /** - * -------------------------------------------------------------------------- - * Session Regenerate Destroy - * -------------------------------------------------------------------------- - * - * Whether to destroy session data associated with the old session ID - * when auto-regenerating the session ID. When set to FALSE, the data - * will be later deleted by the garbage collector. - * - * @var boolean - */ - public $sessionRegenerateDestroy = false; - - /** - * -------------------------------------------------------------------------- - * Cookie Prefix - * -------------------------------------------------------------------------- - * - * Set a cookie name prefix if you need to avoid collisions. - * - * @var string - * - * @deprecated use Config\Cookie::$prefix property instead. - */ - public $cookiePrefix = ''; - - /** - * -------------------------------------------------------------------------- - * Cookie Domain - * -------------------------------------------------------------------------- - * - * Set to `.your-domain.com` for site-wide cookies. - * - * @var string - * - * @deprecated use Config\Cookie::$domain property instead. - */ - public $cookieDomain = ''; - - /** - * -------------------------------------------------------------------------- - * Cookie Path - * -------------------------------------------------------------------------- - * - * Typically will be a forward slash. - * - * @var string - * - * @deprecated use Config\Cookie::$path property instead. - */ - public $cookiePath = '/'; - - /** - * -------------------------------------------------------------------------- - * Cookie Secure - * -------------------------------------------------------------------------- - * - * Cookie will only be set if a secure HTTPS connection exists. - * - * @var boolean - * - * @deprecated use Config\Cookie::$secure property instead. - */ - public $cookieSecure = false; - - /** - * -------------------------------------------------------------------------- - * Cookie HttpOnly - * -------------------------------------------------------------------------- - * - * Cookie will only be accessible via HTTP(S) (no JavaScript). - * - * @var boolean - * - * @deprecated use Config\Cookie::$httponly property instead. - */ - public $cookieHTTPOnly = true; - - /** - * -------------------------------------------------------------------------- - * Cookie SameSite - * -------------------------------------------------------------------------- - * - * Configure cookie SameSite setting. Allowed values are: - * - None - * - Lax - * - Strict - * - '' - * - * Alternatively, you can use the constant names: - * - `Cookie::SAMESITE_NONE` - * - `Cookie::SAMESITE_LAX` - * - `Cookie::SAMESITE_STRICT` - * - * Defaults to `Lax` for compatibility with modern browsers. Setting `''` - * (empty string) means default SameSite attribute set by browsers (`Lax`) - * will be set on cookies. If set to `None`, `$cookieSecure` must also be set. - * - * @var string - * - * @deprecated use Config\Cookie::$samesite property instead. - */ - public $cookieSameSite = 'Lax'; - - /** - * -------------------------------------------------------------------------- - * Reverse Proxy IPs - * -------------------------------------------------------------------------- - * - * If your server is behind a reverse proxy, you must whitelist the proxy - * IP addresses from which CodeIgniter should trust headers such as - * HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify - * the visitor's IP address. - * - * You can use both an array or a comma-separated list of proxy addresses, - * as well as specifying whole subnets. Here are a few examples: - * - * Comma-separated: '10.0.1.200,192.168.5.0/24' - * Array: ['10.0.1.200', '192.168.5.0/24'] - * - * @var string|string[] - */ - public $proxyIPs = ''; - - /** - * -------------------------------------------------------------------------- - * CSRF Token Name - * -------------------------------------------------------------------------- - * - * The token name. - * - * @deprecated Use `Config\Security` $tokenName property instead of using this property. - * - * @var string - */ - public $CSRFTokenName = 'csrf_test_name'; - - /** - * -------------------------------------------------------------------------- - * CSRF Header Name - * -------------------------------------------------------------------------- - * - * The header name. - * - * @deprecated Use `Config\Security` $headerName property instead of using this property. - * - * @var string - */ - public $CSRFHeaderName = 'X-CSRF-TOKEN'; - - /** - * -------------------------------------------------------------------------- - * CSRF Cookie Name - * -------------------------------------------------------------------------- - * - * The cookie name. - * - * @deprecated Use `Config\Security` $cookieName property instead of using this property. - * - * @var string - */ - public $CSRFCookieName = 'csrf_cookie_name'; - - /** - * -------------------------------------------------------------------------- - * CSRF Expire - * -------------------------------------------------------------------------- - * - * The number in seconds the token should expire. - * - * @deprecated Use `Config\Security` $expire property instead of using this property. - * - * @var integer - */ - public $CSRFExpire = 7200; - - /** - * -------------------------------------------------------------------------- - * CSRF Regenerate - * -------------------------------------------------------------------------- - * - * Regenerate token on every submission? - * - * @deprecated Use `Config\Security` $regenerate property instead of using this property. - * - * @var boolean - */ - public $CSRFRegenerate = true; - - /** - * -------------------------------------------------------------------------- - * CSRF Redirect - * -------------------------------------------------------------------------- - * - * Redirect to previous page with error on failure? - * - * @deprecated Use `Config\Security` $redirect property instead of using this property. - * - * @var boolean - */ - public $CSRFRedirect = true; - - /** - * -------------------------------------------------------------------------- - * CSRF SameSite - * -------------------------------------------------------------------------- - * - * Setting for CSRF SameSite cookie token. Allowed values are: - * - None - * - Lax - * - Strict - * - '' - * - * Defaults to `Lax` as recommended in this link: - * - * @see https://portswigger.net/web-security/csrf/samesite-cookies - * - * @deprecated Use `Config\Security` $samesite property instead of using this property. - * - * @var string - */ - public $CSRFSameSite = 'Lax'; - - /** - * -------------------------------------------------------------------------- - * Content Security Policy - * -------------------------------------------------------------------------- - * - * Enables the Response's Content Secure Policy to restrict the sources that - * can be used for images, scripts, CSS files, audio, video, etc. If enabled, - * the Response object will populate default values for the policy from the - * `ContentSecurityPolicy.php` file. Controllers can always add to those - * restrictions at run time. - * - * For a better understanding of CSP, see these documents: - * - * @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/ - * @see http://www.w3.org/TR/CSP/ - * - * @var boolean - */ - public $CSPEnabled = false; + /** + * -------------------------------------------------------------------------- + * Base Site URL + * -------------------------------------------------------------------------- + * + * URL to your CodeIgniter root. Typically this will be your base URL, + * WITH a trailing slash: + * + * http://example.com/ + * + * If this is not set then CodeIgniter will try guess the protocol, domain + * and path to your installation. However, you should always configure this + * explicitly and never rely on auto-guessing, especially in production + * environments. + * + * @var string + */ + public $baseURL = 'http://localhost:8080/'; + + /** + * -------------------------------------------------------------------------- + * Index File + * -------------------------------------------------------------------------- + * + * Typically this will be your index.php file, unless you've renamed it to + * something else. If you are using mod_rewrite to remove the page set this + * variable so that it is blank. + * + * @var string + */ + public $indexPage = 'index.php'; + + /** + * -------------------------------------------------------------------------- + * URI PROTOCOL + * -------------------------------------------------------------------------- + * + * This item determines which getServer global should be used to retrieve the + * URI string. The default setting of 'REQUEST_URI' works for most servers. + * If your links do not seem to work, try one of the other delicious flavors: + * + * 'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] + * 'QUERY_STRING' Uses $_SERVER['QUERY_STRING'] + * 'PATH_INFO' Uses $_SERVER['PATH_INFO'] + * + * WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded! + * + * @var string + */ + public $uriProtocol = 'REQUEST_URI'; + + /** + * -------------------------------------------------------------------------- + * Default Locale + * -------------------------------------------------------------------------- + * + * The Locale roughly represents the language and location that your visitor + * is viewing the site from. It affects the language strings and other + * strings (like currency markers, numbers, etc), that your program + * should run under for this request. + * + * @var string + */ + public $defaultLocale = 'en'; + + /** + * -------------------------------------------------------------------------- + * Negotiate Locale + * -------------------------------------------------------------------------- + * + * If true, the current Request object will automatically determine the + * language to use based on the value of the Accept-Language header. + * + * If false, no automatic detection will be performed. + * + * @var boolean + */ + public $negotiateLocale = false; + + /** + * -------------------------------------------------------------------------- + * Supported Locales + * -------------------------------------------------------------------------- + * + * If $negotiateLocale is true, this array lists the locales supported + * by the application in descending order of priority. If no match is + * found, the first locale will be used. + * + * @var string[] + */ + public $supportedLocales = ['en']; + + /** + * -------------------------------------------------------------------------- + * Application Timezone + * -------------------------------------------------------------------------- + * + * The default timezone that will be used in your application to display + * dates with the date helper, and can be retrieved through app_timezone() + * + * @var string + */ + public $appTimezone = 'America/Chicago'; + + /** + * -------------------------------------------------------------------------- + * Default Character Set + * -------------------------------------------------------------------------- + * + * This determines which character set is used by default in various methods + * that require a character set to be provided. + * + * @see http://php.net/htmlspecialchars for a list of supported charsets. + * + * @var string + */ + public $charset = 'UTF-8'; + + /** + * -------------------------------------------------------------------------- + * URI PROTOCOL + * -------------------------------------------------------------------------- + * + * If true, this will force every request made to this application to be + * made via a secure connection (HTTPS). If the incoming request is not + * secure, the user will be redirected to a secure version of the page + * and the HTTP Strict Transport Security header will be set. + * + * @var boolean + */ + public $forceGlobalSecureRequests = false; + + /** + * -------------------------------------------------------------------------- + * Session Driver + * -------------------------------------------------------------------------- + * + * The session storage driver to use: + * - `CodeIgniter\Session\Handlers\FileHandler` + * - `CodeIgniter\Session\Handlers\DatabaseHandler` + * - `CodeIgniter\Session\Handlers\MemcachedHandler` + * - `CodeIgniter\Session\Handlers\RedisHandler` + * + * @var string + */ + public $sessionDriver = 'CodeIgniter\Session\Handlers\FileHandler'; + + /** + * -------------------------------------------------------------------------- + * Session Cookie Name + * -------------------------------------------------------------------------- + * + * The session cookie name, must contain only [0-9a-z_-] characters + * + * @var string + */ + public $sessionCookieName = 'ci_session'; + + /** + * -------------------------------------------------------------------------- + * Session Expiration + * -------------------------------------------------------------------------- + * + * The number of SECONDS you want the session to last. + * Setting to 0 (zero) means expire when the browser is closed. + * + * @var integer + */ + public $sessionExpiration = 7200; + + /** + * -------------------------------------------------------------------------- + * Session Save Path + * -------------------------------------------------------------------------- + * + * The location to save sessions to and is driver dependent. + * + * For the 'files' driver, it's a path to a writable directory. + * WARNING: Only absolute paths are supported! + * + * For the 'database' driver, it's a table name. + * Please read up the manual for the format with other session drivers. + * + * IMPORTANT: You are REQUIRED to set a valid save path! + * + * @var string + */ + public $sessionSavePath = WRITEPATH . 'session'; + + /** + * -------------------------------------------------------------------------- + * Session Match IP + * -------------------------------------------------------------------------- + * + * Whether to match the user's IP address when reading the session data. + * + * WARNING: If you're using the database driver, don't forget to update + * your session table's PRIMARY KEY when changing this setting. + * + * @var boolean + */ + public $sessionMatchIP = false; + + /** + * -------------------------------------------------------------------------- + * Session Time to Update + * -------------------------------------------------------------------------- + * + * How many seconds between CI regenerating the session ID. + * + * @var integer + */ + public $sessionTimeToUpdate = 300; + + /** + * -------------------------------------------------------------------------- + * Session Regenerate Destroy + * -------------------------------------------------------------------------- + * + * Whether to destroy session data associated with the old session ID + * when auto-regenerating the session ID. When set to FALSE, the data + * will be later deleted by the garbage collector. + * + * @var boolean + */ + public $sessionRegenerateDestroy = false; + + /** + * -------------------------------------------------------------------------- + * Cookie Prefix + * -------------------------------------------------------------------------- + * + * Set a cookie name prefix if you need to avoid collisions. + * + * @var string + * + * @deprecated use Config\Cookie::$prefix property instead. + */ + public $cookiePrefix = ''; + + /** + * -------------------------------------------------------------------------- + * Cookie Domain + * -------------------------------------------------------------------------- + * + * Set to `.your-domain.com` for site-wide cookies. + * + * @var string + * + * @deprecated use Config\Cookie::$domain property instead. + */ + public $cookieDomain = ''; + + /** + * -------------------------------------------------------------------------- + * Cookie Path + * -------------------------------------------------------------------------- + * + * Typically will be a forward slash. + * + * @var string + * + * @deprecated use Config\Cookie::$path property instead. + */ + public $cookiePath = '/'; + + /** + * -------------------------------------------------------------------------- + * Cookie Secure + * -------------------------------------------------------------------------- + * + * Cookie will only be set if a secure HTTPS connection exists. + * + * @var boolean + * + * @deprecated use Config\Cookie::$secure property instead. + */ + public $cookieSecure = false; + + /** + * -------------------------------------------------------------------------- + * Cookie HttpOnly + * -------------------------------------------------------------------------- + * + * Cookie will only be accessible via HTTP(S) (no JavaScript). + * + * @var boolean + * + * @deprecated use Config\Cookie::$httponly property instead. + */ + public $cookieHTTPOnly = true; + + /** + * -------------------------------------------------------------------------- + * Cookie SameSite + * -------------------------------------------------------------------------- + * + * Configure cookie SameSite setting. Allowed values are: + * - None + * - Lax + * - Strict + * - '' + * + * Alternatively, you can use the constant names: + * - `Cookie::SAMESITE_NONE` + * - `Cookie::SAMESITE_LAX` + * - `Cookie::SAMESITE_STRICT` + * + * Defaults to `Lax` for compatibility with modern browsers. Setting `''` + * (empty string) means default SameSite attribute set by browsers (`Lax`) + * will be set on cookies. If set to `None`, `$cookieSecure` must also be set. + * + * @var string + * + * @deprecated use Config\Cookie::$samesite property instead. + */ + public $cookieSameSite = 'Lax'; + + /** + * -------------------------------------------------------------------------- + * Reverse Proxy IPs + * -------------------------------------------------------------------------- + * + * If your server is behind a reverse proxy, you must whitelist the proxy + * IP addresses from which CodeIgniter should trust headers such as + * HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify + * the visitor's IP address. + * + * You can use both an array or a comma-separated list of proxy addresses, + * as well as specifying whole subnets. Here are a few examples: + * + * Comma-separated: '10.0.1.200,192.168.5.0/24' + * Array: ['10.0.1.200', '192.168.5.0/24'] + * + * @var string|string[] + */ + public $proxyIPs = ''; + + /** + * -------------------------------------------------------------------------- + * CSRF Token Name + * -------------------------------------------------------------------------- + * + * The token name. + * + * @deprecated Use `Config\Security` $tokenName property instead of using this property. + * + * @var string + */ + public $CSRFTokenName = 'csrf_test_name'; + + /** + * -------------------------------------------------------------------------- + * CSRF Header Name + * -------------------------------------------------------------------------- + * + * The header name. + * + * @deprecated Use `Config\Security` $headerName property instead of using this property. + * + * @var string + */ + public $CSRFHeaderName = 'X-CSRF-TOKEN'; + + /** + * -------------------------------------------------------------------------- + * CSRF Cookie Name + * -------------------------------------------------------------------------- + * + * The cookie name. + * + * @deprecated Use `Config\Security` $cookieName property instead of using this property. + * + * @var string + */ + public $CSRFCookieName = 'csrf_cookie_name'; + + /** + * -------------------------------------------------------------------------- + * CSRF Expire + * -------------------------------------------------------------------------- + * + * The number in seconds the token should expire. + * + * @deprecated Use `Config\Security` $expire property instead of using this property. + * + * @var integer + */ + public $CSRFExpire = 7200; + + /** + * -------------------------------------------------------------------------- + * CSRF Regenerate + * -------------------------------------------------------------------------- + * + * Regenerate token on every submission? + * + * @deprecated Use `Config\Security` $regenerate property instead of using this property. + * + * @var boolean + */ + public $CSRFRegenerate = true; + + /** + * -------------------------------------------------------------------------- + * CSRF Redirect + * -------------------------------------------------------------------------- + * + * Redirect to previous page with error on failure? + * + * @deprecated Use `Config\Security` $redirect property instead of using this property. + * + * @var boolean + */ + public $CSRFRedirect = true; + + /** + * -------------------------------------------------------------------------- + * CSRF SameSite + * -------------------------------------------------------------------------- + * + * Setting for CSRF SameSite cookie token. Allowed values are: + * - None + * - Lax + * - Strict + * - '' + * + * Defaults to `Lax` as recommended in this link: + * + * @see https://portswigger.net/web-security/csrf/samesite-cookies + * + * @deprecated Use `Config\Security` $samesite property instead of using this property. + * + * @var string + */ + public $CSRFSameSite = 'Lax'; + + /** + * -------------------------------------------------------------------------- + * Content Security Policy + * -------------------------------------------------------------------------- + * + * Enables the Response's Content Secure Policy to restrict the sources that + * can be used for images, scripts, CSS files, audio, video, etc. If enabled, + * the Response object will populate default values for the policy from the + * `ContentSecurityPolicy.php` file. Controllers can always add to those + * restrictions at run time. + * + * For a better understanding of CSP, see these documents: + * + * @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/ + * @see http://www.w3.org/TR/CSP/ + * + * @var boolean + */ + public $CSPEnabled = false; } diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 1ed5e3f65b91..65eec2641c0a 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -17,68 +17,68 @@ */ class Autoload extends AutoloadConfig { - /** - * ------------------------------------------------------------------- - * Namespaces - * ------------------------------------------------------------------- - * This maps the locations of any namespaces in your application to - * their location on the file system. These are used by the autoloader - * to locate files the first time they have been instantiated. - * - * The '/app' and '/system' directories are already mapped for you. - * you may change the name of the 'App' namespace if you wish, - * but this should be done prior to creating any namespaced classes, - * else you will need to modify all of those classes for this to work. - * - * Prototype: - *``` - * $psr4 = [ - * 'CodeIgniter' => SYSTEMPATH, - * 'App' => APPPATH - * ]; - *``` - * @var array - */ - public $psr4 = [ - APP_NAMESPACE => APPPATH, // For custom app namespace - 'Config' => APPPATH . 'Config', - ]; + /** + * ------------------------------------------------------------------- + * Namespaces + * ------------------------------------------------------------------- + * This maps the locations of any namespaces in your application to + * their location on the file system. These are used by the autoloader + * to locate files the first time they have been instantiated. + * + * The '/app' and '/system' directories are already mapped for you. + * you may change the name of the 'App' namespace if you wish, + * but this should be done prior to creating any namespaced classes, + * else you will need to modify all of those classes for this to work. + * + * Prototype: + *``` + * $psr4 = [ + * 'CodeIgniter' => SYSTEMPATH, + * 'App' => APPPATH + * ]; + *``` + * @var array + */ + public $psr4 = [ + APP_NAMESPACE => APPPATH, // For custom app namespace + 'Config' => APPPATH . 'Config', + ]; - /** - * ------------------------------------------------------------------- - * Class Map - * ------------------------------------------------------------------- - * The class map provides a map of class names and their exact - * location on the drive. Classes loaded in this manner will have - * slightly faster performance because they will not have to be - * searched for within one or more directories as they would if they - * were being autoloaded through a namespace. - * - * Prototype: - *``` - * $classmap = [ - * 'MyClass' => '/path/to/class/file.php' - * ]; - *``` - * @var array - */ - public $classmap = []; + /** + * ------------------------------------------------------------------- + * Class Map + * ------------------------------------------------------------------- + * The class map provides a map of class names and their exact + * location on the drive. Classes loaded in this manner will have + * slightly faster performance because they will not have to be + * searched for within one or more directories as they would if they + * were being autoloaded through a namespace. + * + * Prototype: + *``` + * $classmap = [ + * 'MyClass' => '/path/to/class/file.php' + * ]; + *``` + * @var array + */ + public $classmap = []; - /** - * ------------------------------------------------------------------- - * Files - * ------------------------------------------------------------------- - * The files array provides a list of paths to __non-class__ files - * that will be autoloaded. This can be useful for bootstrap operations - * or for loading functions. - * - * Prototype: - * ``` - * $files = [ - * '/path/to/my/file.php', - * ]; - * ``` - * @var array - */ - public $files = []; + /** + * ------------------------------------------------------------------- + * Files + * ------------------------------------------------------------------- + * The files array provides a list of paths to __non-class__ files + * that will be autoloaded. This can be useful for bootstrap operations + * or for loading functions. + * + * Prototype: + * ``` + * $files = [ + * '/path/to/my/file.php', + * ]; + * ``` + * @var array + */ + public $files = []; } diff --git a/app/Config/Cache.php b/app/Config/Cache.php index e5711a35fbca..bab3f6133152 100644 --- a/app/Config/Cache.php +++ b/app/Config/Cache.php @@ -12,156 +12,156 @@ class Cache extends BaseConfig { - /** - * -------------------------------------------------------------------------- - * Primary Handler - * -------------------------------------------------------------------------- - * - * The name of the preferred handler that should be used. If for some reason - * it is not available, the $backupHandler will be used in its place. - * - * @var string - */ - public $handler = 'file'; + /** + * -------------------------------------------------------------------------- + * Primary Handler + * -------------------------------------------------------------------------- + * + * The name of the preferred handler that should be used. If for some reason + * it is not available, the $backupHandler will be used in its place. + * + * @var string + */ + public $handler = 'file'; - /** - * -------------------------------------------------------------------------- - * Backup Handler - * -------------------------------------------------------------------------- - * - * The name of the handler that will be used in case the first one is - * unreachable. Often, 'file' is used here since the filesystem is - * always available, though that's not always practical for the app. - * - * @var string - */ - public $backupHandler = 'dummy'; + /** + * -------------------------------------------------------------------------- + * Backup Handler + * -------------------------------------------------------------------------- + * + * The name of the handler that will be used in case the first one is + * unreachable. Often, 'file' is used here since the filesystem is + * always available, though that's not always practical for the app. + * + * @var string + */ + public $backupHandler = 'dummy'; - /** - * -------------------------------------------------------------------------- - * Cache Directory Path - * -------------------------------------------------------------------------- - * - * The path to where cache files should be stored, if using a file-based - * system. - * - * @var string - * - * @deprecated Use the driver-specific variant under $file - */ - public $storePath = WRITEPATH . 'cache/'; + /** + * -------------------------------------------------------------------------- + * Cache Directory Path + * -------------------------------------------------------------------------- + * + * The path to where cache files should be stored, if using a file-based + * system. + * + * @var string + * + * @deprecated Use the driver-specific variant under $file + */ + public $storePath = WRITEPATH . 'cache/'; - /** - * -------------------------------------------------------------------------- - * Cache Include Query String - * -------------------------------------------------------------------------- - * - * Whether to take the URL query string into consideration when generating - * output cache files. Valid options are: - * - * false = Disabled - * true = Enabled, take all query parameters into account. - * Please be aware that this may result in numerous cache - * files generated for the same page over and over again. - * array('q') = Enabled, but only take into account the specified list - * of query parameters. - * - * @var boolean|string[] - */ - public $cacheQueryString = false; + /** + * -------------------------------------------------------------------------- + * Cache Include Query String + * -------------------------------------------------------------------------- + * + * Whether to take the URL query string into consideration when generating + * output cache files. Valid options are: + * + * false = Disabled + * true = Enabled, take all query parameters into account. + * Please be aware that this may result in numerous cache + * files generated for the same page over and over again. + * array('q') = Enabled, but only take into account the specified list + * of query parameters. + * + * @var boolean|string[] + */ + public $cacheQueryString = false; - /** - * -------------------------------------------------------------------------- - * Key Prefix - * -------------------------------------------------------------------------- - * - * This string is added to all cache item names to help avoid collisions - * if you run multiple applications with the same cache engine. - * - * @var string - */ - public $prefix = ''; + /** + * -------------------------------------------------------------------------- + * Key Prefix + * -------------------------------------------------------------------------- + * + * This string is added to all cache item names to help avoid collisions + * if you run multiple applications with the same cache engine. + * + * @var string + */ + public $prefix = ''; - /** - * -------------------------------------------------------------------------- - * Default TTL - * -------------------------------------------------------------------------- - * - * The default number of seconds to save items when none is specified. - * - * WARNING: This is not used by framework handlers where 60 seconds is - * hard-coded, but may be useful to projects and modules. This will replace - * the hard-coded value in a future release. - * - * @var integer - */ - public $ttl = 60; + /** + * -------------------------------------------------------------------------- + * Default TTL + * -------------------------------------------------------------------------- + * + * The default number of seconds to save items when none is specified. + * + * WARNING: This is not used by framework handlers where 60 seconds is + * hard-coded, but may be useful to projects and modules. This will replace + * the hard-coded value in a future release. + * + * @var integer + */ + public $ttl = 60; - /** - * -------------------------------------------------------------------------- - * File settings - * -------------------------------------------------------------------------- - * Your file storage preferences can be specified below, if you are using - * the File driver. - * - * @var array - */ - public $file = [ - 'storePath' => WRITEPATH . 'cache/', - 'mode' => 0640, - ]; + /** + * -------------------------------------------------------------------------- + * File settings + * -------------------------------------------------------------------------- + * Your file storage preferences can be specified below, if you are using + * the File driver. + * + * @var array + */ + public $file = [ + 'storePath' => WRITEPATH . 'cache/', + 'mode' => 0640, + ]; - /** - * ------------------------------------------------------------------------- - * Memcached settings - * ------------------------------------------------------------------------- - * Your Memcached servers can be specified below, if you are using - * the Memcached drivers. - * - * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached - * - * @var array - */ - public $memcached = [ - 'host' => '127.0.0.1', - 'port' => 11211, - 'weight' => 1, - 'raw' => false, - ]; + /** + * ------------------------------------------------------------------------- + * Memcached settings + * ------------------------------------------------------------------------- + * Your Memcached servers can be specified below, if you are using + * the Memcached drivers. + * + * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached + * + * @var array + */ + public $memcached = [ + 'host' => '127.0.0.1', + 'port' => 11211, + 'weight' => 1, + 'raw' => false, + ]; - /** - * ------------------------------------------------------------------------- - * Redis settings - * ------------------------------------------------------------------------- - * Your Redis server can be specified below, if you are using - * the Redis or Predis drivers. - * - * @var array - */ - public $redis = [ - 'host' => '127.0.0.1', - 'password' => null, - 'port' => 6379, - 'timeout' => 0, - 'database' => 0, - ]; + /** + * ------------------------------------------------------------------------- + * Redis settings + * ------------------------------------------------------------------------- + * Your Redis server can be specified below, if you are using + * the Redis or Predis drivers. + * + * @var array + */ + public $redis = [ + 'host' => '127.0.0.1', + 'password' => null, + 'port' => 6379, + 'timeout' => 0, + 'database' => 0, + ]; - /** - * -------------------------------------------------------------------------- - * Available Cache Handlers - * -------------------------------------------------------------------------- - * - * This is an array of cache engine alias' and class names. Only engines - * that are listed here are allowed to be used. - * - * @var array - */ - public $validHandlers = [ - 'dummy' => DummyHandler::class, - 'file' => FileHandler::class, - 'memcached' => MemcachedHandler::class, - 'predis' => PredisHandler::class, - 'redis' => RedisHandler::class, - 'wincache' => WincacheHandler::class, - ]; + /** + * -------------------------------------------------------------------------- + * Available Cache Handlers + * -------------------------------------------------------------------------- + * + * This is an array of cache engine alias' and class names. Only engines + * that are listed here are allowed to be used. + * + * @var array + */ + public $validHandlers = [ + 'dummy' => DummyHandler::class, + 'file' => FileHandler::class, + 'memcached' => MemcachedHandler::class, + 'predis' => PredisHandler::class, + 'redis' => RedisHandler::class, + 'wincache' => WincacheHandler::class, + ]; } diff --git a/app/Config/ContentSecurityPolicy.php b/app/Config/ContentSecurityPolicy.php index a04e3d0f9e6a..1be7f4c15d4b 100644 --- a/app/Config/ContentSecurityPolicy.php +++ b/app/Config/ContentSecurityPolicy.php @@ -15,153 +15,153 @@ */ class ContentSecurityPolicy extends BaseConfig { - //------------------------------------------------------------------------- - // Broadbrush CSP management - //------------------------------------------------------------------------- - - /** - * Default CSP report context - * - * @var boolean - */ - public $reportOnly = false; - - /** - * Specifies a URL where a browser will send reports - * when a content security policy is violated. - * - * @var string|null - */ - public $reportURI = null; - - /** - * Instructs user agents to rewrite URL schemes, changing - * HTTP to HTTPS. This directive is for websites with - * large numbers of old URLs that need to be rewritten. - * - * @var boolean - */ - public $upgradeInsecureRequests = false; - - //------------------------------------------------------------------------- - // Sources allowed - // Note: once you set a policy to 'none', it cannot be further restricted - //------------------------------------------------------------------------- - - /** - * Will default to self if not overridden - * - * @var string|string[]|null - */ - public $defaultSrc = null; - - /** - * Lists allowed scripts' URLs. - * - * @var string|string[] - */ - public $scriptSrc = 'self'; - - /** - * Lists allowed stylesheets' URLs. - * - * @var string|string[] - */ - public $styleSrc = 'self'; - - /** - * Defines the origins from which images can be loaded. - * - * @var string|string[] - */ - public $imageSrc = 'self'; - - /** - * Restricts the URLs that can appear in a page's `` element. - * - * Will default to self if not overridden - * - * @var string|string[]|null - */ - public $baseURI = null; - - /** - * Lists the URLs for workers and embedded frame contents - * - * @var string|string[] - */ - public $childSrc = 'self'; - - /** - * Limits the origins that you can connect to (via XHR, - * WebSockets, and EventSource). - * - * @var string|string[] - */ - public $connectSrc = 'self'; - - /** - * Specifies the origins that can serve web fonts. - * - * @var string|string[] - */ - public $fontSrc = null; - - /** - * Lists valid endpoints for submission from `
` tags. - * - * @var string|string[] - */ - public $formAction = 'self'; - - /** - * Specifies the sources that can embed the current page. - * This directive applies to ``, `