Skip to content

Commit

Permalink
Fix commenting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rbairwell committed Jun 2, 2016
1 parent 83358d5 commit 545496e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/MiddlewareCors.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ public function setLogger(LoggerInterface $logger = null)
/**
* Add a log string if we have a logger.
*
* @param string $string String to log.
* @param array $logData Additional data to log.
* @param string $string String to log.
* @param array $logData Additional data to log.
*
* @return bool True if logged, false if no logger.
*/
public function addLog(string $string,array $logData=[]) : bool
public function addLog(string $string, array $logData = []) : bool
{
if (null !== $this->logger) {
$this->logger->debug('CORs: '.$string, $logData);
Expand Down Expand Up @@ -239,8 +239,8 @@ public function __invoke(
// and the credentials field returned (if they are applicable).
// All other fields are "request specific" (either preflight or not).
// set the Access-Control-Allow-Origin header. Uses origin configuration setting.
$allowedOrigins=[];
$origin = $this->parseOrigin($request,$allowedOrigins);
$allowedOrigins = [];
$origin = $this->parseOrigin($request, $allowedOrigins);
// check the origin is one of the allowed ones.
if ('' === $origin) {
$exception = new BadOrigin('Bad Origin');
Expand Down
4 changes: 2 additions & 2 deletions src/MiddlewareCors/Preflight.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ final protected function accessControlRequestHeaders(
// loop through each of their provided headers
foreach ($requestHeaders as $header) {
// if we are unable to find a match for the header, block it for security.
if (false === in_array($header, $allowedHeaders,true)) {
if (false === in_array($header, $allowedHeaders, true)) {
// block it
$exception = new HeaderNotAllowed(sprintf('Header "%s" not allowed',$header));
$exception = new HeaderNotAllowed(sprintf('Header "%s" not allowed', $header));
$exception->setAllowed($allowedHeaders)
->setSent($originalRequestHeaders);
throw $exception;
Expand Down
11 changes: 6 additions & 5 deletions src/MiddlewareCors/Traits/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ protected function parseMaxAge(ServerRequestInterface $request) : int
* Parse the origin setting using wildcards where necessary.
* Can return * for "all hosts", '' for "no origin/do not allow" or a string/hostname.
*
* @param ServerRequestInterface $request The server request with the origin header.
* @param ServerRequestInterface $request The server request with the origin header.
* @param array|callable $allowedOrigins The returned list of allowed origins found.
*
* @return string
*/
protected function parseOrigin(ServerRequestInterface $request,array &$allowedOrigins=[]) : string
protected function parseOrigin(ServerRequestInterface $request, array &$allowedOrigins = []) : string
{
// read the client provided origin header
$origin = $request->getHeaderLine('origin');
Expand Down Expand Up @@ -198,7 +199,7 @@ protected function parseOrigin(ServerRequestInterface $request,array &$allowedOr
if (true === is_array($originSetting)) {
$this->addLog('Iterating through Origin array');
foreach ($originSetting as $item) {
$allowedOrigins[]=$item;
$allowedOrigins[] = $item;
// see if the origin matches (the parseOriginMatch function supports
// wildcards)
$matched = $this->parseOriginMatch($item, $originHost);
Expand All @@ -215,8 +216,8 @@ protected function parseOrigin(ServerRequestInterface $request,array &$allowedOr
// is to try to match it as a string (if applicable)
if ('' === $matched && true === is_string($originSetting)) {
$this->addLog('Attempting to match origin as string');
$allowedOrigins[]=$originSetting;
$matched = $this->parseOriginMatch($originSetting, $originHost);
$allowedOrigins[] = $originSetting;
$matched = $this->parseOriginMatch($originSetting, $originHost);
}

// return the matched setting (may be '' to indicate nothing matched)
Expand Down

0 comments on commit 545496e

Please sign in to comment.