Skip to content

Commit

Permalink
Scrutinizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 1, 2018
1 parent 94d61b2 commit 44c4080
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 34 deletions.
9 changes: 6 additions & 3 deletions src/SAML2/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,9 @@ private function parseAttributeValue($attribute, $attributeName)
} else {
/* Fall back for legacy IdPs sending string value (e.g. SSP < 1.15) */
Utils::getContainer()->getLogger()->warning(sprintf("Attribute %s (EPTI) value %d is not an XML NameId", $attributeName, $index));
$this->attributes[$attributeName][] = XML\saml\NameID::fromArray(['Value' => $eptiAttributeValue->textContent]);
$nameId = new XML\saml\NameID();
$nameId->setValue($eptiAttributeValue->textContent);
$this->attributes[$attributeName][] = $nameId;
}
}

Expand Down Expand Up @@ -766,6 +768,7 @@ public function setNameId($nameId)
assert(is_array($nameId) || is_null($nameId) || $nameId instanceof XML\saml\NameID);

if (is_array($nameId)) {
// @deprecated behaviour
$nameId = XML\saml\NameID::fromArray($nameId);
}
$this->nameId = $nameId;
Expand Down Expand Up @@ -1147,7 +1150,7 @@ public function getSignatureMethod()
/**
* Set the signature method used.
*
* @param string|null $signatureMethod.
* @param string|null $signatureMethod
*/
public function setSignatureMethod($signatureMethod)
{
Expand Down Expand Up @@ -1189,7 +1192,7 @@ public function getAuthnContextDecl()
/**
* Set the authentication context declaration reference.
*
* @param string $authnContextDeclRef
* @param string|\SAML2\XML\Chunk $authnContextDeclRef
* @throws \Exception
*/
public function setAuthnContextDeclRef($authnContextDeclRef)
Expand Down
14 changes: 7 additions & 7 deletions src/SAML2/AuthnRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class AuthnRequest extends Request
*
* @var array
*/
private $audiences;
private $audiences = [];

/**
* @var \SAML2\XML\saml\SubjectConfirmation[]
Expand Down Expand Up @@ -441,7 +441,7 @@ public function setIsPassive($isPassive)
*
* This may be null, in which case no audience is included.
*
* @return array|null The audiences.
* @return array The audiences.
*/
public function getAudiences()
{
Expand All @@ -455,7 +455,7 @@ public function getAudiences()
*
* @param array|null $audiences The audiences.
*/
public function setAudiences(array $audiences = null)
public function setAudiences(array $audiences)
{
$this->audiences = $audiences;
}
Expand Down Expand Up @@ -626,11 +626,11 @@ public function getRequestedAuthnContext()
/**
* Set the RequestedAuthnContext.
*
* @param array|null $requestedAuthnContext The RequestedAuthnContext.
* @param array $requestedAuthnContext The RequestedAuthnContext.
*/
public function setRequestedAuthnContext($requestedAuthnContext)
{
assert(is_array($requestedAuthnContext) || is_null($requestedAuthnContext));
assert(is_array($requestedAuthnContext));

$this->requestedAuthnContext = $requestedAuthnContext;
}
Expand Down Expand Up @@ -872,7 +872,7 @@ private function addSubject(\DOMElement $root)
*/
private function addConditions(\DOMElement $root)
{
if ($this->audiences !== null) {
if ($this->audiences !== []) {
$document = $root->ownerDocument;

$conditions = $document->createElementNS(Constants::NS_SAML, 'saml:Conditions');
Expand All @@ -881,7 +881,7 @@ private function addConditions(\DOMElement $root)
$ar = $document->createElementNS(Constants::NS_SAML, 'saml:AudienceRestriction');
$conditions->appendChild($ar);

Utils::addStrings($ar, Constants::NS_SAML, 'saml:Audience', false, $this->audiences);
Utils::addStrings($ar, Constants::NS_SAML, 'saml:Audience', false, $this->getAudiences());
}
}
}
2 changes: 1 addition & 1 deletion src/SAML2/Compat/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract public function generateId();
* - **encrypt** XML that is about to be encrypted
* - **decrypt** XML that was just decrypted
*
* @param string $message
* @param string|\DOMNode $message
* @param string $type
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions src/SAML2/Compat/ContainerSingleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
class ContainerSingleton
{
/**
* @var \SAML2\Compat\Ssp\Container
* @var \SAML2\Compat\AbstractContainer
*/
protected static $container;

/**
* @return \SAML2\Compat\Ssp\Container
* @return \SAML2\Compat\AbstractContainer
*/
public static function getInstance()
{
Expand Down
10 changes: 4 additions & 6 deletions src/SAML2/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class Message implements SignedElement
*
* @var array
*/
protected $extensions;
protected $extensions = [];

/**
* The name of the root element of the DOM tree for the message.
Expand Down Expand Up @@ -589,7 +589,7 @@ public static function fromXML(\DOMElement $xml)
/**
* Retrieve the Extensions.
*
* @return \SAML2\XML\samlp\Extensions
* @return \SAML2\XML\samlp\Extensions[]
*/
public function getExtensions()
{
Expand All @@ -599,12 +599,10 @@ public function getExtensions()
/**
* Set the Extensions.
*
* @param array|null $extensions The Extensions
* @param array $extensions The Extensions
*/
public function setExtensions($extensions)
public function setExtensions(array $extensions)
{
assert(is_array($extensions) || is_null($extensions));

$this->extensions = $extensions;
}

Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/SOAPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static function validateSSL($data, XMLSecurityKey $key)
/*
* Extracts the SOAP Fault from SOAP message
* @param $soapmessage Soap response needs to be type DOMDocument
* @return $soapfaultstring string|null
* @return string|null $soapfaultstring
*/
private function getSOAPFault($soapMessage)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/ecp/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getAssertionConsumerServiceURL()

/**
* Set the value of the AssertionConsumerServiceURL-property
* @param string $AssertionConsumerServiceURL
* @param string $assertionConsumerServiceURL
*/
public function setAssertionConsumerServiceURL($assertionConsumerServiceURL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/md/EntitiesDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function __construct(\DOMElement $xml = null)
*/
public function getName()
{
return $this->name;
return $this->Name;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/SAML2/XML/md/EntityDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ public function setRoleDescriptor(array $roleDescriptor)

/**
* Add the value to the RoleDescriptor-property
* @param \SAML2\XML\md\Role $roleDescriptor
* @param \SAML2\XML\md\RoleDescriptor $roleDescriptor
*/
public function addRoleDescriptor($roleDescriptor)
public function addRoleDescriptor(RoleDescriptor $roleDescriptor)
{
$this->RoleDescriptor[] = $roleDescriptor;
}
Expand All @@ -312,7 +312,7 @@ public function getAffiliationDescriptor()

/**
* Set the value of the AffliationDescriptor-property
* @param \SAML2\XML\md\AffiliationDescriptor $affiliationDescriptor|null
* @param \SAML2\XML\md\AffiliationDescriptor|null $affiliationDescriptor
*/
public function setAffiliationDescriptor(AffiliationDescriptor $affiliationDescriptor = null)
{
Expand All @@ -330,7 +330,7 @@ public function getOrganization()

/**
* Set the value of the Organization-property
* @param \SAML2\XML\md\Organization $organization|null
* @param \SAML2\XML\md\Organization|null $organization
*/
public function setOrganization(Organization $organization = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/md/PDPDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getAuthzService()

/**
* Set the value of the AuthzService-property
* @param \SAML2\XML\md\EndpointType[] $AuthzService
* @param \SAML2\XML\md\EndpointType[] $authzService
*/
public function setAuthzService(array $authzService = [])
{
Expand Down
4 changes: 2 additions & 2 deletions src/SAML2/XML/md/RoleDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function __construct($elementName, \DOMElement $xml = null)
}

foreach (Utils::xpQuery($xml, './saml_metadata:ContactPerson') as $cp) {
$this->addContactPersons(ContactPerson($cp));
$this->addContactPerson(ContactPerson($cp));
}
}

Expand Down Expand Up @@ -270,7 +270,7 @@ public function getOrganization()

/**
* Set the value of the Organization-property
* @param \SAML2\XML\md\Organization $organization|null
* @param \SAML2\XML\md\Organization|null $organization
*/
public function setOrganization(Organization $organization = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/md/SSODescriptorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function setArtifactResolutionService(array $artifactResolutionService)

/**
* Add the value to the ArtifactResolutionService-property
* @param \SAML2\XML\md\IndexedEndpointType $artifactResolucationService
* @param \SAML2\XML\md\IndexedEndpointType $artifactResolutionService
*/
public function addArtifactResolutionService(IndexedEndpointType $artifactResolutionService)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/mdattr/EntityAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function setChildren(array $children)

/**
* Add the value to the children-property
* @param \SAML2\XML\Chunk $child
* @param \SAML2\XML\Chunk|\SAML2\XML\saml\Attribute $child
*/
public function addChildren($child)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/saml/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getNameFormat()

/**
* Set the value of the NameFormat-property
* @param string|null $NameFormat
* @param string|null $nameFormat
*/
public function setNameFormat($nameFormat = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SAML2/XML/shibmd/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setIsRegexpScope($regexp)
public function toXML(\DOMElement $parent)
{
assert(is_string($this->getScope()));
assert(is_bool($this->isRegexpScope()) || is_null($this->isRRegexpScope()));
assert(is_bool($this->isRegexpScope()) || is_null($this->isRegexpScope()));

$doc = $parent->ownerDocument;

Expand Down
4 changes: 3 additions & 1 deletion tests/SAML2/LogoutRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ public function testGetNotOnOrAfter()
public function testSetNotOnOrAfter()
{
$time = time();
$nameId = new XML\saml\NameID();
$nameId->setValue('NameIDValue');

$logoutRequest = new LogoutRequest();
$logoutRequest->setNameID(['Value' => 'NameIDValue']);
$logoutRequest->setNameID($nameId);
$logoutRequest->setNotOnOrAfter($time);
$logoutRequestElement = $logoutRequest->toUnsignedXML();

Expand Down

0 comments on commit 44c4080

Please sign in to comment.