Skip to content

Commit

Permalink
qa: remove BC breaks and ensure conforms to CS guidelines
Browse files Browse the repository at this point in the history
- Removes docblock headers from new files
- Ensures all types are documented in new interface and test assets
- Do not have SameSiteCookieCapableInterface extend ConfigInterface, and StandardConfig implement SameSiteCookieCapableInterface; instead, have StandarConfig implement both ConfigInterface and SameSiteCookieCapableInterface.

Signed-off-by: Matthew Weier O'Phinney <[email protected]>
  • Loading branch information
weierophinney committed Jun 30, 2021
1 parent fa47772 commit 358c0a3
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/book/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Option | Data Type | Description
`cookie_httponly` | `boolean` | Marks the cookie as accessible only through the HTTP protocol.
`cookie_lifetime` | `integer` | Specifies the lifetime of the cookie in seconds which is sent to the browser.
`cookie_path` | `string` | Specifies path to set in the session cookie.
`cookie_samesite` | `string` | Specifies whether cookies should be sent along with cross-site requests.
`cookie_samesite` | `string` | Specifies whether cookies should be sent along with cross-site requests. (Since 2.11.0)
`cookie_secure` | `boolean` | Specifies whether cookies should only be sent over secure connections.
`entropy_length` | `integer` | Specifies the number of bytes which will be read from the file specified in entropy_file. Removed in PHP 7.1.0.
`entropy_file` | `string` | Defines a path to an external resource (file) which will be used as an additional entropy. Removed in PHP 7.1.0.
Expand Down
16 changes: 8 additions & 8 deletions src/Config/SameSiteCookieCapableInterface.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

/**
* @see https://github.com/laminas/laminas-session for the canonical source repository
* @copyright https://github.com/laminas/laminas-session/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-session/blob/master/LICENSE.md New BSD License
*/

namespace Laminas\Session\Config;

interface SameSiteCookieCapableInterface extends ConfigInterface
interface SameSiteCookieCapableInterface
{
/**
* @param string $cookieSameSite
* @return self
*/
public function setCookieSameSite($cookieSameSite);

/** @return string */
public function getCookieSameSite();
}
}
2 changes: 1 addition & 1 deletion src/Config/StandardConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* Standard session configuration
*/
class StandardConfig implements SameSiteCookieCapableInterface
class StandardConfig implements ConfigInterface, SameSiteCookieCapableInterface
{
/**
* session.name
Expand Down
3 changes: 2 additions & 1 deletion src/Service/SessionConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $
&& ! $sessionConfig instanceof SameSiteCookieCapableInterface
) {
throw new ServiceNotCreatedException(sprintf(
'Invalid configuration class "%s". When configuration option "cookie_samesite" is used, the configuration class must implement %s',
'Invalid configuration class "%s". When configuration option "cookie_samesite" is used,'
. ' the configuration class must implement %s',
$class,
SameSiteCookieCapableInterface::class
));
Expand Down
6 changes: 3 additions & 3 deletions test/Service/SessionConfigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace LaminasTest\Session\Service;

use Laminas\ServiceManager\Config;
use Laminas\ServiceManager\ServiceManager;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Session\Config\ConfigInterface;
use Laminas\Session\Config\SessionConfig;
use Laminas\Session\Config\StandardConfig;
Expand Down Expand Up @@ -82,13 +82,13 @@ public function testServiceNotCreatedWhenInvalidSamesiteConfig()
'config',
[
'session_config' => [
'config_class' => TestConfig::class,
'config_class' => TestConfig::class,
'cookie_samesite' => 'Lax',
],
]
);
$this->expectException(ServiceNotCreatedException::class);
$this->expectExceptionMessage('Invalid configuration class "LaminasTest\Session\TestAsset\TestConfig". When configuration option "cookie_samesite" is used, the configuration class must implement Laminas\Session\Config\SameSiteCookieCapableInterface');
$this->expectExceptionMessage('"cookie_samesite"');
$this->services->get(ConfigInterface::class);
}
}
96 changes: 65 additions & 31 deletions test/TestAsset/TestConfig.php
Original file line number Diff line number Diff line change
@@ -1,134 +1,168 @@
<?php

/**
* @see https://github.com/laminas/laminas-session for the canonical source repository
* @copyright https://github.com/laminas/laminas-session/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-session/blob/master/LICENSE.md New BSD License
*/

namespace LaminasTest\Session\TestAsset;

use Laminas\Session\Config\ConfigInterface;

class TestConfig implements ConfigInterface
{
/**
* @param array $options
* @return void
*/
public function setOptions($options)
{
return;
}

/** @return void */
public function getOptions()
{
return;
}

/**
* @param string $option
* @param mixed $value
* @return void
*/
public function setOption($option, $value)
{
return;
}

/**
* @param string $option
* @return void
*/
public function getOption($option)
{
return;
}

/**
* @param string $option
* @return void
*/
public function hasOption($option)
{
return;
}

/** @return void */
public function toArray()
{
return;
}

/**
* @param string $name
* @return void
*/
public function setName($name)
{
return;
}

/** @return void */
public function getName()
{
return;
}

/**
* @param string $savePath
* @return void
*/
public function setSavePath($savePath)
{
return;
}

/** @return void */
public function getSavePath()
{
return;
}

/**
* @param int $cookieLifetime
* @return void
*/
public function setCookieLifetime($cookieLifetime)
{
return;
}

/** @return void */
public function getCookieLifetime()
{
return;
}

/**
* @param string $cookiePath
* @return void
*/
public function setCookiePath($cookiePath)
{
return;
}

/** @return void */
public function getCookiePath()
{
return;
}

/**
* @param string $cookieDomain
* @return void
*/
public function setCookieDomain($cookieDomain)
{
return;
}

/** @return void */
public function getCookieDomain()
{
return;
}

/**
* @param bool $cookieSecure
* @return void
*/
public function setCookieSecure($cookieSecure)
{
return;
}

/** @return void */
public function getCookieSecure()
{
return;
}

/**
* @param bool $cookieHttpOnly
* @return void
*/
public function setCookieHttpOnly($cookieHttpOnly)
{
return;
}

/** @return void */
public function getCookieHttpOnly()
{
return;
}

/**
* @param bool $useCookies
* @return void
*/
public function setUseCookies($useCookies)
{
return;
}

/** @return void */
public function getUseCookies()
{
return;
}

/**
* @param int $rememberMeSeconds
* @return void
*/
public function setRememberMeSeconds($rememberMeSeconds)
{
return;
}

/** @return void */
public function getRememberMeSeconds()
{
return;
}
}
}

0 comments on commit 358c0a3

Please sign in to comment.