Skip to content

Commit

Permalink
fix code review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rosasurfer committed Jul 20, 2024
1 parent dc52be1 commit cfac20a
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Application extends Object {
* If set to FALSE you have to setup your own exception handling mechanism.<br>
* (default: TRUE)<br>
*
* All further options are added to the application's default configuration {@link Config} as regular config values.
* All further options are added to the application's default configuration {@link \rosasurfer\config\Config} as regular config values.
*/
public function __construct(array $options = []) {
// set default values
Expand All @@ -83,7 +83,7 @@ public function __construct(array $options = []) {

if (isSet($_GET['__phpinfo__']) || isSet($_GET['__config__']) || isSet($_GET['__cache__'])) {
if (self::isAdminIP()) {
foreach (\array_keys($_GET) as $param) {
foreach ($_GET as $param => $v) {
if ($param == '__phpinfo__') {
if ($configInfoTask) {
$phpInfoTask = false;
Expand Down Expand Up @@ -164,7 +164,7 @@ public function __construct(array $options = []) {


/**
* Run the application and return the {@link Response} if a web application.
* Run the application and return the {@link \rosasurfer\ministruts\Response} if a web application.
*
* @param array $options [optional] - runtime options
*
Expand Down
2 changes: 1 addition & 1 deletion src/core/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


/**
* Super class for all "rosasurfer" classes. Other classes may directly use {@link ObjectTrait} and/or {@link DiAwareTrait}
* Super class for all "rosasurfer" classes. Other classes may directly use {@link ObjectTrait} and/or {@link \rosasurfer\di\DiAwareTrait}
* to achieve the same functionality.
*/
class Object {
Expand Down
4 changes: 2 additions & 2 deletions src/db/orm/PersistableObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __sleep() {
$mapping = $this->dao()->getMapping();
$array = (array) $this;

foreach (\array_keys($mapping['relations']) as $name) {
foreach ($mapping['relations'] as $name => $v) {
if (is_object($this->$name)) {
/** @var PersistableObject $object */
$object = $this->$name;
Expand Down Expand Up @@ -425,7 +425,7 @@ private function insert() {

// collect column values
$values = [];
foreach (\array_keys($mapping['columns']) as $column) {
foreach ($mapping['columns'] as $column => $value) {
$values[$column] = $this->getPhysicalValue($column);
};

Expand Down
2 changes: 1 addition & 1 deletion src/debug/DebugHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static function errorLevelToStr($level) {
else if (($level & E_ALL) == E_ALL) $levels = ['E_ALL']; // 32767
else if (($level & (E_ALL & ~E_DEPRECATED)) == (E_ALL & ~E_DEPRECATED)) $levels = ['E_ALL & ~E_DEPRECATED']; // 24575
else {
foreach (\array_keys($levels) as $key) {
foreach ($levels as $key => $v) {
if ($level & $key) continue;
unset($levels[$key]);
}
Expand Down
22 changes: 9 additions & 13 deletions src/globals.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?php
/**
* If the {@link Application} option "app.globals" is set to TRUE definitions in namespace "\rosasurfer" are additionally
* mapped to the global namespace. Tis feature is not needed and it's generally not recommended to avoid potential naming
* conflicts in the global scope. However, it may be used to simplify life of developers using editors with limited automatic
* code completion capabilities.
*
* (default: FALSE)
* If the {@link \rosasurfer\Application} option "app.globals" is set to TRUE definitions in namespace "\rosasurfer" are
* additionally mapped to the global namespace.
*/
use rosasurfer\Application;
use rosasurfer\ministruts\ActionMapping;
Expand Down Expand Up @@ -912,7 +908,7 @@ function synchronized(\Closure $task, $mutex = null) {


/**
* Lookup and return a {@link Url} helper for the named {@link ActionMapping}.
* Lookup and return a {@link \rosasurfer\ministruts\url\Url} helper for the named {@link \rosasurfer\ministruts\ActionMapping}.
*
* @param string $name - route name
*
Expand All @@ -924,9 +920,9 @@ function route($name) {


/**
* Return a {@link Url} helper for the given URI. An URI starting with a slash "/" is interpreted as relative to the
* application's base URI. An URI not starting with a slash is interpreted as relative to the application {@link Module}'s
* base URI (the module the current request belongs to).<br>
* Return a {@link \rosasurfer\ministruts\url\Url} helper for the given URI. An URI starting with a slash "/" is interpreted as
* relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link \rosasurfer\ministruts\Module}'s base URI (the module the current request belongs to).<br>
*
* Procedural equivalent of <tt>new \rosasurfer\ministruts\url\Url($uri)</tt>.
*
Expand All @@ -940,9 +936,9 @@ function url($uri) {


/**
* Return a version-aware URL helper for the given URI {@link VersionedUrl}. An URI starting with a slash "/" is interpreted
* as relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link Module}'s base URI (the module the current request belongs to).<br>
* Return a version-aware URL helper for the given URI {@link \rosasurfer\ministruts\url\VersionedUrl}. An URI starting with a slash "/"
* is interpreted as relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link \rosasurfer\ministruts\Module}'s base URI (the module the current request belongs to).<br>
*
* Procedural equivalent of <tt>new \rosasurfer\ministruts\url\VersionedUrl($uri)</tt>.
*
Expand Down
16 changes: 7 additions & 9 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use rosasurfer\exception\IOException;
use rosasurfer\exception\RuntimeException;
use rosasurfer\lock\Lock;
use rosasurfer\ministruts\ActionMapping;
use rosasurfer\ministruts\Module;
use rosasurfer\ministruts\Request;
use rosasurfer\ministruts\url\Url;
use rosasurfer\ministruts\url\VersionedUrl;
Expand Down Expand Up @@ -1535,7 +1533,7 @@ function synchronized(\Closure $task, $mutex = null) {


/**
* Lookup and return a {@link Url} helper for the named {@link ActionMapping}.
* Lookup and return a {@link \rosasurfer\ministruts\url\Url} helper for the named {@link \rosasurfer\ministruts\ActionMapping}.
*
* @param string $name - route name
*
Expand Down Expand Up @@ -1573,9 +1571,9 @@ function route($name) {


/**
* Return a {@link Url} helper for the given URI. An URI starting with a slash "/" is interpreted as relative to the
* application's base URI. An URI not starting with a slash is interpreted as relative to the application {@link Module}'s
* base URI (the module the current request belongs to).<br>
* Return a {@link \rosasurfer\ministruts\url\Url} helper for the given URI. An URI starting with a slash "/" is interpreted
* as relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link \rosasurfer\ministruts\Module}'s base URI (the module the current request belongs to).<br>
*
* Procedural equivalent of <tt>new \rosasurfer\ministruts\url\Url($uri)</tt>.
*
Expand All @@ -1589,9 +1587,9 @@ function url($uri) {


/**
* Return a version-aware URL helper for the given URI {@link VersionedUrl}. An URI starting with a slash "/" is interpreted
* as relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link Module}'s base URI (the module the current request belongs to).<br>
* Return a version-aware URL helper for the given URI {@link \rosasurfer\ministruts\url\VersionedUrl}. An URI starting with a slash "/"
* is interpreted as relative to the application's base URI. An URI not starting with a slash is interpreted as relative to the application
* {@link \rosasurfer\ministruts\Module}'s base URI (the module the current request belongs to).<br>
*
* Procedural equivalent of <tt>new \rosasurfer\ministruts\url\VersionedUrl($uri)</tt>.
*
Expand Down
11 changes: 5 additions & 6 deletions src/ministruts/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public function getPostParameters($name) {
* Return an object-oriented representation of the uploaded files. The broken PHP array structure of uploaded files is
* converted to regular file arrays.
*
* @TODO: convert file data to {@link UploadedFile} instances
* @TODO: convert file data to UploadedFile instances
*
* @return array - associative array of files
*/
Expand All @@ -276,7 +276,7 @@ public function getFiles() {
if (isSet($file['name']) && is_array($file['name'])) {
$properties = \array_keys($file);
$normalized = [];
foreach (\array_keys($file['name']) as $name) {
foreach ($file['name'] as $name => $v) {
foreach ($properties as $property) {
$normalized[$name][$property] = $file[$property][$name];
}
Expand All @@ -286,11 +286,10 @@ public function getFiles() {
}
return $file;
};

$files = [];
if (isSet($_FILES)) {
foreach ($_FILES as $key => $file) {
$files[$key] = $normalizeLevel($file);
}
foreach ($_FILES as $key => $file) {
$files[$key] = $normalizeLevel($file);
}
}
return $files;
Expand Down
2 changes: 1 addition & 1 deletion src/ministruts/RequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function processSession(Request $request) {


/**
* Moves all ActionMessages (including ActionErrors) from the current {@link Request} to the session.
* Moves all ActionMessages (including ActionErrors) from the current equest} to the session.
* At the next request the messages are restored and moved back to the new request.
*
* @param Request $request
Expand Down
4 changes: 2 additions & 2 deletions src/ministruts/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@
const ACTION_MAPPING_KEY = 'org.apache.struts.action.MAPPING';

/**
* Session key under which the currently selected {@link Locale} is stored.
* Session key under which the currently selected locale is stored.
*/
const LOCALE_KEY = 'org.apache.struts.action.LOCALE';

/**
* Request key under which available {@link MessageResource}s are stored (i18n).
* Request key under which available message resources are stored (i18n).
*/
const MESSAGES_KEY = 'org.apache.struts.action.MESSAGE_RESOURCES';

Expand Down
4 changes: 2 additions & 2 deletions src/net/http/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function setHeader($name, $value) {

// alle vorhandenen Header dieses Namens suchen und loeschen (unabhaengig von Gross-/Kleinschreibung)
$intersect = \array_intersect_ukey($this->headers, array($name => 1), 'strCaseCmp');
foreach (\array_keys($intersect) as $key) {
foreach ($intersect as $key => $v) {
unset($this->headers[$key]);
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public function addHeader($name, $value) {

// vorhandene Header dieses Namens suchen und loeschen (unabhaengig von Gross-/Kleinschreibung)
$intersect = \array_intersect_ukey($this->headers, array($name => 1), 'strCaseCmp');
foreach (\array_keys($intersect) as $key) {
foreach ($intersect as $key => $v) {
unset($this->headers[$key]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public static function phpinfo() {
if (is_file($file=$appRoot.'/composer.json') && extension_loaded('json')) {
$composer = json_decode(file_get_contents($file), true);
if (isSet($composer['require']) && is_array($composer['require'])) {
foreach (\array_keys($composer['require']) as $name) {
foreach ($composer['require'] as $name => $v) {
$name = trim(strtolower($name));
if (in_array($name, ['php', 'php-64bit', 'hhvm']) || strContains($name, '/')) continue;
if (strStartsWith($name, 'ext-')) $name = strRight($name, -4);
Expand Down

0 comments on commit cfac20a

Please sign in to comment.