Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: codeigniter4/CodeIgniter4
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f53e30cf96e1c9cfe03b2cca567960cfd942deb2
Choose a base ref
..
head repository: codeigniter4/CodeIgniter4
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6bb72b1317e899fa66cd2f68c9e6f546f95ee0ac
Choose a head ref
Showing with 1,109 additions and 727 deletions.
  1. +12 −2 admin/pre-commit
  2. +134 −23 app/Config/ContentSecurityPolicy.php
  3. +0 −1 app/Config/Services.php
  4. +0 −2 app/Controllers/BaseController.php
  5. +3 −4 app/Controllers/Home.php
  6. +1 −0 app/Views/errors/cli/error_404.php
  7. +1 −1 app/Views/errors/cli/error_exception.php
  8. +7 −7 app/Views/errors/html/error_exception.php
  9. +1 −0 rector.php
  10. +14 −0 system/API/ResponseTrait.php
  11. +0 −1 system/CLI/BaseCommand.php
  12. +2 −2 system/CLI/CLI.php
  13. +0 −1 system/CLI/CommandRunner.php
  14. +0 −1 system/CLI/Console.php
  15. +2 −1 system/CLI/GeneratorCommand.php
  16. +0 −1 system/Cache/CacheInterface.php
  17. +0 −1 system/Cache/Handlers/DummyHandler.php
  18. +0 −1 system/Cache/Handlers/FileHandler.php
  19. +0 −2 system/Cache/Handlers/MemcachedHandler.php
  20. +0 −2 system/Cache/Handlers/PredisHandler.php
  21. +0 −1 system/Cache/Handlers/RedisHandler.php
  22. +0 −1 system/Cache/Handlers/WincacheHandler.php
  23. +2 −2 system/CodeIgniter.php
  24. +2 −6 system/Commands/Generators/CreateScaffold.php
  25. +0 −2 system/Commands/Help.php
  26. +0 −2 system/Commands/Utilities/Namespaces.php
  27. +0 −2 system/Commands/Utilities/Routes.php
  28. +4 −4 system/Config/DotEnv.php
  29. +0 −2 system/Config/ForeignCharacters.php
  30. +0 −1 system/Config/View.php
  31. +1 −0 system/Controller.php
  32. +67 −63 system/Database/BaseBuilder.php
  33. +0 −1 system/Database/BaseConnection.php
  34. +0 −1 system/Database/BaseResult.php
  35. +4 −2 system/Database/BaseUtils.php
  36. +0 −1 system/Database/Config.php
  37. +0 −1 system/Database/ConnectionInterface.php
  38. +0 −1 system/Database/Database.php
  39. +0 −1 system/Database/Forge.php
  40. +0 −1 system/Database/Migration.php
  41. +2 −1 system/Database/MigrationRunner.php
  42. +0 −1 system/Database/MySQLi/Builder.php
  43. +12 −4 system/Database/MySQLi/Connection.php
  44. +0 −1 system/Database/MySQLi/Forge.php
  45. +1 −2 system/Database/MySQLi/Result.php
  46. +0 −1 system/Database/MySQLi/Utils.php
  47. +0 −1 system/Database/Postgre/Builder.php
  48. +0 −1 system/Database/Postgre/Forge.php
  49. +0 −1 system/Database/Postgre/Utils.php
  50. +0 −1 system/Database/PreparedQueryInterface.php
  51. +4 −4 system/Database/Query.php
  52. +0 −1 system/Database/QueryInterface.php
  53. +0 −1 system/Database/ResultInterface.php
  54. +0 −2 system/Database/SQLite3/Builder.php
  55. +0 −1 system/Database/SQLite3/Forge.php
  56. +0 −1 system/Database/SQLite3/Utils.php
  57. +0 −2 system/Database/Sqlsrv/Builder.php
  58. +2 −2 system/Database/Sqlsrv/Connection.php
  59. +0 −2 system/Database/Sqlsrv/Forge.php
  60. +0 −1 system/Database/Sqlsrv/Result.php
  61. +0 −2 system/Database/Sqlsrv/Utils.php
  62. +2 −2 system/Debug/Exceptions.php
  63. +0 −1 system/Debug/Iterator.php
  64. +0 −1 system/Debug/Timer.php
  65. +5 −6 system/Debug/Toolbar.php
  66. +0 −2 system/Debug/Toolbar/Collectors/BaseCollector.php
  67. +0 −2 system/Debug/Toolbar/Collectors/Database.php
  68. +0 −1 system/Debug/Toolbar/Collectors/Events.php
  69. +0 −1 system/Debug/Toolbar/Collectors/Files.php
  70. +0 −1 system/Debug/Toolbar/Collectors/Logs.php
  71. +0 −1 system/Debug/Toolbar/Collectors/Routes.php
  72. +0 −2 system/Debug/Toolbar/Collectors/Timers.php
  73. +0 −1 system/Debug/Toolbar/Collectors/Views.php
  74. +0 −1 system/Exceptions/AlertError.php
  75. +0 −2 system/Exceptions/CastException.php
  76. +0 −1 system/Exceptions/ConfigException.php
  77. +0 −1 system/Exceptions/DownloadException.php
  78. +0 −2 system/Files/Exceptions/FileException.php
  79. +0 −1 system/Files/File.php
  80. +0 −1 system/Filters/CSRF.php
  81. +0 −1 system/Filters/DebugToolbar.php
  82. +0 −1 system/Filters/FilterInterface.php
  83. +6 −1 system/Filters/Filters.php
  84. +0 −2 system/Filters/Honeypot.php
  85. +0 −1 system/Format/FormatterInterface.php
  86. +0 −1 system/Format/JSONFormatter.php
  87. +6 −1 system/HTTP/CURLRequest.php
  88. +39 −76 system/HTTP/ContentSecurityPolicy.php
  89. +0 −1 system/HTTP/Exceptions/HTTPException.php
  90. +0 −2 system/HTTP/Files/FileCollection.php
  91. +1 −2 system/HTTP/Files/UploadedFile.php
  92. +0 −1 system/HTTP/Files/UploadedFileInterface.php
  93. +0 −1 system/HTTP/Header.php
  94. +0 −1 system/HTTP/IncomingRequest.php
  95. +3 −3 system/HTTP/Negotiate.php
  96. +0 −1 system/HTTP/Request.php
  97. +0 −1 system/HTTP/RequestInterface.php
  98. +0 −2 system/HTTP/Response.php
  99. +0 −1 system/HTTP/ResponseInterface.php
  100. +0 −1 system/HTTP/URI.php
  101. +2 −1 system/HTTP/UserAgent.php
  102. +78 −0 system/Helpers/array_helper.php
  103. +2 −2 system/Helpers/cookie_helper.php
  104. +1 −1 system/Helpers/date_helper.php
  105. +10 −6 system/Helpers/form_helper.php
  106. +5 −5 system/Helpers/text_helper.php
  107. +0 −1 system/Honeypot/Exceptions/HoneypotException.php
  108. +0 −2 system/Honeypot/Honeypot.php
  109. +6 −0 system/I18n/TimeDifference.php
  110. +3 −9 system/Images/Handlers/BaseHandler.php
  111. +0 −2 system/Images/Handlers/GDHandler.php
  112. +1 −2 system/Images/Handlers/ImageMagickHandler.php
  113. +0 −1 system/Images/Image.php
  114. +0 −1 system/Images/ImageHandlerInterface.php
  115. +15 −15 system/Language/en/CLI.php
  116. +4 −4 system/Language/en/Cache.php
  117. +6 −6 system/Language/en/Cast.php
  118. +5 −5 system/Language/en/Core.php
  119. +16 −16 system/Language/en/Database.php
  120. +19 −19 system/Language/en/Email.php
  121. +6 −6 system/Language/en/Encryption.php
  122. +1 −1 system/Language/en/Entity.php
  123. +3 −3 system/Language/en/Fabricator.php
  124. +2 −2 system/Language/en/Files.php
  125. +2 −2 system/Language/en/Filters.php
  126. +4 −4 system/Language/en/Format.php
  127. +38 −38 system/Language/en/HTTP.php
  128. +20 −20 system/Language/en/Images.php
  129. +1 −1 system/Language/en/Language.php
  130. +1 −1 system/Language/en/Log.php
  131. +38 −38 system/Language/en/Migrations.php
  132. +10 −10 system/Language/en/Number.php
  133. +9 −9 system/Language/en/Pager.php
  134. +1 −1 system/Language/en/RESTful.php
  135. +1 −1 system/Language/en/Redirect.php
  136. +2 −2 system/Language/en/Router.php
  137. +6 −6 system/Language/en/Session.php
  138. +18 −18 system/Language/en/Time.php
  139. +51 −51 system/Language/en/Validation.php
  140. +6 −6 system/Language/en/View.php
  141. +0 −1 system/Log/Handlers/BaseHandler.php
  142. +0 −1 system/Log/Handlers/ChromeLoggerHandler.php
  143. +0 −1 system/Log/Handlers/HandlerInterface.php
  144. +0 −1 system/Pager/Pager.php
  145. +0 −1 system/Pager/PagerInterface.php
  146. +7 −1 system/Pager/PagerRenderer.php
  147. +2 −3 system/Router/RouteCollection.php
  148. +0 −1 system/Router/RouteCollectionInterface.php
  149. +5 −4 system/Router/Router.php
  150. +0 −1 system/Router/RouterInterface.php
  151. +1 −2 system/Security/Security.php
  152. +0 −1 system/Session/Handlers/BaseHandler.php
  153. +14 −12 system/Session/Session.php
  154. +0 −1 system/Session/SessionInterface.php
  155. +0 −1 system/Test/CIUnitTestCase.php
  156. +2 −3 system/Test/ControllerResponse.php
  157. +5 −2 system/Test/ControllerTester.php
  158. +0 −1 system/Test/DOMParser.php
  159. +0 −1 system/Test/FeatureResponse.php
  160. +2 −2 system/Test/Filters/CITestStreamFilter.php
  161. +2 −2 system/Test/Mock/MockBuilder.php
  162. +1 −2 system/Test/Mock/MockCURLRequest.php
  163. +0 −1 system/Test/Mock/MockFileLogger.php
  164. +0 −1 system/Test/Mock/MockIncomingRequest.php
  165. +0 −2 system/Test/Mock/MockLanguage.php
  166. +0 −1 system/Test/Mock/MockLogger.php
  167. +0 −1 system/Test/Mock/MockQuery.php
  168. +0 −2 system/Test/Mock/MockResourceController.php
  169. +0 −2 system/Test/Mock/MockResponse.php
  170. +2 −3 system/Test/Mock/MockServices.php
  171. +2 −3 system/Test/Mock/MockTable.php
  172. +0 −1 system/Test/ReflectionHelper.php
  173. +0 −2 system/Test/TestLogger.php
  174. +1 −2 system/Throttle/Throttler.php
  175. +0 −1 system/Throttle/ThrottlerInterface.php
  176. +0 −2 system/Typography/Typography.php
  177. +0 −1 system/Validation/CreditCardRules.php
  178. +0 −1 system/Validation/FileRules.php
  179. +11 −13 system/Validation/FormatRules.php
  180. +2 −2 system/Validation/Validation.php
  181. +0 −1 system/Validation/ValidationInterface.php
  182. +4 −4 system/View/Cell.php
  183. +0 −1 system/View/Plugins.php
  184. +0 −1 system/View/RendererInterface.php
  185. +0 −1 system/View/Table.php
  186. +0 −1 system/View/View.php
  187. +18 −0 tests/system/API/ResponseTraitTest.php
  188. +14 −0 tests/system/HTTP/CURLRequestTest.php
  189. +130 −1 tests/system/Helpers/ArrayHelperTest.php
  190. +47 −0 tests/system/Router/RouteCollectionTest.php
  191. +1 −1 user_guide_src/source/changelogs/v4.0.5.rst
  192. +91 −0 user_guide_src/source/helpers/array_helper.rst
  193. +5 −0 user_guide_src/source/incoming/routing.rst
  194. +7 −0 user_guide_src/source/libraries/curlrequest.rst
14 changes: 12 additions & 2 deletions admin/pre-commit
Original file line number Diff line number Diff line change
@@ -35,7 +35,12 @@ if [ "$FILES" != "" ]
then
echo "Running PHPStan..."
# Run on whole codebase
./vendor/bin/phpstan analyse
if [ -d /proc/cygdrive ]
then
./vendor/bin/phpstan analyse
else
php ./vendor/bin/phpstan analyse
fi

if [ $? != 0 ]
then
@@ -47,7 +52,12 @@ fi
if [ "$FILES" != "" ]
then
echo "Running Code Sniffer..."
./vendor/bin/phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 -n -p $FILES
if [ -d /proc/cygdrive ]
then
./vendor/bin/phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 -n -p $FILES
else
php ./vendor/bin/phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 --encoding=utf-8 -n -p $FILES
fi
fi

exit $?
157 changes: 134 additions & 23 deletions app/Config/ContentSecurityPolicy.php
Original file line number Diff line number Diff line change
@@ -5,44 +5,155 @@
use CodeIgniter\Config\BaseConfig;

/**
* Class ContentSecurityPolicyConfig
*
* Stores the default settings for the ContentSecurityPolicy, if you
* choose to use it. The values here will be read in and set as defaults
* for the site. If needed, they can be overridden on a page-by-page basis.
*
* Suggested reference for explanations:
* https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
*/
class ContentSecurityPolicy extends BaseConfig
{
// broadbrush CSP management
//-------------------------------------------------------------------------
// Broadbrush CSP management
//-------------------------------------------------------------------------

/**
* Default CSP report context
*
* @var boolean
*/
public $reportOnly = false;

public $reportOnly = false; // default CSP report context
public $reportURI = null; // URL to send violation reports to
public $upgradeInsecureRequests = false; // toggle for forcing https
/**
* Specifies a URL where a browser will send reports
* when a content security policy is violated.
*
* @var string|null
*/
public $reportURI = null;

// sources allowed; string or array of strings
/**
* 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 `<base>` element.
*
* Will default to self if not overridden
*
* @var string|string[]|null
*/
public $baseURI = null;

public $defaultSrc = null; // will default to self if not over-ridden
public $scriptSrc = 'self';
public $styleSrc = 'self';
public $imageSrc = 'self';
public $baseURI = null; // will default to self if not over-ridden
public $childSrc = 'self';
public $connectSrc = 'self';
public $fontSrc = null;
public $formAction = 'self';
/**
* 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 `<form>` tags.
*
* @var string|string[]
*/
public $formAction = 'self';

/**
* Specifies the sources that can embed the current page.
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
* and `<applet>` tags. This directive can't be used in
* `<meta>` tags and applies only to non-HTML resources.
*
* @var string|string[]|null
*/
public $frameAncestors = null;
public $mediaSrc = null;
public $objectSrc = 'self';
public $manifestSrc = null;

// mime types allowed; string or array of strings
/**
* Restricts the origins allowed to deliver video and audio.
*
* @var string|string[]|null
*/
public $mediaSrc = null;

/**
* Allows control over Flash and other plugins.
*
* @var string|string[]
*/
public $objectSrc = 'self';

/**
* @var string|string[]|null
*/
public $manifestSrc = null;

/**
* Limits the kinds of plugins a page may invoke.
*
* @var string|string[]|null
*/
public $pluginTypes = null;

// list of actions allowed; string or array of strings
/**
* List of actions allowed.
*
* @var string|string[]|null
*/
public $sandbox = null;

}
1 change: 0 additions & 1 deletion app/Config/Services.php
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
*/
class Services extends CoreServices
{

// public static function example($getShared = true)
// {
// if ($getShared)
2 changes: 0 additions & 2 deletions app/Controllers/BaseController.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@

class BaseController extends Controller
{

/**
* An array of helpers to be loaded automatically upon
* class instantiation. These helpers will be available
@@ -44,5 +43,4 @@ public function initController(RequestInterface $request, ResponseInterface $res
// E.g.:
// $this->session = \Config\Services::session();
}

}
7 changes: 3 additions & 4 deletions app/Controllers/Home.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php namespace App\Controllers;
<?php

namespace App\Controllers;

class Home extends BaseController
{
public function index()
{
return view('welcome_message');
}

//--------------------------------------------------------------------

}
1 change: 1 addition & 0 deletions app/Views/errors/cli/error_404.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

use CodeIgniter\CLI\CLI;

CLI::error('ERROR: ' . $code);
2 changes: 1 addition & 1 deletion app/Views/errors/cli/error_exception.php
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@

if (isset($error['class']))
{
$type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type'];
$type = ($error['type'] === '->') ? '()' . $error['type'] : $error['type'];
$function .= $padClass . $error['class'] . $type . $error['function'];
}
elseif (! isset($error['class']) && isset($error['function']))
14 changes: 7 additions & 7 deletions app/Views/errors/html/error_exception.php
Original file line number Diff line number Diff line change
@@ -64,12 +64,12 @@
<!-- Trace info -->
<?php if (isset($row['file']) && is_file($row['file'])) :?>
<?php
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once']))
{
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once'], true))
{
echo $row['function'] . ' ' . static::cleanPath($row['file']);
}
else
{
{
echo static::cleanPath($row['file']) . ' : ' . $row['line'];
}
?>
@@ -89,9 +89,9 @@
<?php
$params = null;
// Reflection by name is not available for closure function
if (substr( $row['function'], -1 ) !== '}')
if (substr($row['function'], -1) !== '}')
{
$mirror = isset( $row['class'] ) ? new \ReflectionMethod( $row['class'], $row['function'] ) : new \ReflectionFunction( $row['function'] );
$mirror = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']);
$params = $mirror->getParameters();
}
foreach ($row['args'] as $key => $value) : ?>
@@ -114,7 +114,7 @@
</p>

<!-- Source? -->
<?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
<?php if (isset($row['file']) && is_file($row['file']) && isset($row['class'])) : ?>
<div class="source">
<?= static::highlightFile($row['file'], $row['line']) ?>
</div>
@@ -354,7 +354,7 @@

<ol>
<?php foreach ($files as $file) :?>
<li><?= htmlspecialchars( static::cleanPath($file), ENT_SUBSTITUTE, 'UTF-8') ?></li>
<li><?= htmlspecialchars(static::cleanPath($file), ENT_SUBSTITUTE, 'UTF-8') ?></li>
<?php endforeach ?>
</ol>
</div>
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
// auto import fully qualified class names
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::ENABLE_CACHE, true);
$parameters->set(Option::PHP_VERSION_FEATURES, '7.2');

$services = $containerConfigurator->services();
$services->set(UnderscoreToCamelCaseVariableNameRector::class);
14 changes: 14 additions & 0 deletions system/API/ResponseTrait.php
Original file line number Diff line number Diff line change
@@ -114,6 +114,19 @@ public function respond($data = null, int $status = null, string $message = '')
$output = $this->format($data);
}

if (! is_null($output))
{
if ($this->format === 'json')
{
return $this->response->setJSON($output)->setStatusCode($status, $message);
}

if ($this->format === 'xml')
{
return $this->response->setXML($output)->setStatusCode($status, $message);
}
}

return $this->response->setBody($output)->setStatusCode($status, $message);
}

@@ -361,6 +374,7 @@ protected function format($data = null)
$contentType = str_replace('application/json', 'text/html', $contentType);
$contentType = str_replace('application/', 'text/', $contentType);
$this->response->setContentType($contentType);
$this->format = 'html';

return $data;
}
1 change: 0 additions & 1 deletion system/CLI/BaseCommand.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
*/
abstract class BaseCommand
{

/**
* The group the command is lumped under
* when listing commands.
4 changes: 2 additions & 2 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@
*/
class CLI
{

/**
* Is the readline library on the system?
*
@@ -253,7 +252,8 @@ public static function prompt(string $field, $options = null, string $validation
{
$extraOutput = ' [' . $extraOutputDefault . ', ' . implode(', ', $opts) . ']';
$validation .= '|in_list[' . implode(',', $options) . ']';
$validation = trim($validation, '|');

$validation = trim($validation, '|');
}

$default = $options[0];
1 change: 0 additions & 1 deletion system/CLI/CommandRunner.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
*/
class CommandRunner extends Controller
{

/**
* The Command Manager
*
1 change: 0 additions & 1 deletion system/CLI/Console.php
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
*/
class Console
{

/**
* Main CodeIgniter instance.
*
3 changes: 2 additions & 1 deletion system/CLI/GeneratorCommand.php
Original file line number Diff line number Diff line change
@@ -313,7 +313,8 @@ protected function setReplacements(string $template, string $class): string
'{ namespace }',
'{namespace}',
];
$classes = [

$classes = [
'DummyClass',
'{ class }',
'{class}',
Loading