From 3b4178d6e25031d84ff224711dd57a6e93584462 Mon Sep 17 00:00:00 2001 From: Arno van der Vegt <arnovandervegt@startmail.com> Date: Wed, 17 Oct 2018 09:09:39 +0200 Subject: [PATCH] Converted array declarations (#959) --- attributemap/addurnprefix.php | 4 +- attributemap/deprecatedSchacNS.php | 4 +- attributemap/facebook2name.php | 4 +- attributemap/feide-oid.php | 4 +- attributemap/linkedin2name.php | 4 +- attributemap/name2claim.php | 4 +- attributemap/name2oid.php | 4 +- attributemap/name2urn.php | 4 +- attributemap/newSchacNS.php | 4 +- attributemap/oid-feide.php | 4 +- attributemap/oid2name.php | 4 +- attributemap/oid2urn.php | 4 +- attributemap/openid2name.php | 4 +- attributemap/removeurnprefix.php | 4 +- attributemap/test.php | 4 +- attributemap/twitter2name.php | 4 +- attributemap/urn2name.php | 4 +- attributemap/urn2oid.php | 4 +- attributemap/windowslive2name.php | 4 +- bin/importPdoMetadata.php | 2 +- bin/memcacheSync.php | 6 +- config-templates/acl.php | 86 ++--- config-templates/authmemcookie.php | 4 +- config-templates/authsources.php | 12 +- config-templates/config.php | 72 ++-- docs/simplesamlphp-advancedfeatures.md | 4 +- docs/simplesamlphp-artifact-idp.md | 24 +- docs/simplesamlphp-artifact-sp.md | 4 +- docs/simplesamlphp-authproc.md | 28 +- docs/simplesamlphp-automated_metadata.md | 62 ++-- docs/simplesamlphp-customauth.md | 56 +-- docs/simplesamlphp-database.md | 20 +- docs/simplesamlphp-ecp-idp.md | 4 +- docs/simplesamlphp-errorhandling.md | 4 +- docs/simplesamlphp-googleapps.md | 28 +- docs/simplesamlphp-hok-idp.md | 12 +- docs/simplesamlphp-hok-sp.md | 4 +- docs/simplesamlphp-idp.md | 50 +-- docs/simplesamlphp-maintenance.md | 46 +-- docs/simplesamlphp-metadata-endpoints.md | 24 +- ...esamlphp-metadata-extensions-attributes.md | 36 +- docs/simplesamlphp-metadata-extensions-rpi.md | 50 +-- docs/simplesamlphp-metadata-extensions-ui.md | 174 ++++----- ...implesamlphp-metadata-pdostoragehandler.md | 8 +- docs/simplesamlphp-modules.md | 12 +- docs/simplesamlphp-reference-idp-hosted.md | 36 +- docs/simplesamlphp-reference-idp-remote.md | 16 +- docs/simplesamlphp-reference-sp-remote.md | 18 +- docs/simplesamlphp-scoping.md | 4 +- docs/simplesamlphp-sp-api.md | 24 +- docs/simplesamlphp-sp-migration.md | 12 +- docs/simplesamlphp-sp.md | 36 +- lib/SimpleSAML/Auth/Default.php | 4 +- lib/SimpleSAML/Auth/LDAP.php | 16 +- lib/SimpleSAML/Auth/ProcessingChain.php | 10 +- lib/SimpleSAML/Auth/Simple.php | 22 +- lib/SimpleSAML/Auth/Source.php | 24 +- lib/SimpleSAML/Auth/State.php | 10 +- lib/SimpleSAML/Bindings/Shib13/Artifact.php | 16 +- lib/SimpleSAML/Bindings/Shib13/HTTPPost.php | 8 +- lib/SimpleSAML/Configuration.php | 54 +-- lib/SimpleSAML/Database.php | 24 +- lib/SimpleSAML/Error/Assertion.php | 2 +- lib/SimpleSAML/Error/AuthSource.php | 4 +- lib/SimpleSAML/Error/BadRequest.php | 2 +- lib/SimpleSAML/Error/ConfigurationError.php | 2 +- .../Error/CriticalConfigurationError.php | 4 +- lib/SimpleSAML/Error/Error.php | 8 +- lib/SimpleSAML/Error/ErrorCodes.php | 16 +- lib/SimpleSAML/Error/Exception.php | 22 +- lib/SimpleSAML/Error/MetadataNotFound.php | 4 +- lib/SimpleSAML/Error/NotFound.php | 8 +- lib/SimpleSAML/IdP.php | 18 +- lib/SimpleSAML/IdP/IFrameLogoutHandler.php | 6 +- .../IdP/TraditionalLogoutHandler.php | 2 +- lib/SimpleSAML/Locale/Language.php | 24 +- lib/SimpleSAML/Locale/Localization.php | 2 +- lib/SimpleSAML/Locale/Translate.php | 20 +- lib/SimpleSAML/Logger.php | 20 +- .../Logger/ErrorLogLoggingHandler.php | 8 +- lib/SimpleSAML/Logger/FileLoggingHandler.php | 10 +- .../Logger/SyslogLoggingHandler.php | 4 +- lib/SimpleSAML/Memcache.php | 10 +- .../Metadata/MetaDataStorageHandler.php | 6 +- .../MetaDataStorageHandlerFlatFile.php | 6 +- .../Metadata/MetaDataStorageHandlerPdo.php | 20 +- .../MetaDataStorageHandlerSerialize.php | 4 +- .../Metadata/MetaDataStorageHandlerXML.php | 16 +- .../Metadata/MetaDataStorageSource.php | 6 +- lib/SimpleSAML/Metadata/SAMLBuilder.php | 46 +-- lib/SimpleSAML/Metadata/SAMLParser.php | 90 ++--- lib/SimpleSAML/Metadata/Signer.php | 26 +- lib/SimpleSAML/Metadata/Sources/MDQ.php | 2 +- lib/SimpleSAML/Module.php | 16 +- lib/SimpleSAML/Session.php | 38 +- lib/SimpleSAML/SessionHandler.php | 4 +- lib/SimpleSAML/SessionHandlerPHP.php | 4 +- lib/SimpleSAML/Stats.php | 6 +- lib/SimpleSAML/Store/Redis.php | 8 +- lib/SimpleSAML/Store/SQL.php | 36 +- lib/SimpleSAML/Utilities.php | 16 +- lib/SimpleSAML/Utils/Arrays.php | 6 +- lib/SimpleSAML/Utils/Attributes.php | 4 +- lib/SimpleSAML/Utils/Auth.php | 2 +- lib/SimpleSAML/Utils/Config/Metadata.php | 8 +- lib/SimpleSAML/Utils/Crypto.php | 12 +- lib/SimpleSAML/Utils/HTTP.php | 44 +-- lib/SimpleSAML/Utils/HttpAdapter.php | 6 +- lib/SimpleSAML/Utils/Net.php | 4 +- lib/SimpleSAML/Utils/XML.php | 16 +- lib/SimpleSAML/XHTML/EMail.php | 2 +- lib/SimpleSAML/XHTML/IdPDisco.php | 18 +- lib/SimpleSAML/XHTML/Template.php | 52 +-- lib/SimpleSAML/XHTML/TemplateLoader.php | 6 +- lib/SimpleSAML/XML/Errors.php | 6 +- lib/SimpleSAML/XML/Shib13/AuthnRequest.php | 2 +- lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 14 +- lib/SimpleSAML/XML/Signer.php | 14 +- lib/SimpleSAML/XML/Validator.php | 20 +- lib/_autoload_modules.php | 4 +- metadata-templates/adfs-idp-hosted.php | 10 +- metadata-templates/adfs-sp-remote.php | 12 +- metadata-templates/saml20-idp-hosted.php | 4 +- metadata-templates/saml20-sp-remote.php | 12 +- metadata-templates/shib13-idp-hosted.php | 4 +- metadata-templates/shib13-sp-hosted.php | 4 +- metadata-templates/shib13-sp-remote.php | 4 +- metadata-templates/wsfed-idp-remote.php | 4 +- metadata-templates/wsfed-sp-hosted.php | 4 +- modules/adfs/lib/IdP/ADFS.php | 26 +- .../XML/fed/SecurityTokenServiceType.php | 2 +- modules/adfs/www/idp/metadata.php | 42 +-- .../lib/Auth/Process/ExpiryWarning.php | 2 +- .../authX509/lib/Auth/Source/X509userCert.php | 6 +- modules/authX509/templates/X509warning.php | 8 +- modules/authX509/www/expirywarning.php | 2 +- .../lib/Auth/Process/OTP2YubiPrefix.php | 2 +- .../authYubiKey/lib/Auth/Source/YubiKey.php | 4 +- modules/authYubiKey/libextinc/Yubico.php | 2 +- modules/authYubiKey/www/yubikeylogin.php | 2 +- modules/authcrypt/lib/Auth/Source/Hash.php | 2 +- .../authcrypt/lib/Auth/Source/Htpasswd.php | 6 +- .../authfacebook/extlibinc/base_facebook.php | 64 ++-- .../authfacebook/lib/Auth/Source/Facebook.php | 18 +- modules/authfacebook/lib/Facebook.php | 8 +- .../authlinkedin/lib/Auth/Source/LinkedIn.php | 18 +- .../authorize/lib/Auth/Process/Authorize.php | 8 +- modules/authorize/www/authorize_403.php | 2 +- .../authtwitter/lib/Auth/Source/Twitter.php | 18 +- .../lib/Auth/Source/LiveID.php | 24 +- modules/cas/lib/Auth/Source/CAS.php | 22 +- modules/cdc/config-templates/module_cdc.php | 8 +- modules/cdc/lib/Auth/Process/CDC.php | 6 +- modules/cdc/lib/Client.php | 2 +- modules/cdc/lib/Server.php | 24 +- modules/consent/dictionaries/consent.php | 88 ++--- modules/consent/lib/Auth/Process/Consent.php | 10 +- modules/consent/lib/Consent/Store/Cookie.php | 6 +- .../consent/lib/Consent/Store/Database.php | 38 +- modules/consent/lib/Store.php | 2 +- modules/consent/www/getconsent.php | 24 +- modules/consent/www/logout.php | 2 +- modules/consent/www/noconsent.php | 10 +- .../config-templates/module_consentAdmin.php | 10 +- modules/consentAdmin/hooks/hook_frontpage.php | 4 +- .../consentAdmin/templates/consentadmin.php | 2 +- modules/consentAdmin/www/consentAdmin.php | 18 +- modules/core/hooks/hook_frontpage.php | 16 +- modules/core/hooks/hook_sanitycheck.php | 6 +- modules/core/lib/ACL.php | 8 +- .../core/lib/Auth/Process/AttributeAdd.php | 4 +- .../core/lib/Auth/Process/AttributeAlter.php | 8 +- .../core/lib/Auth/Process/AttributeCopy.php | 2 +- .../core/lib/Auth/Process/AttributeLimit.php | 4 +- .../core/lib/Auth/Process/AttributeMap.php | 6 +- .../core/lib/Auth/Process/AttributeRealm.php | 2 +- .../lib/Auth/Process/AttributeValueMap.php | 6 +- modules/core/lib/Auth/Process/Cardinality.php | 22 +- .../lib/Auth/Process/CardinalitySingle.php | 16 +- .../core/lib/Auth/Process/GenerateGroups.php | 6 +- .../core/lib/Auth/Process/LanguageAdaptor.php | 2 +- .../core/lib/Auth/Process/ScopeAttribute.php | 2 +- .../lib/Auth/Process/ScopeFromAttribute.php | 2 +- modules/core/lib/Auth/Process/TargetedID.php | 2 +- .../lib/Auth/Process/WarnShortSSOInterval.php | 2 +- .../core/lib/Auth/Source/AdminPassword.php | 2 +- modules/core/lib/Auth/UserPassBase.php | 2 +- modules/core/lib/Auth/UserPassOrgBase.php | 4 +- modules/core/lib/Stats/Output/Log.php | 2 +- .../core/lib/Storage/SQLPermanentStorage.php | 22 +- .../core/templates/cardinality_error.tpl.php | 2 +- .../templates/frontpage_federation.tpl.php | 2 +- modules/core/templates/logout-iframe.php | 16 +- modules/core/www/as_login.php | 4 +- modules/core/www/authenticate.php | 6 +- modules/core/www/cardinality_error.php | 2 +- modules/core/www/cleardiscochoices.php | 2 +- modules/core/www/frontpage_auth.php | 18 +- modules/core/www/frontpage_config.php | 98 ++--- modules/core/www/frontpage_federation.php | 36 +- modules/core/www/frontpage_welcome.php | 18 +- modules/core/www/idp/logout-iframe-done.php | 8 +- modules/core/www/idp/logout-iframe-post.php | 6 +- modules/core/www/idp/logout-iframe.php | 16 +- modules/core/www/login.php | 6 +- modules/core/www/loginuserpass.php | 12 +- modules/core/www/loginuserpassorg.php | 12 +- modules/core/www/short_sso_interval.php | 2 +- modules/core/www/show_metadata.php | 2 +- modules/cron/config-templates/module_cron.php | 6 +- modules/cron/hooks/hook_frontpage.php | 4 +- modules/cron/lib/Cron.php | 6 +- modules/cron/www/croninfo.php | 12 +- .../config-templates/module_discopower.php | 6 +- modules/discopower/lib/PowerIdPDisco.php | 32 +- modules/discopower/templates/disco.tpl.php | 2 +- modules/discopower/www/disco.php | 2 +- .../www/attributeserver.php | 16 +- .../lib/Auth/Process/RedirectTest.php | 4 +- .../exampleauth/lib/Auth/Source/External.php | 22 +- .../exampleauth/lib/Auth/Source/UserPass.php | 2 +- modules/exampleauth/www/authpage.php | 12 +- modules/exampleauth/www/redirecttest.php | 2 +- .../lib/Auth/Process/ExpiryDate.php | 4 +- modules/expirycheck/templates/expired.php | 2 +- modules/expirycheck/www/about2expire.php | 26 +- .../lib/Auth/Process/AttributeAddFromLDAP.php | 8 +- .../Auth/Process/AttributeAddUsersGroups.php | 26 +- modules/ldap/lib/Auth/Process/BaseFilter.php | 10 +- modules/ldap/lib/Auth/Source/LDAPMulti.php | 6 +- .../memcacheMonitor/hooks/hook_frontpage.php | 4 +- .../templates/memcachestat.tpl.php | 2 +- modules/memcacheMonitor/www/memcachestat.php | 12 +- modules/metarefresh/bin/metarefresh.php | 8 +- .../config-templates/config-metarefresh.php | 42 +-- modules/metarefresh/hooks/hook_cron.php | 16 +- modules/metarefresh/hooks/hook_frontpage.php | 4 +- modules/metarefresh/lib/MetaLoader.php | 24 +- modules/metarefresh/www/fetch.php | 12 +- .../multiauth/lib/Auth/Source/MultiAuth.php | 16 +- .../negotiate/lib/Auth/Source/Negotiate.php | 16 +- modules/negotiate/templates/disable.php | 2 +- modules/negotiate/templates/enable.php | 2 +- modules/negotiate/www/disable.php | 4 +- modules/negotiate/www/enable.php | 4 +- .../oauth/config-template/module_oauth.php | 4 +- modules/oauth/hooks/hook_frontpage.php | 4 +- modules/oauth/lib/Consumer.php | 14 +- modules/oauth/lib/OAuthStore.php | 12 +- modules/oauth/lib/Registry.php | 2 +- modules/oauth/libextinc/OAuth.php | 42 +-- modules/oauth/templates/registry.edit.tpl.php | 2 +- modules/oauth/templates/registry.list.php | 6 +- modules/oauth/www/registry.edit.php | 8 +- modules/oauth/www/registry.php | 2 +- .../portal/config-templates/module_portal.php | 12 +- modules/portal/hooks/hook_htmlinject.php | 10 +- modules/portal/lib/Portal.php | 2 +- .../lib/Auth/Process/Warning.php | 2 +- modules/preprodwarning/www/showwarning.php | 2 +- modules/radius/lib/Auth/Source/Radius.php | 14 +- modules/riak/config-templates/module_riak.php | 4 +- modules/saml/hooks/hook_metadata_hosted.php | 4 +- .../Process/ExpectedAuthnContextClassRef.php | 2 +- .../saml/lib/Auth/Process/FilterScopes.php | 8 +- .../saml/lib/Auth/Process/NameIDAttribute.php | 4 +- .../Process/PersistentNameID2TargetedID.php | 2 +- .../lib/Auth/Process/SQLPersistentNameID.php | 4 +- modules/saml/lib/Auth/Source/SP.php | 42 +-- modules/saml/lib/IdP/SAML1.php | 16 +- modules/saml/lib/IdP/SAML2.php | 100 +++--- modules/saml/lib/IdP/SQLNameID.php | 18 +- modules/saml/lib/Message.php | 58 +-- modules/saml/lib/SP/LogoutStore.php | 16 +- .../saml/templates/proxy/invalid_session.php | 4 +- modules/saml/www/disco.php | 2 +- modules/saml/www/sp/metadata.php | 34 +- modules/saml/www/sp/saml1-acs.php | 8 +- modules/saml/www/sp/saml2-acs.php | 22 +- modules/saml/www/sp/saml2-logout.php | 4 +- .../config-templates/config-sanitycheck.php | 4 +- modules/sanitycheck/hooks/hook_cron.php | 8 +- modules/sanitycheck/hooks/hook_frontpage.php | 4 +- modules/sanitycheck/hooks/hook_moduleinfo.php | 12 +- modules/sanitycheck/www/index.php | 8 +- .../lib/Auth/Process/SmartID.php | 8 +- .../lib/Auth/Process/SmartName.php | 4 +- modules/sqlauth/lib/Auth/Source/SQL.php | 8 +- modules/statistics/bin/loganalyzer.php | 2 +- modules/statistics/bin/logcleaner.php | 2 +- .../config-templates/module_statistics.php | 104 +++--- modules/statistics/hooks/hook_frontpage.php | 10 +- modules/statistics/lib/Aggregator.php | 22 +- modules/statistics/lib/Graph/GoogleCharts.php | 6 +- modules/statistics/lib/LogCleaner.php | 6 +- modules/statistics/lib/RatioDataset.php | 8 +- modules/statistics/lib/Ruleset.php | 6 +- modules/statistics/lib/StatDataset.php | 28 +- .../lib/Statistics/FieldPresentation/Base.php | 2 +- .../Statistics/FieldPresentation/Entity.php | 2 +- .../lib/Statistics/Rulesets/BaseRule.php | 6 +- .../statistics/templates/statistics.tpl.php | 4 +- modules/statistics/www/showstats.php | 10 +- templates/includes/attributes.php | 16 +- templates/metadata.php | 2 +- templates/post.php | 4 +- templates/status.php | 20 +- tests/BuiltInServer.php | 14 +- tests/Utils/ReduceSpillOverTest.php | 2 +- tests/Utils/StateClearer.php | 8 +- tests/lib/SimpleSAML/Auth/SimpleTest.php | 38 +- tests/lib/SimpleSAML/Auth/StateTest.php | 12 +- .../SimpleSAML/Auth/TimeLimitedTokenTest.php | 10 +- tests/lib/SimpleSAML/ConfigurationTest.php | 334 +++++++++--------- tests/lib/SimpleSAML/DatabaseTest.php | 50 +-- tests/lib/SimpleSAML/Locale/LanguageTest.php | 68 ++-- .../SimpleSAML/Locale/LocalizationTest.php | 6 +- tests/lib/SimpleSAML/Locale/TranslateTest.php | 6 +- .../SimpleSAML/Metadata/SAMLBuilderTest.php | 78 ++-- .../SimpleSAML/Metadata/SAMLParserTest.php | 12 +- tests/lib/SimpleSAML/ModuleTest.php | 8 +- tests/lib/SimpleSAML/Store/RedisTest.php | 16 +- tests/lib/SimpleSAML/Store/SQLTest.php | 4 +- tests/lib/SimpleSAML/StoreTest.php | 24 +- tests/lib/SimpleSAML/Utils/ArraysTest.php | 88 ++--- tests/lib/SimpleSAML/Utils/AttributesTest.php | 62 ++-- .../SimpleSAML/Utils/Config/MetadataTest.php | 112 +++--- tests/lib/SimpleSAML/Utils/CryptoTest.php | 100 +++--- tests/lib/SimpleSAML/Utils/HTTPTest.php | 80 ++--- tests/lib/SimpleSAML/Utils/SystemTest.php | 10 +- tests/lib/SimpleSAML/Utils/TimeTest.php | 10 +- tests/lib/SimpleSAML/Utils/XMLTest.php | 6 +- tests/lib/SimpleSAML/XML/ErrorsTest.php | 2 +- tests/lib/SimpleSAML/XML/ParserTest.php | 12 +- .../XML/Shib13/AuthnResponseTest.php | 4 +- tests/lib/SimpleSAML/XML/SignerTest.php | 28 +- tests/lib/SimpleSAML/XML/ValidatorTest.php | 36 +- .../consent/lib/Auth/Process/ConsentTest.php | 150 ++++---- .../lib/Auth/Process/AttributeAddTest.php | 136 +++---- .../lib/Auth/Process/AttributeAlterTest.php | 230 ++++++------ .../lib/Auth/Process/AttributeCopyTest.php | 114 +++--- .../lib/Auth/Process/AttributeLimitTest.php | 322 ++++++++--------- .../lib/Auth/Process/AttributeRealmTest.php | 70 ++-- .../Auth/Process/AttributeValueMapTest.php | 168 ++++----- .../Auth/Process/CardinalitySingleTest.php | 110 +++--- .../core/lib/Auth/Process/CardinalityTest.php | 182 +++++----- .../modules/core/lib/Auth/Process/PHPTest.php | 64 ++-- .../lib/Auth/Process/ScopeAttributeTest.php | 168 ++++----- .../Auth/Process/ScopeFromAttributeTest.php | 80 ++--- .../core/lib/Auth/Process/TargetedIDTest.php | 47 ++- .../core/lib/Auth/UserPassBaseTest.php | 12 +- .../core/lib/Auth/UserPassOrgBaseTest.php | 14 +- .../ldap/lib/Auth/Process/BaseFilterTest.php | 4 +- .../lib/Auth/Process/FilterScopesTest.php | 96 ++--- .../lib/Auth/Process/NameIDAttributeTest.php | 56 +-- .../lib/Auth/Source/Auth_Source_SP_Test.php | 46 +-- tests/modules/saml/lib/IdP/SAML2Test.php | 6 +- tests/www/IndexTest.php | 24 +- tests/www/TemplateTest.php | 4 +- www/admin/hostnames.php | 30 +- www/admin/index.php | 4 +- www/admin/metadata-converter.php | 6 +- www/authmemcookie.php | 4 +- www/errorreport.php | 4 +- www/module.php | 6 +- www/saml2/idp/metadata.php | 50 +-- www/shib13/idp/metadata.php | 20 +- 367 files changed, 3847 insertions(+), 3848 deletions(-) diff --git a/attributemap/addurnprefix.php b/attributemap/addurnprefix.php index 9d9877c00..c8623954f 100644 --- a/attributemap/addurnprefix.php +++ b/attributemap/addurnprefix.php @@ -1,6 +1,6 @@ <?php -$attributemap = array( +$attributemap = [ 'sn' => 'urn:mace:dir:attribute-def:sn', 'telephoneNumber' => 'urn:mace:dir:attribute-def:telephoneNumber', 'facsimileTelephoneNumber' => 'urn:mace:dir:attribute-def:facsimileTelephoneNumber', @@ -17,4 +17,4 @@ $attributemap = array( 'eduPersonEntitlement' => 'urn:mace:dir:attribute-def:eduPersonEntitlement', 'eduPersonOrgDN' => 'urn:mace:dir:attribute-def:eduPersonOrgDN', 'eduPersonOrgUnitDN' => 'urn:mace:dir:attribute-def:eduPersonOrgUnitDN', -); +]; diff --git a/attributemap/deprecatedSchacNS.php b/attributemap/deprecatedSchacNS.php index 5f90e03ab..4a613348e 100644 --- a/attributemap/deprecatedSchacNS.php +++ b/attributemap/deprecatedSchacNS.php @@ -11,7 +11,7 @@ if (!defined('SCHAC_NEW_NS')) { define('SCHAC_NEW_NS', 'urn:schac:attribute-def:'); } -$attributemap = array( +$attributemap = [ SCHAC_NEW_NS.'schacCountryOfCitizenship' => SCHAC_OLD_NS.'schacCountryOfCitizenship', SCHAC_NEW_NS.'schacCountryOfResidence' => SCHAC_OLD_NS.'schacCountryOfResidence', SCHAC_NEW_NS.'schacDateOfBirth' => SCHAC_OLD_NS.'schacDateOfBirth', @@ -32,4 +32,4 @@ $attributemap = array( SCHAC_NEW_NS.'schacUserPresenceID' => SCHAC_OLD_NS.'schacUserPresenceID', SCHAC_NEW_NS.'schacUserPrivateAttribute' => SCHAC_OLD_NS.'schacUserPrivateAttribute', SCHAC_NEW_NS.'schacUserStatus' => SCHAC_OLD_NS.'schacUserStatus', -); +]; diff --git a/attributemap/facebook2name.php b/attributemap/facebook2name.php index 5867ea7ed..e567a69f2 100644 --- a/attributemap/facebook2name.php +++ b/attributemap/facebook2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ // Generated Facebook Attributes 'facebook_user' => 'eduPersonPrincipalName', // username OR uid @ facebook.com @@ -15,4 +15,4 @@ $attributemap = array( 'facebook.profile_url' => 'labeledURI', 'facebook.locale' => 'preferredLanguage', 'facebook.about_me' => 'description', -); +]; diff --git a/attributemap/feide-oid.php b/attributemap/feide-oid.php index dc94cd7a4..45a1a28a4 100644 --- a/attributemap/feide-oid.php +++ b/attributemap/feide-oid.php @@ -1,6 +1,6 @@ <?php -$attributemap = array( +$attributemap = [ 'mobile' => 'urn:mace:dir:attribute-def:mobile', 'displayName' => 'urn:oid:2.16.840.1.113730.3.1.241', -); +]; diff --git a/attributemap/linkedin2name.php b/attributemap/linkedin2name.php index 97231dd4b..9b654682d 100644 --- a/attributemap/linkedin2name.php +++ b/attributemap/linkedin2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ // See http://developer.linkedin.com/docs/DOC-1061 for LinkedIn Profile fields. // NB: JSON response requires the conversion of field names from hyphened to camelCase. @@ -15,4 +15,4 @@ $attributemap = array( 'linkedin.id' => 'uid', // alpha + mixed case user id 'linkedin.headline' => 'title', 'linkedin.summary' => 'description', -); +]; diff --git a/attributemap/name2claim.php b/attributemap/name2claim.php index 482bb6d8b..7b03b1045 100644 --- a/attributemap/name2claim.php +++ b/attributemap/name2claim.php @@ -1,5 +1,5 @@ <?php // Maps AD LDAP to Claims from http://msdn.microsoft.com/en-us/library/hh159803.aspx -$attributemap = array( +$attributemap = [ 'c' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/country', 'givenName' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname', 'mail' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress', @@ -10,4 +10,4 @@ $attributemap = array( 'st' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/stateorprovince', 'streetaddress' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/streetaddress', 'telephonenumber' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/otherphone', -); +]; diff --git a/attributemap/name2oid.php b/attributemap/name2oid.php index 1a5e10ca2..c99f0e0b3 100644 --- a/attributemap/name2oid.php +++ b/attributemap/name2oid.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'aRecord' => 'urn:oid:0.9.2342.19200300.100.1.26', 'aliasedEntryName' => 'urn:oid:2.5.4.1', 'aliasedObjectName' => 'urn:oid:2.5.4.1', @@ -189,4 +189,4 @@ $attributemap = array( 'userid' => 'urn:oid:0.9.2342.19200300.100.1.1', 'x121Address' => 'urn:oid:2.5.4.24', 'x500UniqueIdentifier' => 'urn:oid:2.5.4.45', -); +]; diff --git a/attributemap/name2urn.php b/attributemap/name2urn.php index 9286f6fe3..03190f309 100644 --- a/attributemap/name2urn.php +++ b/attributemap/name2urn.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'aRecord' => 'urn:mace:dir:attribute-def:aRecord', 'aliasedEntryName' => 'urn:mace:dir:attribute-def:aliasedEntryName', 'aliasedObjectName' => 'urn:mace:dir:attribute-def:aliasedObjectName', @@ -186,4 +186,4 @@ $attributemap = array( 'userid' => 'urn:mace:dir:attribute-def:userid', 'x121Address' => 'urn:mace:dir:attribute-def:x121Address', 'x500UniqueIdentifier' => 'urn:mace:dir:attribute-def:x500UniqueIdentifier', -); +]; diff --git a/attributemap/newSchacNS.php b/attributemap/newSchacNS.php index 8b3d2a756..16e67394e 100644 --- a/attributemap/newSchacNS.php +++ b/attributemap/newSchacNS.php @@ -11,7 +11,7 @@ if (!defined('SCHAC_NEW_NS')) { define('SCHAC_NEW_NS', 'urn:schac:attribute-def:'); } -$attributemap = array( +$attributemap = [ SCHAC_OLD_NS.'schacCountryOfCitizenship' => SCHAC_NEW_NS.'schacCountryOfCitizenship', SCHAC_OLD_NS.'schacCountryOfResidence' => SCHAC_NEW_NS.'schacCountryOfResidence', SCHAC_OLD_NS.'schacDateOfBirth' => SCHAC_NEW_NS.'schacDateOfBirth', @@ -32,4 +32,4 @@ $attributemap = array( SCHAC_OLD_NS.'schacUserPresenceID' => SCHAC_NEW_NS.'schacUserPresenceID', SCHAC_OLD_NS.'schacUserPrivateAttribute' => SCHAC_NEW_NS.'schacUserPrivateAttribute', SCHAC_OLD_NS.'schacUserStatus' => SCHAC_NEW_NS.'schacUserStatus', -); +]; diff --git a/attributemap/oid-feide.php b/attributemap/oid-feide.php index e20b7a885..c6bc2148d 100644 --- a/attributemap/oid-feide.php +++ b/attributemap/oid-feide.php @@ -1,6 +1,6 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:oid:0.9.2342.19200300.100.1.41' => 'mobile', 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6' => 'eduPersonPrincipalName', 'urn:oid:0.9.2342.19200300.100.1.3' => 'mail', @@ -9,4 +9,4 @@ $attributemap = array( 'urn:oid:2.5.4.4' => 'sn', 'urn:oid:2.5.4.42' => 'givenName', 'urn:oid:2.16.756.1.2.5.1.1.1' => 'eduPerson', -); +]; diff --git a/attributemap/oid2name.php b/attributemap/oid2name.php index e1ce887d6..f36dd1cab 100644 --- a/attributemap/oid2name.php +++ b/attributemap/oid2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:oid:0.9.2342.19200300.100.1.1' => 'uid', 'urn:oid:0.9.2342.19200300.100.1.10' => 'manager', 'urn:oid:0.9.2342.19200300.100.1.11' => 'documentIdentifier', @@ -167,4 +167,4 @@ $attributemap = array( 'urn:oid:2.5.4.7' => 'l', 'urn:oid:2.5.4.8' => 'st', 'urn:oid:2.5.4.9' => 'street', -); +]; diff --git a/attributemap/oid2urn.php b/attributemap/oid2urn.php index cefb99ce7..a2b0a78e3 100644 --- a/attributemap/oid2urn.php +++ b/attributemap/oid2urn.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:oid:0.9.2342.19200300.100.1.1' => 'urn:mace:dir:attribute-def:uid', 'urn:oid:0.9.2342.19200300.100.1.10' => 'urn:mace:dir:attribute-def:manager', 'urn:oid:0.9.2342.19200300.100.1.11' => 'urn:mace:dir:attribute-def:documentIdentifier', @@ -164,4 +164,4 @@ $attributemap = array( 'urn:oid:2.5.4.7' => 'urn:mace:dir:attribute-def:l', 'urn:oid:2.5.4.8' => 'urn:mace:dir:attribute-def:st', 'urn:oid:2.5.4.9' => 'urn:mace:dir:attribute-def:street', -); +]; diff --git a/attributemap/openid2name.php b/attributemap/openid2name.php index 624074b02..1cef43ef2 100644 --- a/attributemap/openid2name.php +++ b/attributemap/openid2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ // Simple Registration + AX Schema 'http://axschema.org/namePerson/friendly' => 'displayName', // Alias/Username -> displayName 'openid.sreg.nickname' => 'displayName', @@ -30,4 +30,4 @@ $attributemap = array( 'http://axschema.org/contact/phone/fax' => 'facsimileTelephoneNumber', // Phone (fax) // Further attributes can be found at http://www.axschema.org/types/ -); +]; diff --git a/attributemap/removeurnprefix.php b/attributemap/removeurnprefix.php index 6a7c920d5..f9ac92f5e 100644 --- a/attributemap/removeurnprefix.php +++ b/attributemap/removeurnprefix.php @@ -1,6 +1,6 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:mace:dir:attribute-def:sn' => 'sn', 'urn:mace:dir:attribute-def:telephoneNumber' => 'telephoneNumber', 'urn:mace:dir:attribute-def:facsimileTelephoneNumber' => 'facsimileTelephoneNumber', @@ -17,4 +17,4 @@ $attributemap = array( 'urn:mace:dir:attribute-def:eduPersonEntitlement' => 'eduPersonEntitlement', 'urn:mace:dir:attribute-def:eduPersonOrgDN' => 'eduPersonOrgDN', 'urn:mace:dir:attribute-def:eduPersonOrgUnitDN' => 'eduPersonOrgUnitDN', -); +]; diff --git a/attributemap/test.php b/attributemap/test.php index a89ad869f..8ddd84b69 100644 --- a/attributemap/test.php +++ b/attributemap/test.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'mobile' => 'urn:mace:dir:attribute-def:mobile' -); +]; diff --git a/attributemap/twitter2name.php b/attributemap/twitter2name.php index 27c9e755a..00f65317a 100644 --- a/attributemap/twitter2name.php +++ b/attributemap/twitter2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ // Generated Twitter Attributes 'twitter_screen_n_realm' => 'eduPersonPrincipalName', // screen_name@twitter.com @@ -11,4 +11,4 @@ $attributemap = array( 'twitter.url' => 'labeledURI', 'twitter.lang' => 'preferredLanguage', 'twitter.description' => 'description', -); +]; diff --git a/attributemap/urn2name.php b/attributemap/urn2name.php index fc8d4d97d..8cf8bffd7 100644 --- a/attributemap/urn2name.php +++ b/attributemap/urn2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:mace:dir:attribute-def:aRecord' => 'aRecord', 'urn:mace:dir:attribute-def:aliasedEntryName' => 'aliasedEntryName', 'urn:mace:dir:attribute-def:aliasedObjectName' => 'aliasedObjectName', @@ -186,4 +186,4 @@ $attributemap = array( 'urn:mace:terena.org:attribute-def:schacUserStatus' => 'schacUserStatus', 'urn:oasis:names:tc:SAML:attribute:pairwise-id' => 'pairwise-id', 'urn:oasis:names:tc:SAML:attribute:subject-id' => 'subject-id', -); +]; diff --git a/attributemap/urn2oid.php b/attributemap/urn2oid.php index fda382b93..4abf46784 100644 --- a/attributemap/urn2oid.php +++ b/attributemap/urn2oid.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ 'urn:mace:dir:attribute-def:aRecord' => 'urn:oid:0.9.2342.19200300.100.1.26', 'urn:mace:dir:attribute-def:aliasedEntryName' => 'urn:oid:2.5.4.1', 'urn:mace:dir:attribute-def:aliasedObjectName' => 'urn:oid:2.5.4.1', @@ -185,4 +185,4 @@ $attributemap = array( 'urn:mace:terena.org:attribute-def:schacUserPresenceID' => 'urn:oid:1.3.6.1.4.1.25178.1.2.12', 'urn:mace:terena.org:attribute-def:schacUserPrivateAttribute' => 'urn:oid:1.3.6.1.4.1.25178.1.2.18', 'urn:mace:terena.org:attribute-def:schacUserStatus' => 'urn:oid:1.3.6.1.4.1.25178.1.2.19', -); +]; diff --git a/attributemap/windowslive2name.php b/attributemap/windowslive2name.php index 1c5496c90..3c3ffa1f0 100644 --- a/attributemap/windowslive2name.php +++ b/attributemap/windowslive2name.php @@ -1,5 +1,5 @@ <?php -$attributemap = array( +$attributemap = [ // Generated Windows Live ID Attributes 'windowslive_user' => 'eduPersonPrincipalName', // uid @ windowslive.com @@ -19,4 +19,4 @@ $attributemap = array( 'windowslive.mail' => 'mail', 'windowslive.preferredLanguage' => 'preferredLanguage', -); +]; diff --git a/bin/importPdoMetadata.php b/bin/importPdoMetadata.php index b930b99f2..abf4fdd48 100755 --- a/bin/importPdoMetadata.php +++ b/bin/importPdoMetadata.php @@ -14,7 +14,7 @@ foreach ($config['metadata.sources'] as $s) { $mdshp->initDatabase(); foreach (glob("metadata/*.php") as $filename) { - $metadata = array(); + $metadata = []; require_once $filename; $set = basename($filename, ".php"); echo "importing set '$set'...".PHP_EOL; diff --git a/bin/memcacheSync.php b/bin/memcacheSync.php index 278cd0f6d..0b5ca9c85 100755 --- a/bin/memcacheSync.php +++ b/bin/memcacheSync.php @@ -35,7 +35,7 @@ $warnBigSlab = 0; // We use the stats interface to determine which servers exists $stats = \SimpleSAML\Memcache::getRawStats(); -$keys = array(); +$keys = []; foreach ($stats as $group) { foreach ($group as $server => $state) { @@ -109,7 +109,7 @@ function getServerKeys($server) } // Read list of slabs - $slabs = array(); + $slabs = []; while (($line = fgets($socket)) !== false) { $line = rtrim($line); if ($line === 'END') { @@ -125,7 +125,7 @@ function getServerKeys($server) } // Dump keys in slabs - $keys = array(); + $keys = []; foreach ($slabs as $slab) { if (fwrite($socket, "stats cachedump ".$slab." 1000000\r\n") === false) { diff --git a/config-templates/acl.php b/config-templates/acl.php index e208952eb..cb760d0aa 100644 --- a/config-templates/acl.php +++ b/config-templates/acl.php @@ -4,56 +4,56 @@ * This file defines "named" access control lists, which can * be reused in several places. */ -$config = array( - 'adminlist' => array( - //array('allow', 'equals', 'mail', 'admin1@example.org'), - //array('allow', 'has', 'groups', 'admin'), +$config = [ + 'adminlist' => [ + //['allow', 'equals', 'mail', 'admin1@example.org'], + //['allow', 'has', 'groups', 'admin'], // The default action is to deny access. - ), + ], - 'example-simple' => array( - array('allow', 'equals', 'mail', 'admin1@example.org'), - array('allow', 'equals', 'mail', 'admin2@example.org'), + 'example-simple' => [ + ['allow', 'equals', 'mail', 'admin1@example.org'], + ['allow', 'equals', 'mail', 'admin2@example.org'], // The default action is to deny access. - ), + ], - 'example-deny-some' => array( - array('deny', 'equals', 'mail', 'eviluser@example.org'), - array('allow'), // Allow everybody else. - ), + 'example-deny-some' => [ + ['deny', 'equals', 'mail', 'eviluser@example.org'], + ['allow'], // Allow everybody else. + ], - 'example-maildomain' => array( - array('allow', 'equals-preg', 'mail', '/@example\.org$/'), + 'example-maildomain' => [ + ['allow', 'equals-preg', 'mail', '/@example\.org$/'], // The default action is to deny access. - ), + ], - 'example-allow-employees' => array( - array('allow', 'has', 'eduPersonAffiliation', 'employee'), + 'example-allow-employees' => [ + ['allow', 'has', 'eduPersonAffiliation', 'employee'], // The default action is to deny access. - ), + ], - 'example-allow-employees-not-students' => array( - array('deny', 'has', 'eduPersonAffiliation', 'student'), - array('allow', 'has', 'eduPersonAffiliation', 'employee'), + 'example-allow-employees-not-students' => [ + ['deny', 'has', 'eduPersonAffiliation', 'student'], + ['allow', 'has', 'eduPersonAffiliation', 'employee'], // The default action is to deny access. - ), - - 'example-deny-student-except-one' => array( - array('deny', 'and', - array('has', 'eduPersonAffiliation', 'student'), - array('not', 'equals', 'mail', 'user@example.org'), - ), - array('allow'), - ), - - 'example-allow-or' => array( - array('allow', 'or', - array('equals', 'eduPersonAffiliation', 'student', 'member'), - array('equals', 'mail', 'someuser@example2.org'), - ), - ), - - 'example-allow-all' => array( - array('allow'), - ), -); + ], + + 'example-deny-student-except-one' => [ + ['deny', 'and', + ['has', 'eduPersonAffiliation', 'student'], + ['not', 'equals', 'mail', 'user@example.org'], + ], + ['allow'], + ], + + 'example-allow-or' => [ + ['allow', 'or', + ['equals', 'eduPersonAffiliation', 'student', 'member'], + ['equals', 'mail', 'someuser@example2.org'], + ], + ], + + 'example-allow-all' => [ + ['allow'], + ], +]; diff --git a/config-templates/authmemcookie.php b/config-templates/authmemcookie.php index cf2031add..fac028138 100644 --- a/config-templates/authmemcookie.php +++ b/config-templates/authmemcookie.php @@ -4,7 +4,7 @@ * This is the configuration file for the Auth MemCookie example. */ -$config = array( +$config = [ /* * The authentication source that should be used. * @@ -70,4 +70,4 @@ $config = array( * 'memcache.port' => 11211, */ 'memcache.port' => 11211, -); +]; diff --git a/config-templates/authsources.php b/config-templates/authsources.php index 5550b6d55..c637594c9 100644 --- a/config-templates/authsources.php +++ b/config-templates/authsources.php @@ -1,19 +1,19 @@ <?php -$config = array( +$config = [ // This is a authentication source which handles admin authentication. - 'admin' => array( + 'admin' => [ // The default is to use core:AdminPassword, but it can be replaced with // any authentication source. 'core:AdminPassword', - ), + ], // An authentication source which can authenticate against both SAML 2.0 // and Shibboleth 1.3 IdPs. - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', // The entity ID of this SP. @@ -46,7 +46,7 @@ $config = array( /*'attributes.required' => array ( 'urn:oid:x.x.x.x', ),*/ - ), + ], /* @@ -331,4 +331,4 @@ $config = array( ), */ -); +]; diff --git a/config-templates/config.php b/config-templates/config.php index 50a08f9b9..f3f776351 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -4,7 +4,7 @@ * */ -$config = array( +$config = [ /******************************* | BASIC CONFIGURATION OPTIONS | @@ -150,7 +150,7 @@ $config = array( * Example: * 'trusted.url.domains' => array('sp.example.com', 'app.example.com'), */ - 'trusted.url.domains' => array(), + 'trusted.url.domains' => [], /* * Enable regular expression matching of trusted.url.domains. @@ -214,11 +214,11 @@ $config = array( * If you want to disable debugging completely, unset this option or set it to an * empty array. */ - 'debug' => array( + 'debug' => [ 'saml' => false, 'backtraces' => true, 'validatexml' => false, - ), + ], /* * When 'showerrors' is enabled, all error messages and stack traces will be output @@ -316,7 +316,7 @@ $config = array( * This is an array of outputs. Each output has at least a 'class' option, which * selects the output. */ - 'statistics.out' => array(// Log statistics to the normal log. + 'statistics.out' => [// Log statistics to the normal log. /* array( 'class' => 'core:Log', @@ -330,7 +330,7 @@ $config = array( 'directory' => '/var/log/stats', ), */ - ), + ], @@ -377,7 +377,7 @@ $config = array( */ 'database.username' => 'simplesamlphp', 'database.password' => 'secret', - 'database.options' => array(), + 'database.options' => [], /* * (Optional) Table prefix @@ -387,7 +387,7 @@ $config = array( /* * (Optional) Driver options */ - 'database.driver_options' => array(), + 'database.driver_options' => [], /* * True or false if you would like a persistent database connection @@ -404,7 +404,7 @@ $config = array( * options for the master (shown above) with the exception of the table * prefix and driver options. */ - 'database.slaves' => array( + 'database.slaves' => [ /* array( 'dsn' => 'mysql:host=myslave;dbname=saml', @@ -413,7 +413,7 @@ $config = array( 'persistent' => false, ), */ - ), + ], @@ -628,11 +628,11 @@ $config = array( * ), * */ - 'memcache_store.servers' => array( - array( - array('hostname' => 'localhost'), - ), - ), + 'memcache_store.servers' => [ + [ + ['hostname' => 'localhost'], + ], + ], /* * This value allows you to set a prefix for memcache-keys. The default @@ -670,7 +670,7 @@ $config = array( /* * Language-related options. */ - 'language' => array( + 'language' => [ /* * An array in the form 'language' => <list of alternative languages>. * @@ -690,23 +690,23 @@ $config = array( * not available, we look for translations in "nb" (Norwegian BokmĂĄl), * and so on, in that order. */ - 'priorities' => array( - 'no' => array('nb', 'nn', 'en', 'se'), - 'nb' => array('no', 'nn', 'en', 'se'), - 'nn' => array('no', 'nb', 'en', 'se'), - 'se' => array('nb', 'no', 'nn', 'en'), - ), - ), + 'priorities' => [ + 'no' => ['nb', 'nn', 'en', 'se'], + 'nb' => ['no', 'nn', 'en', 'se'], + 'nn' => ['no', 'nb', 'en', 'se'], + 'se' => ['nb', 'no', 'nn', 'en'], + ], + ], /* * Languages available, RTL languages, and what language is the default. */ - 'language.available' => array( + 'language.available' => [ 'en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'ca', 'fr', 'it', 'nl', 'lb', 'cs', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-br', 'tr', 'ja', 'zh', 'zh-tw', 'ru', 'et', 'he', 'id', 'sr', 'lv', 'ro', 'eu', 'el', 'af' - ), - 'language.rtl' => array('ar', 'dv', 'fa', 'ur', 'he'), + ], + 'language.rtl' => ['ar', 'dv', 'fa', 'ur', 'he'], 'language.default' => 'en', /* @@ -854,7 +854,7 @@ $config = array( * Authentication processing filters that will be executed for all IdPs * Both Shibboleth and SAML 2.0 */ - 'authproc.idp' => array( + 'authproc.idp' => [ /* Enable the authproc filter below to add URN prefixes to all attributes 10 => array( 'class' => 'core:AttributeMap', 'addurnprefix' @@ -866,11 +866,11 @@ $config = array( // Adopts language from attribute to use in UI 30 => 'core:LanguageAdaptor', - 45 => array( + 45 => [ 'class' => 'core:StatisticsWithAttribute', 'attributename' => 'realm', 'type' => 'saml20-idp-SSO', - ), + ], /* When called without parameters, it will fallback to filter attributes ‹the old way› * by checking the 'attributes' parameter in metadata on IdP hosted and SP remote. @@ -901,13 +901,13 @@ $config = array( */ // If language is set in Consent module it will be added as an attribute. 99 => 'core:LanguageAdaptor', - ), + ], /* * Authentication processing filters that will be executed for all SPs * Both Shibboleth and SAML 2.0 */ - 'authproc.sp' => array( + 'authproc.sp' => [ /* 10 => array( 'class' => 'core:AttributeMap', 'removeurnprefix' @@ -930,7 +930,7 @@ $config = array( // Adopts language from attribute to use in UI 90 => 'core:LanguageAdaptor', - ), + ], @@ -1018,9 +1018,9 @@ $config = array( * array('type' => 'flatfile') * ), */ - 'metadata.sources' => array( - array('type' => 'flatfile'), - ), + 'metadata.sources' => [ + ['type' => 'flatfile'], + ], /* * Should signing of generated metadata be enabled by default. @@ -1091,4 +1091,4 @@ $config = array( * The prefix we should use on our Redis datastore. */ 'store.redis.prefix' => 'SimpleSAMLphp', -); +]; diff --git a/docs/simplesamlphp-advancedfeatures.md b/docs/simplesamlphp-advancedfeatures.md index adb7c2486..a1ee444dd 100644 --- a/docs/simplesamlphp-advancedfeatures.md +++ b/docs/simplesamlphp-advancedfeatures.md @@ -41,9 +41,9 @@ In `metadata/saml20-idp-hosted.php`: In `config/authsources.php`: - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', - ), + ], diff --git a/docs/simplesamlphp-artifact-idp.md b/docs/simplesamlphp-artifact-idp.md index b07985a85..fcbf0079d 100644 --- a/docs/simplesamlphp-artifact-idp.md +++ b/docs/simplesamlphp-artifact-idp.md @@ -35,11 +35,11 @@ Enabling artifact on the IdP To enable the IdP to send artifacts, you must add the `saml20.sendartifact` option to the `saml20-idp-hosted` metadata file: - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ [....] 'auth' => 'example-userpass', 'saml20.sendartifact' => TRUE, - ); + ]; Add new metadata to SPs @@ -49,13 +49,13 @@ After enabling the Artifact binding, your IdP metadata will change to add a Arti You therefore need to update the metadata for your IdP at your SPs. `saml20-idp-remote` metadata for SimpleSAMLphp SPs should contain something like: - 'ArtifactResolutionService' => array( - array( + 'ArtifactResolutionService' => [ + [ 'index' => 0, 'Location' => 'https://idp.example.org/simplesaml/saml2/idp/ArtifactResolutionService.php', 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP', - ), - ), + ], + ], SP metadata on the IdP @@ -66,16 +66,16 @@ This means that you must use the complex endpoint format in `saml20-sp-remote` m In general, that should look something like: 'AssertionConsumerService' => array ( - array( + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', 'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'index' => 0, - ), - array( + ], + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', 'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'index' => 2, - ), + ], ), (The specific values of the various fields will vary depending on the SP.) @@ -89,9 +89,9 @@ You may therefore have to add the webserver certificate to the metadata that you To do this, you need to set the `https.certificate` option in the `saml20-idp-hosted` metadata file. That option should refer to a file containing the webserver certificate. - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ [....] 'auth' => 'example-userpass', 'saml20.sendartifact' => TRUE, 'https.certificate' => '/etc/apache2/webserver.crt', - ); + ]; diff --git a/docs/simplesamlphp-artifact-sp.md b/docs/simplesamlphp-artifact-sp.md index 6b18119ce..7571454e6 100644 --- a/docs/simplesamlphp-artifact-sp.md +++ b/docs/simplesamlphp-artifact-sp.md @@ -19,11 +19,11 @@ When this is done, you can add the metadata of your SP to the IdP, and test the Example configuration --------------------- - 'artifact-sp' => array( + 'artifact-sp' => [ 'saml:SP', 'ProtocolBinding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', 'privatekey' => 'sp.example.org.pem', 'certificate' => 'sp.example.org.crt', - ), + ], See the [SP configuration reference](./saml:sp) for a description of the options. diff --git a/docs/simplesamlphp-authproc.md b/docs/simplesamlphp-authproc.md index f97086b3a..d66762e4b 100644 --- a/docs/simplesamlphp-authproc.md +++ b/docs/simplesamlphp-authproc.md @@ -44,20 +44,20 @@ How to configure Auth Proc Filters The configuration of *Auth Proc Filters* is a list of filters with priority as *index*. Here is an example of *Auth Proc Filters* configured in `config.php`: - 'authproc.idp' => array( - 10 => array( + 'authproc.idp' => [ + 10 => [ 'class' => 'core:AttributeMap', 'addurnprefix' - ), + ], 20 => 'core:TargetedID', 50 => 'core:AttributeLimit', - 90 => array( + 90 => [ 'class' => 'consent:Consent', 'store' => 'consent:Cookie', 'focus' => 'yes', 'checked' => TRUE - ), - ), + ], + ], This configuration will execute *Auth Proc Filters* one by one, with the priority value in increasing order. When *Auth Proc Filters* is configured in multiple places, in example both globally, in the hosted IdP and remote SP metadata, then the list is interleaved sorted by priority. @@ -73,18 +73,18 @@ When you know the class definition of a filter, and the priority, the simple way This is analogous to: - 20 => array( + 20 => [ 'class' => 'core:TargetedID' - ), + ], Some *Auth Proc Filters* have optional or required *parameters*. To send parameters to *Auth Proc Filters*, you need to choose the second of the two alernatives above. Here is an example of provided parameters to the consent module: - 90 => array( + 90 => [ 'class' => 'consent:Consent', 'store' => 'consent:Cookie', 'focus' => 'yes', 'checked' => TRUE - ), + ], ### Filters in `config.php` @@ -105,15 +105,15 @@ The filters in `authproc.sp` will be executed at the SP side regardless of which Filters can be added both in `hosted` and `remote` metadata. Here is an example of a filter added in a metadata file: - '__DYNAMIC:1__' => array( + '__DYNAMIC:1__' => [ 'host' => '__DEFAULT_', 'privatekey' => 'example.org.pem', 'certificate' => 'example.org.crt', 'auth' => 'feide', - 'authproc' => array( + 'authproc' => [ 40 => 'preprodwarning:Warning', - ), - ) + ], + ] The example above is in `saml20-idp-hosted`. diff --git a/docs/simplesamlphp-automated_metadata.md b/docs/simplesamlphp-automated_metadata.md index 54eba4510..cc40de2ce 100644 --- a/docs/simplesamlphp-automated_metadata.md +++ b/docs/simplesamlphp-automated_metadata.md @@ -68,43 +68,43 @@ Now we are going to proceed to configure the metarefresh module. First, edit the Here's an example of a possible configuration for both the Kalmar Federation and UK Access Management Federation: - $config = array( - 'sets' => array( - 'kalmar' => array( - 'cron' => array('hourly'), - 'sources' => array( - array( + $config = [ + 'sets' => [ + 'kalmar' => [ + 'cron' => ['hourly'], + 'sources' => [ + [ 'src' => 'https://kalmar.feide.no/simplesaml/module.php/aggregator/?id=kalmarcentral&mimetype=text/plain&exclude=norway', - 'certificates' => array( + 'certificates' => [ 'current.crt', 'rollover.crt', - ), - 'template' => array( - 'tags' => array('kalmar'), - 'authproc' => array( - 51 => array('class' => 'core:AttributeMap', 'oid2name'), - ), - ), - ), - ), + ], + 'template' => [ + 'tags' => ['kalmar'], + 'authproc' => [ + 51 => ['class' => 'core:AttributeMap', 'oid2name'], + ], + ], + ], + ], 'expireAfter' => 60*60*24*4, // Maximum 4 days cache time. 'outputDir' => 'metadata/metarefresh-kalmar/', 'outputFormat' => 'flatfile', - ), - 'uk' => array( - 'cron' => array('hourly'), - 'sources' => array( - array( + ], + 'uk' => [ + 'cron' => ['hourly'], + 'sources' => [ + [ 'src' => 'http://metadata.ukfederation.org.uk/ukfederation-metadata.xml', 'validateFingerprint' => 'D0:E8:40:25:F0:B1:2A:CC:74:22:ED:C3:87:04:BC:29:BB:7B:9A:40', - ), - ), + ], + ], 'expireAfter' => 60*60*24*4, // Maximum 4 days cache time. 'outputDir' => 'metadata/metarefresh-ukaccess/', 'outputFormat' => 'serialize', - ), - ) - ); + ], + ] + ]; The configuration consists of one or more metadata sets. Each metadata set has its own configuration, representing a metadata set of sources. @@ -180,11 +180,11 @@ web-server write access to the output directories. Following the previous exampl Now you can configure SimpleSAMLphp to use the metadata fetched by metarefresh. Edit the main config.php file, and modify the `metadata.sources` directive accordingly: - 'metadata.sources' => array( - array('type' => 'flatfile'), - array('type' => 'flatfile', 'directory' => 'metadata/metarefresh-kalmar'), - array('type' => 'serialize', 'directory' => 'metadata/metarefresh-ukaccess'), - ), + 'metadata.sources' => [ + ['type' => 'flatfile'], + ['type' => 'flatfile', 'directory' => 'metadata/metarefresh-kalmar'], + ['type' => 'serialize', 'directory' => 'metadata/metarefresh-ukaccess'], + ], Remember that the `type` parameter here must match the `outputFormat` in the configuration of the module. diff --git a/docs/simplesamlphp-customauth.md b/docs/simplesamlphp-customauth.md index a11a3e5ce..ac9b04e24 100644 --- a/docs/simplesamlphp-customauth.md +++ b/docs/simplesamlphp-customauth.md @@ -45,11 +45,11 @@ Create the file `modules/mymodule/lib/Auth/Source/MyAuth.php` with the following if ($username !== 'theusername' || $password !== 'thepassword') { throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); } - return array( - 'uid' => array('theusername'), - 'displayName' => array('Some Random User'), - 'eduPersonAffiliation' => array('member', 'employee'), - ); + return [ + 'uid' => ['theusername'], + 'displayName' => ['Some Random User'], + 'eduPersonAffiliation' => ['member', 'employee'], + ]; } } @@ -78,19 +78,19 @@ Before we can test our authentication source, we must add an entry for it in `co The entry looks like this: - 'myauthinstance' => array( + 'myauthinstance' => [ 'mymodule:MyAuth', - ), + ], You can add it to the beginning of the list, so that the file looks something like this: <?php - $config = array( - 'myauthinstance' => array( + $config = [ + 'myauthinstance' => [ 'mymodule:MyAuth', - ), + ], /* Other authentication sources follow. */ - ); + ]; `myauthinstance` is the name of this instance of the authentication source. (You are allowed to have multiple instances of an authentication source with different configuration.) @@ -124,7 +124,7 @@ In that file you should locate the `auth`-option for your IdP, and change it to <?php /* ... */ - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ /* ... */ /* * Authentication source to use. Must be one that is configured in @@ -132,7 +132,7 @@ In that file you should locate the `auth`-option for your IdP, and change it to */ 'auth' => 'myauthinstance', /* ... */ - ); + ]; You can then test logging in to the IdP. If you have logged in previously, you may need to log out first. @@ -189,22 +189,22 @@ The complete class file should look like this: if ($username !== $this->username || $password !== $this->password) { throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); } - return array( - 'uid' => array($this->username), - 'displayName' => array('Some Random User'), - 'eduPersonAffiliation' => array('member', 'employee'), - ); + return [ + 'uid' => [$this->username], + 'displayName' => ['Some Random User'], + 'eduPersonAffiliation' => ['member', 'employee'], + ]; } } We can then update our entry in `config/authsources.php` with the configuration options: - 'myauthinstance' => array( + 'myauthinstance' => [ 'mymodule:MyAuth', 'username' => 'theconfigusername', 'password' => 'theconfigpassword', - ), + ], Next, you should go to the "Test configured authentication sources" page again, and test logging in. Note that we have updated the username & password to "theconfigusername" and "theconfigpassword". @@ -314,7 +314,7 @@ The class follows: */ $st = $db->prepare('SELECT username, password_hash, full_name FROM userdb WHERE username=:username'); - if (!$st->execute(array('username' => $username))) { + if (!$st->execute(['username' => $username])) { throw new Exception('Failed to query database for user.'); } @@ -334,11 +334,11 @@ The class follows: } /* Create the attribute array of the user. */ - $attributes = array( - 'uid' => array($username), - 'displayName' => array($row['full_name']), - 'eduPersonAffiliation' => array('member', 'employee'), - ); + $attributes = [ + 'uid' => [$username], + 'displayName' => [$row['full_name']], + 'eduPersonAffiliation' => ['member', 'employee'], + ]; /* Return the attributes. */ return $attributes; @@ -348,10 +348,10 @@ The class follows: And configured in `config/authsources.php`: - 'myauthinstance' => array( + 'myauthinstance' => [ 'mymodule:MyAuth', 'dsn' => 'mysql:host=sql.example.org;dbname=userdatabase', 'username' => 'db_username', 'password' => 'secret_db_password', - ), + ], diff --git a/docs/simplesamlphp-database.md b/docs/simplesamlphp-database.md index 01fbd5d94..b9a797a00 100644 --- a/docs/simplesamlphp-database.md +++ b/docs/simplesamlphp-database.md @@ -47,20 +47,20 @@ Since the database class allows administrators to configure master and slave dat The write function takes 2 parameters: SQL, params. $table = $db->applyPrefix("test"); - $values = array( + $values = [ 'id' => 20, 'data' => 'Some data', - ); + ]; $query = $db->write("INSERT INTO $table (id, data) VALUES (:id, :data)", $values); The values specified in the $values array will be bound to the placeholders and will be executed on the master. By default, values are binded as PDO::PARAM_STR. If you need to override this, you can specify it in the values array. $table = $db->applyPrefix("test"); - $values = array( - 'id' => array(20, PDO::PARAM_INT), + $values = [ + 'id' => [20, PDO::PARAM_INT], 'data' => 'Some data', - ); + ]; $query = $db->write("INSERT INTO $table (id, data) VALUES (:id, :data)", $values); @@ -75,17 +75,17 @@ Since the database class allows administrators to configure master and slave dat The read function takes 2 parameters: SQL, params. $table = $db->applyPrefix("test"); - $values = array( + $values = [ 'id' => 20, - ); + ]; $query = $db->read("SELECT * FROM $table WHERE id = :id", $values); The values specified in the $values array will be bound to the placeholders and will be executed on the selected slave. By default, values are binded as PDO::PARAM_STR. If you need to override this, you can specify it in the values array. $table = $db->applyPrefix("test"); - $values = array( - 'id' => array(20, PDO::PARAM_INT), - ); + $values = [ + 'id' => [20, PDO::PARAM_INT], + ]; $query = $db->read("SELECT * FROM $table WHERE id = :id", $values); diff --git a/docs/simplesamlphp-ecp-idp.md b/docs/simplesamlphp-ecp-idp.md index 28ac7f90a..566df182d 100644 --- a/docs/simplesamlphp-ecp-idp.md +++ b/docs/simplesamlphp-ecp-idp.md @@ -19,11 +19,11 @@ Enabling ECP Profile on the IdP To enable the IdP to send ECP assertions you must add the `saml20.ecp` option to the `saml20-idp-hosted` metadata file: - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ [....] 'auth' => 'example-userpass', 'saml20.ecp' => true, - ); + ]; Note: authentication filters that require interaction with the user will not work with ECP. diff --git a/docs/simplesamlphp-errorhandling.md b/docs/simplesamlphp-errorhandling.md index 1c9c8097c..f7251550b 100644 --- a/docs/simplesamlphp-errorhandling.md +++ b/docs/simplesamlphp-errorhandling.md @@ -205,11 +205,11 @@ The code for handling this becomes something like: $procChain = [...]; - $state = array( + $state = [ 'ReturnURL' => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), \SimpleSAML\Auth\State::EXCEPTION_HANDLER_URL => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), [...], - ) + ] try { $procChain->processState($state); diff --git a/docs/simplesamlphp-googleapps.md b/docs/simplesamlphp-googleapps.md index 3eba11a6a..5f8cfbd3c 100644 --- a/docs/simplesamlphp-googleapps.md +++ b/docs/simplesamlphp-googleapps.md @@ -100,17 +100,17 @@ The next step is to create an authentication source with this module. An authent In this example we will use `example-userpass`, and hence that section is what matters and will be used. <?php - $config = array( - 'example-userpass' => array( + $config = [ + 'example-userpass' => [ 'exampleauth:UserPass', - 'student:studentpass' => array( - 'uid' => array('student'), - ), - 'employee:employeepass' => array( - 'uid' => array('employee'), - ), - ), - ); + 'student:studentpass' => [ + 'uid' => ['student'], + ], + 'employee:employeepass' => [ + 'uid' => ['employee'], + ], + ], + ]; ?> This configuration creates two users - `student` and `employee`, with the passwords `studentpass` and `employeepass`. The username and password are stored in the array index `student:studentpass` for the `student`-user. The attributes (only `uid` in this example) will be returned by the IdP when the user logs on. @@ -127,7 +127,7 @@ If you want to setup a SAML 2.0 IdP for Google Apps, you need to configure two m This is the configuration of the IdP itself. Here is some example config: // The SAML entity ID is the index of this config. Dynamic:X will automatically generate an entity ID (recommended) - $metadata['__DYNAMIC:1__'] => array( + $metadata['__DYNAMIC:1__'] => [ // The hostname of the server (VHOST) that this SAML entity will use. 'host' => '__DEFAULT__', @@ -137,7 +137,7 @@ This is the configuration of the IdP itself. Here is some example config: 'certificate' => 'googleappsidp.crt', 'auth' => 'example-userpass', - ) + ] **Note**: You can only have one entry in the file with host equal to `__DEFAULT__`, therefore you should replace the existing entry with this one, instead of adding this entry as a new entry in the file. @@ -152,12 +152,12 @@ In the `saml20-sp-remote.php` file we will configure an entry for G Suite (Googl * at G Suite. E.g. if your google account is foo.com, and you have a user with email john@foo.com, then you * must set the simplesaml.nameidattribute to be the name of an attribute that for this user has the value of 'john'. */ - $metadata['https://www.google.com/a/g.feide.no'] => array( + $metadata['https://www.google.com/a/g.feide.no'] => [ 'AssertionConsumerService' => 'https://www.google.com/a/g.feide.no/acs', 'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress', 'simplesaml.nameidattribute' => 'uid', 'simplesaml.attributes' => false - ); + ]; You must also map some attributes received from the authentication module into email field sent to Google Apps. In this example, the `uid` attribute is set. When you later configure the IdP to connect to a LDAP directory or some other authentication source, make sure that the `uid` attribute is set properly, or you can configure another attribute to use here. The `uid` attribute contains the local part of the user name. diff --git a/docs/simplesamlphp-hok-idp.md b/docs/simplesamlphp-hok-idp.md index e34a6b827..a2315bf74 100644 --- a/docs/simplesamlphp-hok-idp.md +++ b/docs/simplesamlphp-hok-idp.md @@ -29,11 +29,11 @@ Enabling HoK SSO Profile on the IdP To enable the IdP to send HoK assertions you must add the `saml20.hok.assertion` option to the `saml20-idp-hosted` metadata file: - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ [....] 'auth' => 'example-userpass', 'saml20.hok.assertion' => TRUE, - ); + ]; Add new metadata to SPs ----------------------- @@ -62,16 +62,16 @@ This means that you have to use the complex endpoint format in `saml20-sp-remote In general, this should look like the following code: 'AssertionConsumerService' => array ( - array( + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', 'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'index' => 0, - ), - array( + ], + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser', 'Location' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'index' => 4, - ), + ], ), (The specific values of the various fields will vary depending on the SP.) diff --git a/docs/simplesamlphp-hok-sp.md b/docs/simplesamlphp-hok-sp.md index a687896c5..4b12a113a 100644 --- a/docs/simplesamlphp-hok-sp.md +++ b/docs/simplesamlphp-hok-sp.md @@ -31,10 +31,10 @@ To enable support for the HoK SSO Profile in the SP, the `saml20.hok.assertion` This option can also be enabled in the `saml20-idp-remote` metadata file, but in that case the endpoint will not be added to the SP metadata. You must also send authentication requests specifying the Holder-of-Key profile to the IdP. This is controlled by the `ProtocolBinding` option in the SP configuration. - 'hok-sp' => array( + 'hok-sp' => [ 'saml:SP', 'saml20.hok.assertion' => TRUE, 'ProtocolBinding' => 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser', - ), + ], When this is done, you can add the metadata of your SP to the IdP and test the authentication. diff --git a/docs/simplesamlphp-idp.md b/docs/simplesamlphp-idp.md index 3654d237f..1401d1d54 100644 --- a/docs/simplesamlphp-idp.md +++ b/docs/simplesamlphp-idp.md @@ -96,26 +96,26 @@ The next step is to create an authentication source with this module. An authent In this setup, this file should contain a single entry: <?php - $config = array( - 'example-userpass' => array( + $config = [ + 'example-userpass' => [ 'exampleauth:UserPass', - 'student:studentpass' => array( - 'uid' => array('student'), - 'eduPersonAffiliation' => array('member', 'student'), - ), - 'employee:employeepass' => array( - 'uid' => array('employee'), - 'eduPersonAffiliation' => array('member', 'employee'), - ), - ), - ); + 'student:studentpass' => [ + 'uid' => ['student'], + 'eduPersonAffiliation' => ['member', 'student'], + ], + 'employee:employeepass' => [ + 'uid' => ['employee'], + 'eduPersonAffiliation' => ['member', 'employee'], + ], + ], + ]; This configuration creates two users - `student` and `employee`, with the passwords `studentpass` and `employeepass`. The username and password is stored in the array index (`student:studentpass` for the `student`-user. The attributes for each user is configured in the array referenced by the index. For the student user, these are: - array( - 'uid' => array('student'), - 'eduPersonAffiliation' => array('member', 'student'), - ), + [ + 'uid' => ['student'], + 'eduPersonAffiliation' => ['member', 'student'], + ], The attributes will be returned by the IdP when the user logs on. @@ -145,7 +145,7 @@ The SAML 2.0 IdP is configured by the metadata stored in This is a minimal configuration: <?php - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ /* * The hostname for this IdP. This makes it possible to run multiple * IdPs from the same configuration. '__DEFAULT__' means that this one @@ -165,7 +165,7 @@ This is a minimal configuration: * user. This must match one of the entries in config/authsources.php. */ 'auth' => 'example-userpass', - ); + ]; For more information about available options in the idp-hosted metadata files, see the [IdP hosted reference](simplesamlphp-reference-idp-hosted). @@ -179,10 +179,10 @@ We therefore recommended enabling this in new installations. This can be done by adding the following to the saml20-idp-hosted configuration: 'attributes.NameFormat' => 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri', - 'authproc' => array( + 'authproc' => [ // Convert LDAP names to oids. - 100 => array('class' => 'core:AttributeMap', 'name2oid'), - ), + 100 => ['class' => 'core:AttributeMap', 'name2oid'], + ], Adding SPs to the IdP @@ -193,10 +193,10 @@ This is configured by metadata stored in `metadata/saml20-sp-remote.php`. This is a minimal example of a `metadata/saml20-sp-remote.php` metadata file for a SimpleSAMLphp SP: <?php - $metadata['https://sp.example.org/simplesaml/module.php/saml/sp/metadata.php/default-sp'] = array( + $metadata['https://sp.example.org/simplesaml/module.php/saml/sp/metadata.php/default-sp'] = [ 'AssertionConsumerService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'SingleLogoutService' => 'https://sp.example.org/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp', - ); + ]; Note that the URI in the entityID and the URLs to the AssertionConsumerService and SingleLogoutService endpoints change between different service providers. If you have the metadata of the remote SP as an XML file, you can use the built-in XML to SimpleSAMLphp metadata converter, which by default is available as `/admin/metadata-converter.php` in your SimpleSAMLphp installation. @@ -252,7 +252,7 @@ To send the RelayState parameter from a SimpleSAMLphp IdP, specify it in the que To set it in the SP configuration, add it to `authsources.php`: - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', 'RelayState' => 'https://sp.example.org/welcome.php', - ), + ], diff --git a/docs/simplesamlphp-maintenance.md b/docs/simplesamlphp-maintenance.md index cfd2d7e37..ff4581b03 100644 --- a/docs/simplesamlphp-maintenance.md +++ b/docs/simplesamlphp-maintenance.md @@ -96,26 +96,26 @@ Here are two examples of configuration of memcache session handling: Example of redundant configuration with load balancing: This configuration makes it possible to lose both servers in the a-group or both servers in the b-group without losing any sessions. Note that sessions will be lost if one server is lost from both the a-group and the b-group. - 'memcache_store.servers' => array( - array( - array('hostname' => 'mc_a1'), - array('hostname' => 'mc_a2'), - ), - array( - array('hostname' => 'mc_b1'), - array('hostname' => 'mc_b2'), - ), - ), + 'memcache_store.servers' => [ + [ + ['hostname' => 'mc_a1'], + ['hostname' => 'mc_a2'], + ], + [ + ['hostname' => 'mc_b1'], + ['hostname' => 'mc_b2'], + ], + ], **Example 2. Example of simple configuration with only one memcache server** Example of simple configuration with only one memcache server, running on the same computer as the web server: Note that all sessions will be lost if the memcache server crashes. - 'memcache_store.servers' => array( - array( - array('hostname' => 'localhost'), - ), - ), + 'memcache_store.servers' => [ + [ + ['hostname' => 'localhost'], + ], + ], The expiration value (`memcache_store.expires`) is the duration for which data should be retained in memcache. Data are dropped from the memcache servers when this time expires. The time will be reset every time the data is written to the memcache servers. @@ -170,11 +170,11 @@ Several metadata storage backends are available by default, including `flatfile` example configuration of different metadata sources in use at the same time: ``` -'metadata.sources' => array( - array('type' => 'flatfile'), - array('type' => 'flatfile', 'directory' => 'metadata/metarefresh-kalmar'), - array('type' => 'serialize', 'directory' => 'metadata/metarefresh-ukaccess'), -), +'metadata.sources' => [ + ['type' => 'flatfile'], + ['type' => 'flatfile', 'directory' => 'metadata/metarefresh-kalmar'], + ['type' => 'serialize', 'directory' => 'metadata/metarefresh-ukaccess'], +], ``` You may also implement your own metadata storage handler, in a very similar way to how you would implement @@ -245,7 +245,7 @@ To add support for a new language, add your new language to the `language.availa /* * Languages available and which language is default */ - 'language.available' => array('en', 'no', 'da', 'es', 'xx'), + 'language.available' => ['en', 'no', 'da', 'es', 'xx'], 'language.default' => 'en', Please use the standardized two-character @@ -255,11 +255,11 @@ You also can set the default language. You should ensure that the default langua All strings that can be localized are found in the files `dictionaries/`. Add a new entry for each string, with your language code, like this: - 'user_pass_header' => array( + 'user_pass_header' => [ 'en' => 'Enter your username and password', 'no' => 'Skriv inn brukernavn og passord', 'xx' => 'Pooa jujjique jamba', - ), + ], You can translate as many of the texts as you would like; a full translation is not required unless you want to make this the default language. From the end users point of view, it looks best if all text fragments used in a given screen or form is in one single language. diff --git a/docs/simplesamlphp-metadata-endpoints.md b/docs/simplesamlphp-metadata-endpoints.md index 9bca9088d..7200c9187 100644 --- a/docs/simplesamlphp-metadata-endpoints.md +++ b/docs/simplesamlphp-metadata-endpoints.md @@ -32,10 +32,10 @@ It can be used when there is only a single endpoint that uses the default bindin Array of strings ---------------- - 'AssertionConsumerService' => array( + 'AssertionConsumerService' => [ 'https://site1.example.org/ACS', 'https://site2.example.org/ACS', - ), + ], This endpoint format can be used to represent multiple endpoints, all of which use the default binding. @@ -43,28 +43,28 @@ This endpoint format can be used to represent multiple endpoints, all of which u Array of arrays --------------- - 'AssertionConsumerService' => array( - array( + 'AssertionConsumerService' => [ + [ 'index' => 1, 'isDefault' => TRUE, 'Location' => 'https://sp.example.org/ACS', 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', - ), - array( + ], + [ 'index' => 2, 'Location' => 'https://sp.example.org/ACS', 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', - ), - ), + ], + ], This endpoint format allows for specifying multiple endpoints with different bindings. It can also be used to specify the ResponseLocation attribute on endpoints, e.g. on `SingleLogoutService`: - 'SingleLogoutService' => array( - array( + 'SingleLogoutService' => [ + [ 'Location' => 'https://sp.example.org/LogoutRequest', 'ResponseLocation' => 'https://sp.example.org/LogoutResponse', 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', - ), - ), + ], + ], diff --git a/docs/simplesamlphp-metadata-extensions-attributes.md b/docs/simplesamlphp-metadata-extensions-attributes.md index 7e3c1c0bc..832bc9c7d 100644 --- a/docs/simplesamlphp-metadata-extensions-attributes.md +++ b/docs/simplesamlphp-metadata-extensions-attributes.md @@ -19,14 +19,14 @@ The `metadata/saml20-idp-hosted.php` entries are used to define the metadata extension items. An example of this is: <?php - $metadata['entity-id-1'] = array( + $metadata['entity-id-1'] = [ /* ... */ - 'EntityAttributes' => array( - 'urn:simplesamlphp:v1:simplesamlphp' => array('is', 'really', 'cool'), - '{urn:simplesamlphp:v1}foo' => array('bar'), - ), + 'EntityAttributes' => [ + 'urn:simplesamlphp:v1:simplesamlphp' => ['is', 'really', 'cool'], + '{urn:simplesamlphp:v1}foo' => ['bar'], + ], /* ... */ - ); + ]; The OASIS specification primarily defines how to include arbitrary `Attribute` and `Assertion` elements within the metadata for an IdP. @@ -43,9 +43,9 @@ metadata. Each item in the `EntityAttributes` array defines a new array. Each item in this array produces a separte `<AttributeValue>` element within the `<Attribute>` element. - 'EntityAttributes' => array( - 'urn:simplesamlphp:v1:simplesamlphp' => array('is', 'really', 'cool'), - ), + 'EntityAttributes' => [ + 'urn:simplesamlphp:v1:simplesamlphp' => ['is', 'really', 'cool'], + ], This generates: @@ -58,9 +58,9 @@ This generates: Each `<Attribute>` element requires a `NameFormat` attribute. This is specified using curly braces at the beginning of the key name: - 'EntityAttributes' => array( - '{urn:simplesamlphp:v1}foo' => array('bar'), - ), + 'EntityAttributes' => [ + '{urn:simplesamlphp:v1}foo' => ['bar'], + ], This generates: @@ -76,17 +76,17 @@ Generated XML Metadata Examples If given the following configuration... - $metadata['https://www.example.com/saml/saml2/idp/metadata.php'] = array( + $metadata['https://www.example.com/saml/saml2/idp/metadata.php'] = [ 'host' => 'www.example.com', 'certificate' => 'example.com.crt', 'privatekey' => 'example.com.pem', 'auth' => 'example-userpass', - 'EntityAttributes' => array( - 'urn:simplesamlphp:v1:simplesamlphp' => array('is', 'really', 'cool'), - '{urn:simplesamlphp:v1}foo' => array('bar'), - ), - ); + 'EntityAttributes' => [ + 'urn:simplesamlphp:v1:simplesamlphp' => ['is', 'really', 'cool'], + '{urn:simplesamlphp:v1}foo' => ['bar'], + ], + ]; ... will generate the following XML metadata: diff --git a/docs/simplesamlphp-metadata-extensions-rpi.md b/docs/simplesamlphp-metadata-extensions-rpi.md index 4799de19b..a6dc868e7 100644 --- a/docs/simplesamlphp-metadata-extensions-rpi.md +++ b/docs/simplesamlphp-metadata-extensions-rpi.md @@ -59,54 +59,54 @@ Examples Service Provider: - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', 'entityID' => NULL, ... - 'RegistrationInfo' => array( + 'RegistrationInfo' => [ 'authority' => 'urn:mace:sp.example.org', 'instant' => '2008-01-17T11:28:03.577Z', - 'policies' => array('en' => 'http://sp.example.org/policy', 'es' => 'http://sp.example.org/politica'), - ), - ), + 'policies' => ['en' => 'http://sp.example.org/policy', 'es' => 'http://sp.example.org/politica'], + ], + ], Identity Provider: - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ 'host' => '__DEFAULT__', ... - 'RegistrationInfo' => array( + 'RegistrationInfo' => [ 'authority' => 'urn:mace:idp.example.org', 'instant' => '2008-01-17T11:28:03.577Z', - ), - ); + ], + ]; `aggregator` module: - $config = array( - 'aggregators' => array( + $config = [ + 'aggregators' => [ ... - ), + ], 'maxDuration' => 60*60*24*5, 'reconstruct' => FALSE, ... - 'RegistrationInfo' => array( + 'RegistrationInfo' => [ 'authority' => 'urn:mace:example.federation', 'instant' => '2008-01-17T11:28:03Z', - 'policies' => array('en' => 'http://example.org/federation_policy', 'es' => 'https://example.org/politica_federacion'), - ), - ); + 'policies' => ['en' => 'http://example.org/federation_policy', 'es' => 'https://example.org/politica_federacion'], + ], + ]; `aggregator2` module: - $config = array( - 'example.org' => array( - 'sources' => array( + $config = [ + 'example.org' => [ + 'sources' => [ ... - ), - 'RegistrationInfo' => array( + ], + 'RegistrationInfo' => [ 'authority' => 'urn:mace:example.federation', - 'policies' => array('en' => 'http://example.org/federation_policy', 'es' => 'https://example.org/politica_federacion'), - ), - ), - ); + 'policies' => ['en' => 'http://example.org/federation_policy', 'es' => 'https://example.org/politica_federacion'], + ], + ], + ]; diff --git a/docs/simplesamlphp-metadata-extensions-ui.md b/docs/simplesamlphp-metadata-extensions-ui.md index f9627b93e..10dd3aba0 100644 --- a/docs/simplesamlphp-metadata-extensions-ui.md +++ b/docs/simplesamlphp-metadata-extensions-ui.md @@ -23,72 +23,72 @@ the relevant entry in `authsources.php`. An example for an IdP: <?php - $metadata['entity-id-1'] = array( + $metadata['entity-id-1'] = [ /* ... */ - 'UIInfo' => array( - 'DisplayName' => array( + 'UIInfo' => [ + 'DisplayName' => [ 'en' => 'English name', 'es' => 'Nombre en Español', - ), - 'Description' => array( + ], + 'Description' => [ 'en' => 'English description', 'es' => 'DescripciĂłn en Español', - ), - 'InformationURL' => array( + ], + 'InformationURL' => [ 'en' => 'http://example.com/info/en', 'es' => 'http://example.com/info/es', - ), - 'PrivacyStatementURL' => array( + ], + 'PrivacyStatementURL' => [ 'en' => 'http://example.com/privacy/en', 'es' => 'http://example.com/privacy/es', - ), - 'Keywords' => array( - 'en' => array('communication', 'federated session'), - 'es' => array('comunicaciĂłn', 'sesiĂłn federated'), - ), - 'Logo' => array( - array( + ], + 'Keywords' => [ + 'en' => ['communication', 'federated session'], + 'es' => ['comunicaciĂłn', 'sesiĂłn federated'], + ], + 'Logo' => [ + [ 'url' => 'http://example.com/logo1.png', 'height' => 200, 'width' => 400, 'lang' => 'en', - ), - array( + ], + [ 'url' => 'http://example.com/logo2.png', 'height' => 201, 'width' => 401, - ), - ), - ), - 'DiscoHints' => array( - 'IPHint' => array('130.59.0.0/16', '2001:620::0/96'), - 'DomainHint' => array('example.com', 'www.example.com'), - 'GeolocationHint' => array('geo:47.37328,8.531126', 'geo:19.34343,12.342514'), - ), + ], + ], + ], + 'DiscoHints' => [ + 'IPHint' => ['130.59.0.0/16', '2001:620::0/96'], + 'DomainHint' => ['example.com', 'www.example.com'], + 'GeolocationHint' => ['geo:47.37328,8.531126', 'geo:19.34343,12.342514'], + ], /* ... */ - ); + ]; And for an SP it could look like this: <?php - $config = array( + $config = [ - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', - 'UIInfo' => array( - 'DisplayName' => array( + 'UIInfo' => [ + 'DisplayName' => [ 'en' => 'English name', 'es' => 'Nombre en Español' - ), - 'Description' => array( + ], + 'Description' => [ 'en' => 'English description', 'es' => 'DescripciĂłn en Español' - ), - ), + ], + ], /* ... */ - ), - ); + ], + ]; The OASIS specification primarily defines how an entity can communicate metadata related to IdP or service discovery and identification. There @@ -106,52 +106,52 @@ about an IdP or SP. These properties are all children of the `UIInfo` key. *Note*: Most elements are localized strings that specify the language using the array key as the language-code: - 'DisplayName' => array( + 'DisplayName' => [ 'en' => 'English name', 'es' => 'Nombre en Español', - ), + ], `DisplayName` : The localized list of names for this entity - 'DisplayName' => array( + 'DisplayName' => [ 'en' => 'English name', 'es' => 'Nombre en Español', - ), + ], `Description` : The localized list of statements used to describe this entity - 'Description' => array( + 'Description' => [ 'en' => 'English description', 'es' => 'DescripciĂłn en Español', - ), + ], `InformationURL` : A localized list of URLs where more information about the entity is located. - 'InformationURL' => array( + 'InformationURL' => [ 'en' => 'http://example.com/info/en', 'es' => 'http://example.com/info/es', - ), + ], `PrivacyStatementURL` : A localized list of URLs where the entity's privacy statement is located. - 'PrivacyStatementURL' => array( + 'PrivacyStatementURL' => [ 'en' => 'http://example.com/privacy/en', 'es' => 'http://example.com/privacy/es', - ), + ], `Keywords` : A localized list of keywords used to describe the entity - 'Keywords' => array( - 'en' => array('communication', 'federated session'), - 'es' => array('comunicaciĂłn', 'sesiĂłn federated'), - ), + 'Keywords' => [ + 'en' => ['communication', 'federated session'], + 'es' => ['comunicaciĂłn', 'sesiĂłn federated'], + ], : *Note*: The `+` (plus) character is forbidden by specification from being part of a Keyword. @@ -159,19 +159,19 @@ using the array key as the language-code: `Logo` : The logos used to represent the entity - 'Logo' => array( - array( + 'Logo' => [ + [ 'url' => 'http://example.com/logo1.png', 'height' => 200, 'width' => 400, 'lang' => 'en', - ), - array( + ], + [ 'url' => 'http://example.com/logo2.png', 'height' => 201, 'width' => 401, - ), - ), + ], + ], : An optional `lang` key containing a language-code is supported for localized logos. @@ -188,20 +188,20 @@ key. : This is a list of both IPv4 and IPv6 addresses in CIDR notation services by or associated with this entity. - 'IPHint' => array('130.59.0.0/16', '2001:620::0/96'), + 'IPHint' => ['130.59.0.0/16', '2001:620::0/96'], `DomainHint` : This specifies a list of domain names serviced by or associated with this entity. - 'DomainHint' => array('example.com', 'www.example.com'), + 'DomainHint' => ['example.com', 'www.example.com'], `GeolocationHint` : This specifies a list of geographic coordinates associated with, or serviced by, the entity. Coordinates are given in URI form using the geo URI scheme [RFC5870](http://www.ietf.org/rfc/rfc5870.txt). - 'GeolocationHint' => array('geo:47.37328,8.531126', 'geo:19.34343,12.342514'), + 'GeolocationHint' => ['geo:47.37328,8.531126', 'geo:19.34343,12.342514'], Generated XML Metadata Examples @@ -209,52 +209,52 @@ Generated XML Metadata Examples If given the following configuration... - $metadata['https://www.example.com/saml/saml2/idp/metadata.php'] = array( + $metadata['https://www.example.com/saml/saml2/idp/metadata.php'] = [ 'host' => 'www.example.com', 'certificate' => 'example.com.crt', 'privatekey' => 'example.com.pem', 'auth' => 'example-userpass', - 'UIInfo' => array( - 'DisplayName' => array( + 'UIInfo' => [ + 'DisplayName' => [ 'en' => 'English name', 'es' => 'Nombre en Español', - ), - 'Description' => array( + ], + 'Description' => [ 'en' => 'English description', 'es' => 'DescripciĂłn en Español', - ), - 'InformationURL' => array( + ], + 'InformationURL' => [ 'en' => 'http://example.com/info/en', 'es' => 'http://example.com/info/es', - ), - 'PrivacyStatementURL' => array( + ], + 'PrivacyStatementURL' => [ 'en' => 'http://example.com/privacy/en', 'es' => 'http://example.com/privacy/es', - ), - 'Keywords' => array( - 'en' => array('communication', 'federated session'), - 'es' => array('comunicaciĂłn', 'sesiĂłn federated'), - ), - 'Logo' => array( - array( + ], + 'Keywords' => [ + 'en' => ['communication', 'federated session'], + 'es' => ['comunicaciĂłn', 'sesiĂłn federated'], + ], + 'Logo' => [ + [ 'url' => 'http://example.com/logo1.png', 'height' => 200, 'width' => 400, - ), - array( + ], + [ 'url' => 'http://example.com/logo2.png', 'height' => 201, 'width' => 401, - ), - ), - ), - 'DiscoHints' => array( - 'IPHint' => array('130.59.0.0/16', '2001:620::0/96'), - 'DomainHint' => array('example.com', 'www.example.com'), - 'GeolocationHint' => array('geo:47.37328,8.531126', 'geo:19.34343,12.342514'), - ), - ); + ], + ], + ], + 'DiscoHints' => [ + 'IPHint' => ['130.59.0.0/16', '2001:620::0/96'], + 'DomainHint' => ['example.com', 'www.example.com'], + 'GeolocationHint' => ['geo:47.37328,8.531126', 'geo:19.34343,12.342514'], + ], + ]; ... will generate the following XML metadata: diff --git a/docs/simplesamlphp-metadata-pdostoragehandler.md b/docs/simplesamlphp-metadata-pdostoragehandler.md index 82656fb09..9724a6d2e 100644 --- a/docs/simplesamlphp-metadata-pdostoragehandler.md +++ b/docs/simplesamlphp-metadata-pdostoragehandler.md @@ -35,10 +35,10 @@ You will first need to configure a PDO metadata source. Here is an example of flatfile plus PDO: - 'metadata.sources' => array( - array('type' => 'flatfile'), - array('type' => 'pdo'), - ), + 'metadata.sources' => [ + ['type' => 'flatfile'], + ['type' => 'pdo'], + ], diff --git a/docs/simplesamlphp-modules.md b/docs/simplesamlphp-modules.md index 300cfb802..ed0df9982 100644 --- a/docs/simplesamlphp-modules.md +++ b/docs/simplesamlphp-modules.md @@ -150,26 +150,26 @@ authentication source. A typical configuration entry for an authentication source looks like this: - 'example-static' => array( + 'example-static' => [ /* This maps to modules/exampleauth/lib/Auth/Source/Static.php */ 'exampleauth:Static', /* The following is configuration which is passed on to * the exampleauth:Static authentication source. */ 'uid' => 'testuser', - 'eduPersonAffiliation' => array('member', 'employee'), - 'cn' => array('Test User'), - ), + 'eduPersonAffiliation' => ['member', 'employee'], + 'cn' => ['Test User'], + ], To use this authentication source in a SAML 2.0 IdP, set the `auth`-option of the IdP to `'example-static'`: - '__DYNAMIC:1__' => array( + '__DYNAMIC:1__' => [ 'host' => '__DEFAULT__', 'privatekey' => 'example.org.pem', 'certificate' => 'example.org.crt', 'auth' => 'example-static', - ), + ], ### Creating authentication sources diff --git a/docs/simplesamlphp-reference-idp-hosted.md b/docs/simplesamlphp-reference-idp-hosted.md index fc134dded..add1d7f00 100644 --- a/docs/simplesamlphp-reference-idp-hosted.md +++ b/docs/simplesamlphp-reference-idp-hosted.md @@ -9,14 +9,14 @@ Both files have the following format: <?php /* The index of the array is the entity ID of this IdP. */ - $metadata['entity-id-1'] = array( + $metadata['entity-id-1'] = [ 'host' => 'idp.example.org', /* Configuration options for the first IdP. */ - ); - $metadata['entity-id-2'] = array( + ]; + $metadata['entity-id-2'] = [ 'host' => '__DEFAULT__', /* Configuration options for the default IdP. */ - ); + ]; /* ... */ The entity ID should be an URI. It can, also be on the form @@ -54,33 +54,33 @@ Common options : Specify contacts in addition to the technical contact configured through config/config.php. For example, specifying a support contact: - 'contacts' => array( - array( + 'contacts' => [ + [ 'contactType' => 'support', 'emailAddress' => 'support@example.org', 'givenName' => 'John', 'surName' => 'Doe', 'telephoneNumber' => '+31(0)12345678', 'company' => 'Example Inc.', - ), - ), + ], + ], : If you have support for a trust framework that requires extra attributes on the contact person element in your IdP metadata (for example, SIRTFI), you can specify an array of attributes on a contact. - 'contacts' => array( - array( + 'contacts' => [ + [ 'contactType' => 'other', 'emailAddress' => 'mailto:abuse@example.org', 'givenName' => 'John', 'surName' => 'Doe', 'telephoneNumber' => '+31(0)12345678', 'company' => 'Example Inc.', - 'attributes' => array( + 'attributes' => [ 'xmlns:remd' => 'http://refeds.org/metadata', 'remd:contactType' => 'http://refeds.org/metadata/contactType/security', - ), - ), - ), + ], + ], + ], `host` : The hostname for this IdP. One IdP can also have the `host`-option @@ -96,10 +96,10 @@ Common options : This option can be translated into multiple languages by specifying the value as an array of language-code to translated name: - 'OrganizationName' => array( + 'OrganizationName' => [ 'en' => 'Example organization', 'no' => 'Eksempel organisation', - ), + ], : *Note*: If you specify this option, you must also specify the `OrganizationURL` option. @@ -427,7 +427,7 @@ These are some examples of IdP metadata * We use the '__DYNAMIC:1__' entity ID so that the entity ID * will be autogenerated. */ - $metadata['__DYNAMIC:1__'] = array( + $metadata['__DYNAMIC:1__'] = [ /* * We use '__DEFAULT__' as the hostname so we won't have to * enter a hostname. @@ -443,4 +443,4 @@ These are some examples of IdP metadata * from config/authsources.php. */ 'auth' => 'example-userpass', - ); + ]; diff --git a/docs/simplesamlphp-reference-idp-remote.md b/docs/simplesamlphp-reference-idp-remote.md index 7908ebc39..af324ef4d 100644 --- a/docs/simplesamlphp-reference-idp-remote.md +++ b/docs/simplesamlphp-reference-idp-remote.md @@ -7,12 +7,12 @@ This is a reference for metadata options available for `metadata/saml20-idp-remo <?php /* The index of the array is the entity ID of this IdP. */ - $metadata['entity-id-1'] = array( + $metadata['entity-id-1'] = [ /* Configuration options for the first IdP. */ - ); - $metadata['entity-id-2'] = array( + ]; + $metadata['entity-id-2'] = [ /* Configuration options for the second IdP. */ - ); + ]; /* ... */ @@ -50,10 +50,10 @@ The following options are common between both the SAML 2.0 protocol and Shibbole : This option can be translated into multiple languages by specifying the value as an array of language-code to translated name: - 'OrganizationName' => array( + 'OrganizationName' => [ 'en' => 'Example organization', 'no' => 'Eksempel organisation', - ), + ], : *Note*: If you specify this option, you must also specify the `OrganizationURL` option. @@ -80,10 +80,10 @@ The following options are common between both the SAML 2.0 protocol and Shibbole : This option can be translated into multiple languages by specifying the value as an array of language-code to translated name: - 'name' => array( + 'name' => [ 'en' => 'A service', 'no' => 'En tjeneste', - ), + ], `scope` : An array with scopes valid for this IdP. diff --git a/docs/simplesamlphp-reference-sp-remote.md b/docs/simplesamlphp-reference-sp-remote.md index 2eb7efd32..1ddddab60 100644 --- a/docs/simplesamlphp-reference-sp-remote.md +++ b/docs/simplesamlphp-reference-sp-remote.md @@ -9,12 +9,12 @@ Both files have the following format: <?php /* The index of the array is the entity ID of this SP. */ - $metadata['entity-id-1'] = array( + $metadata['entity-id-1'] = [ /* Configuration options for the first SP. */ - ); - $metadata['entity-id-2'] = array( + ]; + $metadata['entity-id-2'] = [ /* Configuration options for the second SP. */ - ); + ]; /* ... */ @@ -54,10 +54,10 @@ and Shibboleth 1.3 protocol: : This option can be translated into multiple languages by specifying the value as an array of language-code to translated name: - 'name' => array( + 'name' => [ 'en' => 'A service', 'no' => 'En tjeneste', - ), + ], `OrganizationName` : The name of the organization responsible for this SPP. @@ -65,10 +65,10 @@ and Shibboleth 1.3 protocol: : This option can be translated into multiple languages by specifying the value as an array of language-code to translated name: - 'OrganizationName' => array( + 'OrganizationName' => [ 'en' => 'Example organization', 'no' => 'Eksempel organisation', - ), + ], : *Note*: If you specify this option, you must also specify the `OrganizationURL` option. @@ -376,7 +376,7 @@ idp is in the intersection the discoveryservice will go directly to the idp. **Example: Configuration for scoping** - 'IDPList' => array('https://idp1.wayf.dk', 'https://idp2.wayf.dk'), + 'IDPList' => ['https://idp1.wayf.dk', 'https://idp2.wayf.dk'], Shibboleth 1.3 options diff --git a/docs/simplesamlphp-scoping.md b/docs/simplesamlphp-scoping.md index 3124122ed..c821b30e7 100644 --- a/docs/simplesamlphp-scoping.md +++ b/docs/simplesamlphp-scoping.md @@ -55,11 +55,11 @@ The ProxyCount and IDPList option can be specified in the following places: Example configuration: # Add the IDPList - 'IDPList' => array( + 'IDPList' => [ 'IdPEntityID1', 'IdPEntityID2', 'IdPEntityID3', - ), + ], # Set ProxyCount 'ProxyCount' => 2, diff --git a/docs/simplesamlphp-sp-api.md b/docs/simplesamlphp-sp-api.md index cc43e4bcd..07c851f9d 100644 --- a/docs/simplesamlphp-sp-api.md +++ b/docs/simplesamlphp-sp-api.md @@ -42,7 +42,7 @@ Check whether the user is authenticated with this authentication source. `requireAuth` ------------- - void requireAuth(array $params = array()) + void requireAuth(array $params = []) Make sure that the user is authenticated. This function will only return if the user is authenticated. @@ -65,17 +65,17 @@ See the documentation for the `login`-function for a description of the paramete * Return the user to the frontpage after authentication, don't post * the current POST data. */ - $auth->requireAuth(array( + $auth->requireAuth([ 'ReturnTo' => 'https://sp.example.org/', 'KeepPost' => FALSE, - )); + ]); print("Hello, authenticated user!"); `login` ------------- - void login(array $params = array()) + void login(array $params = []) Start a login operation. This function will always start a new authentication process. @@ -108,10 +108,10 @@ The [`saml:SP`](./saml:sp) authentication source also defines some parameters. ### Example # Send a passive authentication request. - $auth->login(array( + $auth->login([ 'isPassive' => TRUE, 'ErrorURL' => 'https://.../error_handler.php', - )); + ]); `logout` @@ -149,11 +149,11 @@ Logout, and redirect to the specified URL. Same as the previous, but check the result of the logout operation afterwards. - $auth->logout(array( + $auth->logout([ 'ReturnTo' => 'https://sp.example.org/logged_out.php', 'ReturnStateParam' => 'LogoutState', 'ReturnStateStage' => 'MyLogoutState', - )); + ]); And in logged_out.php: @@ -178,10 +178,10 @@ If the user isn't authenticated, an empty array will be returned. The attributes will be returned as an associative array with the name of the attribute as the key and the value as an array of one or more strings: - array( - 'uid' => array('testuser'), - 'eduPersonAffiliation' => array('student', 'member'), - ) + [ + 'uid' => ['testuser'], + 'eduPersonAffiliation' => ['student', 'member'], + ] ### Example diff --git a/docs/simplesamlphp-sp-migration.md b/docs/simplesamlphp-sp-migration.md index 92187b802..8827b3e23 100644 --- a/docs/simplesamlphp-sp-migration.md +++ b/docs/simplesamlphp-sp-migration.md @@ -25,15 +25,15 @@ To do this, we open `config/authsources.php`. Create the file if it does not exi If you create the file, it should look like this: <?php - $config = array( + $config = [ /* Here we can add entries for authentication sources we want to use. */ - ); + ]; We are going to add an entry to this file. The entry should look something like this: - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', /* @@ -49,7 +49,7 @@ The entry should look something like this: 'idp' => NULL, /* Here you can add other options to the SP. */ - ), + ], `default-sp` is the name of the authentication source. It is used to refer to this authentication source when we use it. @@ -171,7 +171,7 @@ Blocks of code like the following: \SimpleSAML\Utilities::redirect( '/' . $config->getBaseURL() . 'saml2/sp/initSSO.php', - array('RelayState' => \SimpleSAML\Utilities::selfURL()) + ['RelayState' => \SimpleSAML\Utilities::selfURL()] ); } @@ -198,7 +198,7 @@ Redirecting to the initSLO-script: \SimpleSAML\Utilities::redirect( '/' . $config->getBaseURL() . 'saml2/sp/initSLO.php', - array('RelayState' => \SimpleSAML\Utilities::selfURL()) + ['RelayState' => \SimpleSAML\Utilities::selfURL()] ); should be replaced with a call to `logout()`: diff --git a/docs/simplesamlphp-sp.md b/docs/simplesamlphp-sp.md index 453b9b525..24530e6a5 100644 --- a/docs/simplesamlphp-sp.md +++ b/docs/simplesamlphp-sp.md @@ -22,26 +22,26 @@ The SP is configured by an entry in `config/authsources.php`. This is a minimal `authsources.php` for a SP: <?php - $config = array( + $config = [ /* This is the name of this authentication source, and will be used to access it later. */ - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', - ), - ); + ], + ]; For more information about additional options available for the SP, see the [`saml:SP` reference](./saml:sp). If you want multiple Service Providers in the same site and installation, you can add more entries in the `authsources.php` configuration. If so remember to set the EntityID explicitly. Here is an example: - 'sp1' => array( + 'sp1' => [ 'saml:SP', 'entityID' => 'https://sp1.example.org/', - ), - 'sp2' => array( + ], + 'sp2' => [ 'saml:SP', 'entityID' => 'https://sp2.example.org/', - ), + ], ### Enabling a certificate for your Service Provider @@ -55,11 +55,11 @@ Create a self-signed certificate in the `cert/` directory. Then edit your `authsources.php` entry, and add references to your certificate: - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', 'privatekey' => 'saml.pem', 'certificate' => 'saml.crt', - ), + ], Adding IdPs to the SP @@ -69,11 +69,11 @@ The service provider you are configuring needs to know about the identity provid This is a minimal example of a `metadata/saml20-idp-remote.php` metadata file: <?php - $metadata['https://example.com'] = array( + $metadata['https://example.com'] = [ 'SingleSignOnService' => 'https://example.com/simplesaml/saml2/idp/SSOService.php', 'SingleLogoutService' => 'https://example.com/simplesaml/saml2/idp/SingleLogoutService.php', 'certificate' => 'example.pem', - ); + ]; `example.pem` under your `cert/` directory contains the certificate the identity provider uses for signing assertions. @@ -91,9 +91,9 @@ An option in the authentication source allows you to configure which IdP should This is the `idp` option. <?php - $config = array( + $config = [ - 'default-sp' => array( + 'default-sp' => [ 'saml:SP', /* @@ -101,8 +101,8 @@ This is the `idp` option. * Can be NULL/unset, in which case the user will be shown a list of available IdPs. */ 'idp' => 'https://idp.example.com', - ), - ); + ], + ]; Exchange metadata with the IdP @@ -180,9 +180,9 @@ Each attribute name can be used as an index into $attributes to obtain the value We can also request authentication with a specific IdP: - $as->login(array( + $as->login([ 'saml:idp' => 'https://idp.example.org/', - )); + ]); Other options are also available. Take a look in the documentation for the [SP module](./saml:sp) for a list of all parameters. diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index 234f97f6e..86c7465cd 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -23,7 +23,7 @@ class DefaultAuth $authId, $return, $errorURL = null, - array $params = array() + array $params = [] ) { $as = self::getAuthSource($authId); @@ -64,7 +64,7 @@ class DefaultAuth $session->doLogout($authority); $state['\SimpleSAML\Auth\DefaultAuth.ReturnURL'] = $returnURL; - $state['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted'); + $state['LogoutCompletedHandler'] = [get_class(), 'logoutCompleted']; $as = Source::getById($authority); if ($as === null) { diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index 5eedc264c..c83d221f9 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -255,11 +255,11 @@ class LDAP // Search using generated filter Logger::debug('Library - LDAP search(): Searching base ('.$scope.') \''.$base.'\' for \''.$filter.'\''); if ($scope === 'base') { - $result = @ldap_read($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); + $result = @ldap_read($this->ldap, $base, $filter, [], 0, 0, $this->timeout, LDAP_DEREF_NEVER); } elseif ($scope === 'onelevel') { - $result = @ldap_list($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); + $result = @ldap_list($this->ldap, $base, $filter, [], 0, 0, $this->timeout, LDAP_DEREF_NEVER); } else { - $result = @ldap_search($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); + $result = @ldap_search($this->ldap, $base, $filter, [], 0, 0, $this->timeout, LDAP_DEREF_NEVER); } if ($result === false) { @@ -386,7 +386,7 @@ class LDAP public function searchformultiple( $bases, $filters, - $attributes = array(), + $attributes = [], $and = true, $escape = true, $scope = 'subtree' @@ -608,7 +608,7 @@ class LDAP } else { // Get all attributes... // TODO: Verify that this originally was the intended behaviour. Could $attributes be a string? - $attributes = array(); + $attributes = []; } Logger::debug('Library - LDAP getAttributes(): Getting '.$description.' from DN \''.$dn.'\''); @@ -630,14 +630,14 @@ class LDAP } // Parsing each found attribute into our result set - $result = array(); // Recycling $result... Possibly bad practice. + $result = []; // Recycling $result... Possibly bad practice. for ($i = 0; $i < $attributes['count']; $i++) { // Ignore attributes that exceed the maximum allowed size $name = $attributes[$i]; $attribute = $attributes[$name]; // Deciding whether to base64 encode - $values = array(); + $values = []; for ($j = 0; $j < $attribute['count']; $j++) { $value = $attribute[$j]; @@ -728,7 +728,7 @@ class LDAP * @param string|array $values Array of values to escape * @return array Array $values, but escaped */ - public static function escape_filter_value($values = array(), $singleValue = true) + public static function escape_filter_value($values = [], $singleValue = true) { // Parameter validation $values = \SimpleSAML\Utils\Arrays::arrayize($values); diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index 55766967c..9f7daf3a3 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -52,7 +52,7 @@ class ProcessingChain assert(is_array($idpMetadata)); assert(is_array($spMetadata)); - $this->filters = array(); + $this->filters = []; $config = \SimpleSAML\Configuration::getInstance(); $configauthproc = $config->getArray('authproc.'.$mode, null); @@ -101,7 +101,7 @@ class ProcessingChain } } /* $i now points to the filter which should preceede the current filter. */ - array_splice($target, $i + 1, 0, array($filter)); + array_splice($target, $i + 1, 0, [$filter]); } } @@ -116,11 +116,11 @@ class ProcessingChain { assert(is_array($filterSrc)); - $parsedFilters = array(); + $parsedFilters = []; foreach ($filterSrc as $priority => $filter) { if (is_string($filter)) { - $filter = array('class' => $filter); + $filter = ['class' => $filter]; } if (!is_array($filter)) { @@ -255,7 +255,7 @@ class ProcessingChain * in $state['ReturnURL']. */ $id = State::saveState($state, self::COMPLETED_STAGE); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnURL'], array(self::AUTHPARAM => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnURL'], [self::AUTHPARAM => $id]); } else { /* Pass the state to the function defined in $state['ReturnCall']. */ diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php index f952ae2c3..a0a0aae44 100644 --- a/lib/SimpleSAML/Auth/Simple.php +++ b/lib/SimpleSAML/Auth/Simple.php @@ -88,7 +88,7 @@ class Simple * * @param array $params Various options to the authentication request. See the documentation. */ - public function requireAuth(array $params = array()) + public function requireAuth(array $params = []) { $session = Session::getSessionFromRequest(); @@ -115,7 +115,7 @@ class Simple * * @param array $params Various options to the authentication request. */ - public function login(array $params = array()) + public function login(array $params = []) { if (array_key_exists('KeepPost', $params)) { $keepPost = (bool) $params['KeepPost']; @@ -183,9 +183,9 @@ class Simple } if (is_string($params)) { - $params = array( + $params = [ 'ReturnTo' => $params, - ); + ]; } assert(is_array($params)); @@ -204,7 +204,7 @@ class Simple $session->doLogout($this->authSource); - $params['LogoutCompletedHandler'] = array(get_class(), 'logoutCompleted'); + $params['LogoutCompletedHandler'] = [get_class(), 'logoutCompleted']; $as = Source::getById($this->authSource); if ($as !== null) { @@ -232,7 +232,7 @@ class Simple call_user_func($state['ReturnCallback'], $state); assert(false); } else { - $params = array(); + $params = []; if (isset($state['ReturnStateParam']) || isset($state['ReturnStateStage'])) { assert(isset($state['ReturnStateParam'], $state['ReturnStateStage'])); $stateID = State::saveState($state, $state['ReturnStateStage']); @@ -255,7 +255,7 @@ class Simple { if (!$this->isAuthenticated()) { // Not authenticated - return array(); + return []; } // Authenticated @@ -316,10 +316,10 @@ class Simple $returnTo = HTTP::getSelfURL(); } - $login = Module::getModuleURL('core/as_login.php', array( + $login = Module::getModuleURL('core/as_login.php', [ 'AuthId' => $this->authSource, 'ReturnTo' => $returnTo, - )); + ]); return $login; } @@ -341,10 +341,10 @@ class Simple $returnTo = HTTP::getSelfURL(); } - $logout = Module::getModuleURL('core/as_logout.php', array( + $logout = Module::getModuleURL('core/as_logout.php', [ 'AuthId' => $this->authSource, 'ReturnTo' => $returnTo, - )); + ]); return $logout; } diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index a7dc11633..9cd848641 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -55,7 +55,7 @@ abstract class Source $config = \SimpleSAML\Configuration::getConfig('authsources.php'); - $ret = array(); + $ret = []; $sources = $config->getOptions(); foreach ($sources as $id) { @@ -160,25 +160,25 @@ abstract class Source * @param array $params Extra information about the login. Different authentication requestors may provide different * information. Optional, will default to an empty array. */ - public function initLogin($return, $errorURL = null, array $params = array()) + public function initLogin($return, $errorURL = null, array $params = []) { assert(is_string($return) || is_array($return)); assert(is_string($errorURL) || $errorURL === null); - $state = array_merge($params, array( + $state = array_merge($params, [ '\SimpleSAML\Auth\DefaultAuth.id' => $this->authId, // TODO: remove in 2.0 '\SimpleSAML\Auth\Source.id' => $this->authId, '\SimpleSAML\Auth\DefaultAuth.Return' => $return, // TODO: remove in 2.0 '\SimpleSAML\Auth\Source.Return' => $return, '\SimpleSAML\Auth\DefaultAuth.ErrorURL' => $errorURL, // TODO: remove in 2.0 '\SimpleSAML\Auth\Source.ErrorURL' => $errorURL, - 'LoginCompletedHandler' => array(get_class(), 'loginCompleted'), - 'LogoutCallback' => array(get_class(), 'logoutCallback'), - 'LogoutCallbackState' => array( + 'LoginCompletedHandler' => [get_class(), 'loginCompleted'], + 'LogoutCallback' => [get_class(), 'logoutCallback'], + 'LogoutCallbackState' => [ '\SimpleSAML\Auth\DefaultAuth.logoutSource' => $this->authId, // TODO: remove in 2.0 '\SimpleSAML\Auth\Source.logoutSource' => $this->authId, - ), - )); + ], + ]); if (is_string($return)) { $state['\SimpleSAML\Auth\DefaultAuth.ReturnURL'] = $return; // TODO: remove in 2.0 @@ -297,7 +297,7 @@ abstract class Source self::validateSource($config, $authId); $id = $config[0]; - $info = array('AuthId' => $authId); + $info = ['AuthId' => $authId]; $authSource = null; unset($config[0]); @@ -426,15 +426,15 @@ abstract class Source if (array_key_exists('LogoutCallbackState', $state)) { $callbackState = $state['LogoutCallbackState']; } else { - $callbackState = array(); + $callbackState = []; } $id = strlen($this->authId).':'.$this->authId.$assoc; - $data = array( + $data = [ 'callback' => $callback, 'state' => $callbackState, - ); + ]; $session = \SimpleSAML\Session::getSessionFromRequest(); $session->setData( diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 44454b41f..8ee2986db 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -103,7 +103,7 @@ class State public static function getPersistentAuthData(array $state) { // save persistent authentication data - $persistent = array(); + $persistent = []; if (array_key_exists('PersistentAuthData', $state)) { foreach ($state['PersistentAuthData'] as $key) { @@ -114,14 +114,14 @@ class State } // add those that should always be included - $mandatory = array( + $mandatory = [ 'Attributes', 'Expire', 'LogoutState', 'AuthInstant', 'RememberMe', 'saml:sp:NameID' - ); + ]; foreach ($mandatory as $key) { if (isset($state[$key])) { $persistent[$key] = $state[$key]; @@ -352,7 +352,7 @@ class State // Redirect to the exception handler \SimpleSAML\Utils\HTTP::redirectTrustedURL( $state[self::EXCEPTION_HANDLER_URL], - array(self::EXCEPTION_PARAM => $id) + [self::EXCEPTION_PARAM => $id] ); } elseif (array_key_exists(self::EXCEPTION_HANDLER_FUNC, $state)) { // Call the exception handler @@ -415,6 +415,6 @@ class State if (count($tmp) === 2) { $url = $tmp[1]; } - return array('id' => $id, 'url' => $url); + return ['id' => $id, 'url' => $url]; } } diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index 83df98925..3ce30d977 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -33,7 +33,7 @@ class Artifact // We need to process the query string manually, to capture all SAMLart parameters - $artifacts = array(); + $artifacts = []; $elements = explode('&', $_SERVER['QUERY_STRING']); foreach ($elements as $element) { @@ -142,7 +142,7 @@ class Artifact $url = $idpMetadata->getDefaultEndpoint( 'ArtifactResolutionService', - array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding') + ['urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding'] ); $url = $url['Location']; @@ -164,21 +164,21 @@ class Artifact $spKeyCertFile = Config::getCertPath($spMetadata->getString('privatekey')); - $opts = array( - 'ssl' => array( + $opts = [ + 'ssl' => [ 'verify_peer' => true, 'cafile' => $file, 'local_cert' => $spKeyCertFile, 'capture_peer_cert' => true, 'capture_peer_chain' => true, - ), - 'http' => array( + ], + 'http' => [ 'method' => 'POST', 'content' => $request, 'header' => 'SOAPAction: http://www.oasis-open.org/committees/security'."\r\n". 'Content-Type: text/xml', - ), - ); + ], + ]; // Fetch the artifact $response = HTTP::fetch($url, $opts); diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php index 97d004c71..893682c1b 100644 --- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php +++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php @@ -88,11 +88,11 @@ class HTTPPost $signResponse = true; } - $signer = new Signer(array( + $signer = new Signer([ 'privatekey_array' => $privatekey, 'publickey_array' => $publickey, 'id' => ($signResponse ? 'ResponseID' : 'AssertionID'), - )); + ]); if ($idpmd->hasValue('certificatechain')) { $signer->addCertificate($idpmd->getString('certificatechain')); @@ -113,10 +113,10 @@ class HTTPPost XML::debugSAMLMessage($response, 'out'); - HTTP::submitPOSTData($shire, array( + HTTP::submitPOSTData($shire, [ 'TARGET' => $relayState, 'SAMLResponse' => base64_encode($response), - )); + ]); } diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 48dc325c5..26c05307f 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -25,7 +25,7 @@ class Configuration implements Utils\ClearableState * * @var array */ - private static $instance = array(); + private static $instance = []; /** @@ -36,7 +36,7 @@ class Configuration implements Utils\ClearableState * * @var array */ - private static $configDirs = array(); + private static $configDirs = []; /** @@ -46,7 +46,7 @@ class Configuration implements Utils\ClearableState * * @var array */ - private static $loadedConfigs = array(); + private static $loadedConfigs = []; /** @@ -125,8 +125,8 @@ class Configuration implements Utils\ClearableState try { require($filename); } catch (\ParseError $e) { - self::$loadedConfigs[$filename] = self::loadFromArray(array(), '[ARRAY]', 'simplesaml'); - throw new Error\ConfigurationError($e->getMessage(), $filename, array()); + self::$loadedConfigs[$filename] = self::loadFromArray([], '[ARRAY]', 'simplesaml'); + throw new Error\ConfigurationError($e->getMessage(), $filename, []); } } else { require($filename); @@ -163,7 +163,7 @@ class Configuration implements Utils\ClearableState throw new Error\ConfigurationError('Missing configuration file', $filename); } else { // file does not exist, but is optional, so return an empty configuration object without saving it - $cfg = new Configuration(array(), $filename); + $cfg = new Configuration([], $filename); $cfg->filename = $filename; return $cfg; } @@ -842,7 +842,7 @@ class Configuration implements Utils\ClearableState } if (!in_array($ret, $allowedValues, true)) { - $strValues = array(); + $strValues = []; foreach ($allowedValues as $av) { $strValues[] = var_export($av, true); } @@ -918,7 +918,7 @@ class Configuration implements Utils\ClearableState } if (!is_array($ret)) { - $ret = array($ret); + $ret = [$ret]; } return $ret; @@ -1040,7 +1040,7 @@ class Configuration implements Utils\ClearableState ); } - $out = array(); + $out = []; foreach ($ret as $index => $config) { $newLoc = $this->location.'['.var_export($name, true).']['. var_export($index, true).']'; @@ -1132,14 +1132,14 @@ class Configuration implements Utils\ClearableState if (!array_key_exists($endpointType, $this->configuration)) { // no endpoints of the given type - return array(); + return []; } $eps = $this->configuration[$endpointType]; if (is_string($eps)) { // for backwards-compatibility - $eps = array($eps); + $eps = [$eps]; } elseif (!is_array($eps)) { throw new \Exception($loc.': Expected array or string.'); } @@ -1150,10 +1150,10 @@ class Configuration implements Utils\ClearableState if (is_string($ep)) { // for backwards-compatibility - $ep = array( + $ep = [ 'Location' => $ep, 'Binding' => $this->getDefaultBinding($endpointType), - ); + ]; $responseLocation = $this->getString($endpointType.'Response', null); if ($responseLocation !== null) { $ep['ResponseLocation'] = $responseLocation; @@ -1286,7 +1286,7 @@ class Configuration implements Utils\ClearableState $loc = $this->location.'['.var_export($name, true).']'; if (is_string($ret)) { - $ret = array('en' => $ret,); + $ret = ['en' => $ret,]; } if (!is_array($ret)) { @@ -1327,7 +1327,7 @@ class Configuration implements Utils\ClearableState assert(is_string($prefix)); if ($this->hasValue($prefix.'keys')) { - $ret = array(); + $ret = []; foreach ($this->getArray($prefix.'keys') as $key) { if ($use !== null && isset($key[$use]) && !$key[$use]) { continue; @@ -1342,14 +1342,14 @@ class Configuration implements Utils\ClearableState } elseif ($this->hasValue($prefix.'certData')) { $certData = $this->getString($prefix.'certData'); $certData = preg_replace('/\s+/', '', $certData); - return array( - array( + return [ + [ 'encryption' => true, 'signing' => true, 'type' => 'X509Certificate', 'X509Certificate' => $certData, - ), - ); + ], + ]; } elseif ($this->hasValue($prefix.'certificate')) { $file = $this->getString($prefix.'certificate'); $file = Utils\Config::getCertPath($file); @@ -1368,18 +1368,18 @@ class Configuration implements Utils\ClearableState } $certData = preg_replace('/\s+/', '', $matches[1]); - return array( - array( + return [ + [ 'encryption' => true, 'signing' => true, 'type' => 'X509Certificate', 'X509Certificate' => $certData, - ), - ); + ], + ]; } elseif ($required === true) { throw new \SimpleSAML\Error\Exception($this->location.': Missing certificate in metadata.'); } else { - return array(); + return []; } } @@ -1390,8 +1390,8 @@ class Configuration implements Utils\ClearableState */ public static function clearInternalState() { - self::$configDirs = array(); - self::$instance = array(); - self::$loadedConfigs = array(); + self::$configDirs = []; + self::$instance = []; + self::$loadedConfigs = []; } } diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php index aee9e2725..94c9b788f 100644 --- a/lib/SimpleSAML/Database.php +++ b/lib/SimpleSAML/Database.php @@ -22,7 +22,7 @@ class Database /** * This variable holds the instance of the session - Singleton approach. */ - private static $instance = array(); + private static $instance = []; /** * PDO Object for the Master database server @@ -32,7 +32,7 @@ class Database /** * Array of PDO Objects for configured database slaves */ - private $dbSlaves = array(); + private $dbSlaves = []; /** * Prefix to apply to the tables @@ -75,9 +75,9 @@ class Database */ private function __construct($config) { - $driverOptions = $config->getArray('database.driver_options', array()); + $driverOptions = $config->getArray('database.driver_options', []); if ($config->getBoolean('database.persistent', true)) { - $driverOptions = array(\PDO::ATTR_PERSISTENT => true); + $driverOptions = [\PDO::ATTR_PERSISTENT => true]; } // connect to the master @@ -89,7 +89,7 @@ class Database ); // connect to any configured slaves - $slaves = $config->getArray('database.slaves', array()); + $slaves = $config->getArray('database.slaves', []); foreach ($slaves as $slave) { array_push( $this->dbSlaves, @@ -115,16 +115,16 @@ class Database */ private static function generateInstanceId($config) { - $assembledConfig = array( - 'master' => array( + $assembledConfig = [ + 'master' => [ 'database.dsn' => $config->getString('database.dsn'), 'database.username' => $config->getString('database.username', null), 'database.password' => $config->getString('database.password', null), 'database.prefix' => $config->getString('database.prefix', ''), 'database.persistent' => $config->getBoolean('database.persistent', false), - ), - 'slaves' => $config->getArray('database.slaves', array()), - ); + ], + 'slaves' => $config->getArray('database.slaves', []), + ]; return sha1(serialize($assembledConfig)); } @@ -252,7 +252,7 @@ class Database * * @return int The number of rows affected by the query. */ - public function write($stmt, $params = array()) + public function write($stmt, $params = []) { $db = $this->dbMaster; @@ -273,7 +273,7 @@ class Database * * @return \PDOStatement|bool object */ - public function read($stmt, $params = array()) + public function read($stmt, $params = []) { $db = $this->getSlave(); diff --git a/lib/SimpleSAML/Error/Assertion.php b/lib/SimpleSAML/Error/Assertion.php index 7a5cb2dfa..c16f61164 100644 --- a/lib/SimpleSAML/Error/Assertion.php +++ b/lib/SimpleSAML/Error/Assertion.php @@ -59,7 +59,7 @@ class Assertion extends Exception assert_options(ASSERT_WARNING, 0); assert_options(ASSERT_QUIET_EVAL, 0); - assert_options(ASSERT_CALLBACK, array('\SimpleSAML\Error\Assertion', 'onAssertion')); + assert_options(ASSERT_CALLBACK, ['\SimpleSAML\Error\Assertion', 'onAssertion']); } diff --git a/lib/SimpleSAML/Error/AuthSource.php b/lib/SimpleSAML/Error/AuthSource.php index 6db188121..e075aa7bc 100644 --- a/lib/SimpleSAML/Error/AuthSource.php +++ b/lib/SimpleSAML/Error/AuthSource.php @@ -37,11 +37,11 @@ class AuthSource extends Error $this->authsource = $authsource; $this->reason = $reason; parent::__construct( - array( + [ 'AUTHSOURCEERROR', '%AUTHSOURCE%' => htmlspecialchars(var_export($this->authsource, true)), '%REASON%' => htmlspecialchars(var_export($this->reason, true)) - ), + ], $cause ); diff --git a/lib/SimpleSAML/Error/BadRequest.php b/lib/SimpleSAML/Error/BadRequest.php index 41bf65c1f..1deb08c0b 100644 --- a/lib/SimpleSAML/Error/BadRequest.php +++ b/lib/SimpleSAML/Error/BadRequest.php @@ -30,7 +30,7 @@ class BadRequest extends Error assert(is_string($reason)); $this->reason = $reason; - parent::__construct(array('BADREQUEST', '%REASON%' => $this->reason)); + parent::__construct(['BADREQUEST', '%REASON%' => $this->reason]); $this->httpCode = 400; } diff --git a/lib/SimpleSAML/Error/ConfigurationError.php b/lib/SimpleSAML/Error/ConfigurationError.php index 47dd0ccc9..128093dad 100644 --- a/lib/SimpleSAML/Error/ConfigurationError.php +++ b/lib/SimpleSAML/Error/ConfigurationError.php @@ -37,7 +37,7 @@ class ConfigurationError extends Error { $file_str = ''; $reason_str = '.'; - $params = array('CONFIG'); + $params = ['CONFIG']; if ($file !== null) { $params['%FILE%'] = $file; $basepath = dirname(dirname(dirname(dirname(__FILE__)))).'/'; diff --git a/lib/SimpleSAML/Error/CriticalConfigurationError.php b/lib/SimpleSAML/Error/CriticalConfigurationError.php index 1e67a1e80..d41367fbf 100644 --- a/lib/SimpleSAML/Error/CriticalConfigurationError.php +++ b/lib/SimpleSAML/Error/CriticalConfigurationError.php @@ -28,12 +28,12 @@ class CriticalConfigurationError extends ConfigurationError * * @var array */ - private static $minimum_config = array( + private static $minimum_config = [ 'logging.handler' => 'errorlog', 'logging.level' => \SimpleSAML\Logger::DEBUG, 'errorreporting' => false, 'debug' => true, - ); + ]; /** diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index f5842f91b..0d8d011a0 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -79,7 +79,7 @@ class Error extends Exception unset($this->parameters[0]); $this->errorCode = $errorCode[0]; } else { - $this->parameters = array(); + $this->parameters = []; $this->errorCode = $errorCode; } @@ -196,7 +196,7 @@ class Error extends Exception } else { $referer = 'unknown'; } - $errorData = array( + $errorData = [ 'exceptionMsg' => $emsg, 'exceptionTrace' => $etrace, 'reportId' => $reportId, @@ -204,7 +204,7 @@ class Error extends Exception 'url' => \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), 'version' => $config->getVersion(), 'referer' => $referer, - ); + ]; $session->setData('core:errorreport', $reportId, $errorData); return $errorData; @@ -226,7 +226,7 @@ class Error extends Exception $errorData = $this->saveError(); $config = \SimpleSAML\Configuration::getInstance(); - $data = array(); + $data = []; $data['showerrors'] = $config->getBoolean('showerrors', true); $data['error'] = $errorData; $data['errorCode'] = $this->errorCode; diff --git a/lib/SimpleSAML/Error/ErrorCodes.php b/lib/SimpleSAML/Error/ErrorCodes.php index e35865894..d15f8c46f 100644 --- a/lib/SimpleSAML/Error/ErrorCodes.php +++ b/lib/SimpleSAML/Error/ErrorCodes.php @@ -18,7 +18,7 @@ class ErrorCodes */ final public static function defaultGetAllErrorCodeTitles() { - return array( + return [ 'ACSPARAMS' => \SimpleSAML\Locale\Translate::noop('{errors:title_ACSPARAMS}'), 'ARSPARAMS' => \SimpleSAML\Locale\Translate::noop('{errors:title_ARSPARAMS}'), 'AUTHSOURCEERROR' => \SimpleSAML\Locale\Translate::noop('{errors:title_AUTHSOURCEERROR}'), @@ -52,7 +52,7 @@ class ErrorCodes 'UNKNOWNCERT' => \SimpleSAML\Locale\Translate::noop('{errors:title_UNKNOWNCERT}'), 'USERABORTED' => \SimpleSAML\Locale\Translate::noop('{errors:title_USERABORTED}'), 'WRONGUSERPASS' => \SimpleSAML\Locale\Translate::noop('{errors:title_WRONGUSERPASS}'), - ); + ]; } @@ -76,7 +76,7 @@ class ErrorCodes */ final public static function defaultGetAllErrorCodeDescriptions() { - return array( + return [ 'ACSPARAMS' => \SimpleSAML\Locale\Translate::noop('{errors:descr_ACSPARAMS}'), 'ARSPARAMS' => \SimpleSAML\Locale\Translate::noop('{errors:descr_ARSPARAMS}'), 'AUTHSOURCEERROR' => \SimpleSAML\Locale\Translate::noop('{errors:descr_AUTHSOURCEERROR}'), @@ -110,7 +110,7 @@ class ErrorCodes 'UNKNOWNCERT' => \SimpleSAML\Locale\Translate::noop('{errors:descr_UNKNOWNCERT}'), 'USERABORTED' => \SimpleSAML\Locale\Translate::noop('{errors:descr_USERABORTED}'), 'WRONGUSERPASS' => \SimpleSAML\Locale\Translate::noop('{errors:descr_WRONGUSERPASS}'), - ); + ]; } /** @@ -135,10 +135,10 @@ class ErrorCodes */ public static function getAllErrorCodeMessages() { - return array( + return [ 'title' => self::getAllErrorCodeTitles(), 'descr' => self::getAllErrorCodeDescriptions(), - ); + ]; } @@ -181,9 +181,9 @@ class ErrorCodes */ public static function getErrorCodeMessage($errorCode) { - return array( + return [ 'title' => self::getErrorCodeTitle($errorCode), 'descr' => self::getErrorCodeDescription($errorCode), - ); + ]; } } diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index 8a3b199aa..5ab59f482 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -80,7 +80,7 @@ class Exception extends \Exception */ protected function initBacktrace(\Exception $exception) { - $this->backtrace = array(); + $this->backtrace = []; // position in the top function on the stack $pos = $exception->getFile().':'.$exception->getLine(); @@ -148,9 +148,9 @@ class Exception extends \Exception */ public function format($anonymize = false) { - $ret = array( + $ret = [ $this->getClass().': '.$this->getMessage(), - ); + ]; return array_merge($ret, $this->formatBacktrace($anonymize)); } @@ -166,7 +166,7 @@ class Exception extends \Exception */ public function formatBacktrace($anonymize = false) { - $ret = array(); + $ret = []; $basedir = \SimpleSAML\Configuration::getInstance()->getBaseDir(); $e = $this; @@ -197,7 +197,7 @@ class Exception extends \Exception protected function logBacktrace($level = \SimpleSAML\Logger::DEBUG) { // see if debugging is enabled for backtraces - $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', array('backtraces' => false)); + $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', ['backtraces' => false]); if (!(in_array('backtraces', $debug, true) // implicitly enabled || (array_key_exists('backtraces', $debug) && $debug['backtraces'] === true) @@ -210,13 +210,13 @@ class Exception extends \Exception $backtrace = $this->formatBacktrace(); - $callback = array('\SimpleSAML\Logger'); - $functions = array( + $callback = ['\SimpleSAML\Logger']; + $functions = [ \SimpleSAML\Logger::ERR => 'error', \SimpleSAML\Logger::WARNING => 'warning', \SimpleSAML\Logger::INFO => 'info', \SimpleSAML\Logger::DEBUG => 'debug', - ); + ]; $callback[] = $functions[$level]; foreach ($backtrace as $line) { @@ -234,13 +234,13 @@ class Exception extends \Exception */ public function log($default_level) { - $fn = array( + $fn = [ \SimpleSAML\Logger::ERR => 'logError', \SimpleSAML\Logger::WARNING => 'logWarning', \SimpleSAML\Logger::INFO => 'logInfo', \SimpleSAML\Logger::DEBUG => 'logDebug', - ); - call_user_func(array($this, $fn[$default_level]), $default_level); + ]; + call_user_func([$this, $fn[$default_level]], $default_level); } diff --git a/lib/SimpleSAML/Error/MetadataNotFound.php b/lib/SimpleSAML/Error/MetadataNotFound.php index 93e086c14..47636bc21 100644 --- a/lib/SimpleSAML/Error/MetadataNotFound.php +++ b/lib/SimpleSAML/Error/MetadataNotFound.php @@ -20,9 +20,9 @@ class MetadataNotFound extends Error assert(is_string($entityId)); $this->includeTemplate = 'core:no_metadata.tpl.php'; - parent::__construct(array( + parent::__construct([ 'METADATANOTFOUND', '%ENTITYID%' => htmlspecialchars(var_export($entityId, true)) - )); + ]); } } diff --git a/lib/SimpleSAML/Error/NotFound.php b/lib/SimpleSAML/Error/NotFound.php index 79f604922..0e6185269 100644 --- a/lib/SimpleSAML/Error/NotFound.php +++ b/lib/SimpleSAML/Error/NotFound.php @@ -32,10 +32,10 @@ class NotFound extends Error $url = \SimpleSAML\Utils\HTTP::getSelfURL(); if ($reason === null) { - parent::__construct(array('NOTFOUND', '%URL%' => $url)); + parent::__construct(['NOTFOUND', '%URL%' => $url]); $this->message = "The requested page '$url' could not be found."; } else { - parent::__construct(array('NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason)); + parent::__construct(['NOTFOUNDREASON', '%URL%' => $url, '%REASON%' => $reason]); $this->message = "The requested page '$url' could not be found. ".$reason; } @@ -65,8 +65,8 @@ class NotFound extends Error */ public function format($anonymize = false) { - return array( + return [ $this->getClass().': '.$this->getMessage(), - ); + ]; } } diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php index 8e0d95113..70db63b4c 100644 --- a/lib/SimpleSAML/IdP.php +++ b/lib/SimpleSAML/IdP.php @@ -19,7 +19,7 @@ class IdP * * @var array */ - private static $idpCache = array(); + private static $idpCache = []; /** * The identifier for this IdP. @@ -204,7 +204,7 @@ class IdP } elseif ($spMetadata->hasValue('OrganizationDisplayName')) { return $spMetadata->getLocalizedString('OrganizationDisplayName'); } else { - return array('en' => $spEntityId); + return ['en' => $spEntityId]; } } @@ -307,7 +307,7 @@ class IdP if (isset($state['SPMetadata'])) { $spMetadata = $state['SPMetadata']; } else { - $spMetadata = array(); + $spMetadata = []; } if (isset($state['core:SP'])) { @@ -322,7 +322,7 @@ class IdP $pc = new Auth\ProcessingChain($idpMetadata, $spMetadata, 'idp'); - $state['ReturnCall'] = array('\SimpleSAML\IdP', 'postAuthProc'); + $state['ReturnCall'] = ['\SimpleSAML\IdP', 'postAuthProc']; $state['Destination'] = $spMetadata; $state['Source'] = $idpMetadata; @@ -403,7 +403,7 @@ class IdP } $state['IdPMetadata'] = $this->getConfig()->toArray(); - $state['ReturnCallback'] = array('\SimpleSAML\IdP', 'postAuth'); + $state['ReturnCallback'] = ['\SimpleSAML\IdP', 'postAuth']; try { if ($needAuth) { @@ -490,7 +490,7 @@ class IdP // terminate the local session $id = Auth\State::saveState($state, 'core:Logout:afterbridge'); - $returnTo = Module::getModuleURL('core/idp/resumelogout.php', array('id' => $id)); + $returnTo = Module::getModuleURL('core/idp/resumelogout.php', ['id' => $id]); $this->authSource->logout($returnTo); @@ -535,10 +535,10 @@ class IdP { assert(is_string($url)); - $state = array( - 'Responder' => array('\SimpleSAML\IdP', 'finishLogoutRedirect'), + $state = [ + 'Responder' => ['\SimpleSAML\IdP', 'finishLogoutRedirect'], 'core:Logout:URL' => $url, - ); + ]; $this->handleLogoutRequest($state, null); assert(false); diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index 08c47aedb..b2d808cc2 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -56,7 +56,7 @@ class IFrameLogoutHandler implements LogoutHandlerInterface if (!is_null($assocId)) { $spName = $this->idp->getSPName($assocId); if ($spName === null) { - $spName = array('en' => $assocId); + $spName = ['en' => $assocId]; } $state['core:Logout-IFrame:From'] = $spName; @@ -64,9 +64,9 @@ class IFrameLogoutHandler implements LogoutHandlerInterface $state['core:Logout-IFrame:From'] = null; } - $params = array( + $params = [ 'id' => \SimpleSAML\Auth\State::saveState($state, 'core:Logout-IFrame'), - ); + ]; if (isset($state['core:Logout-IFrame:InitType'])) { $params['type'] = $state['core:Logout-IFrame:InitType']; } diff --git a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php index 37218ea88..32652b561 100644 --- a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php +++ b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php @@ -53,7 +53,7 @@ class TraditionalLogoutHandler implements LogoutHandlerInterface try { $idp = \SimpleSAML\IdP::getByState($association); - $url = call_user_func(array($association['Handler'], 'getLogoutURL'), $idp, $association, $relayState); + $url = call_user_func([$association['Handler'], 'getLogoutURL'], $idp, $association, $relayState); HTTP::redirectTrustedURL($url); } catch (\Exception $e) { Logger::warning('Unable to initialize logout to '.var_export($id, true).'.'); diff --git a/lib/SimpleSAML/Locale/Language.php b/lib/SimpleSAML/Locale/Language.php index 56bf91b40..21dc94b7c 100644 --- a/lib/SimpleSAML/Locale/Language.php +++ b/lib/SimpleSAML/Locale/Language.php @@ -18,7 +18,7 @@ class Language /** * This is the default language map. It is used to map languages codes from the user agent to other language codes. */ - private static $defaultLanguageMap = array('nb' => 'no'); + private static $defaultLanguageMap = ['nb' => 'no']; /** * The configuration to use. @@ -77,7 +77,7 @@ class Language * * @var array */ - private $language_names = array( + private $language_names = [ 'no' => 'BokmĂĄl', // Norwegian BokmĂĄl 'nn' => 'Nynorsk', // Norwegian Nynorsk 'se' => 'Sámegiella', // Northern Sami @@ -118,17 +118,17 @@ class Language 'ro' => 'RomâneČ™te', // Romanian 'eu' => 'Euskara', // Basque 'af' => 'Afrikaans', // Afrikaans - ); + ]; /** * A mapping of SSP languages to locales * * @var array */ - private $languagePosixMapping = array( + private $languagePosixMapping = [ 'no' => 'nb_NO', 'nn' => 'nn_NO', - ); + ]; /** @@ -143,7 +143,7 @@ class Language $this->defaultLanguage = $this->configuration->getString('language.default', 'en'); $this->languageParameterName = $this->configuration->getString('language.parameter.name', 'language'); $this->customFunction = $this->configuration->getArray('language.get_language_function', null); - $this->rtlLanguages = $this->configuration->getArray('language.rtl', array()); + $this->rtlLanguages = $this->configuration->getArray('language.rtl', []); if (isset($_GET[$this->languageParameterName])) { $this->setLanguage( $_GET[$this->languageParameterName], @@ -160,8 +160,8 @@ class Language */ private function getInstalledLanguages() { - $configuredAvailableLanguages = $this->configuration->getArray('language.available', array('en')); - $availableLanguages = array(); + $configuredAvailableLanguages = $this->configuration->getArray('language.available', ['en']); + $availableLanguages = []; foreach ($configuredAvailableLanguages as $code) { if (array_key_exists($code, $this->language_names) && isset($this->language_names[$code])) { $availableLanguages[] = $code; @@ -378,7 +378,7 @@ class Language public static function getLanguageCookie() { $config = \SimpleSAML\Configuration::getInstance(); - $availableLanguages = $config->getArray('language.available', array('en')); + $availableLanguages = $config->getArray('language.available', ['en']); $name = $config->getString('language.cookie.name', 'language'); if (isset($_COOKIE[$name])) { @@ -404,20 +404,20 @@ class Language $language = strtolower($language); $config = \SimpleSAML\Configuration::getInstance(); - $availableLanguages = $config->getArray('language.available', array('en')); + $availableLanguages = $config->getArray('language.available', ['en']); if (!in_array($language, $availableLanguages, true) || headers_sent()) { return; } $name = $config->getString('language.cookie.name', 'language'); - $params = array( + $params = [ 'lifetime' => ($config->getInteger('language.cookie.lifetime', 60 * 60 * 24 * 900)), 'domain' => ($config->getString('language.cookie.domain', null)), 'path' => ($config->getString('language.cookie.path', '/')), 'secure' => ($config->getBoolean('language.cookie.secure', false)), 'httponly' => ($config->getBoolean('language.cookie.httponly', false)), - ); + ]; HTTP::setCookie($name, $language, $params, false); } diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index bbf64ae6a..9a4543d37 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -54,7 +54,7 @@ class Localization * * @var array */ - private $localeDomainMap = array(); + private $localeDomainMap = []; /** * Pointer to currently active translator diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index 7bffffedf..c9e7a223d 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -24,14 +24,14 @@ class Translate * * @var array */ - private $langtext = array(); + private $langtext = []; /** * Associative array of dictionaries. * * @var array */ - private $dictionaries = array(); + private $dictionaries = []; /** * The default dictionary. @@ -201,7 +201,7 @@ class Translate { // normalize attribute name $normName = strtolower($name); - $normName = str_replace(array(":", "-"), "_", $normName); + $normName = str_replace([":", "-"], "_", $normName); // check for an extra dictionary $extraDict = $this->configuration->getString('attributes.extradictionary', null); @@ -258,11 +258,11 @@ class Translate */ public function t( $tag, - $replacements = array(), + $replacements = [], // TODO: remove this for 2.0. Assume true $fallbackdefault = true, // TODO: remove this for 2.0 - $oldreplacements = array(), + $oldreplacements = [], // TODO: remove this for 2.0 $striptags = false ) { @@ -353,7 +353,7 @@ class Translate public function includeInlineTranslation($tag, $translation) { if (is_string($translation)) { - $translation = array('en' => $translation); + $translation = ['en' => $translation]; } elseif (!is_array($translation)) { throw new \Exception("Inline translation should be string or array. Is ".gettype($translation)." now!"); } @@ -401,7 +401,7 @@ class Translate if (empty($lang)) { \SimpleSAML\Logger::error('Invalid dictionary definition file ['.$definitionFile.']'); - return array(); + return []; } $translationFile = $filename.'.translation.json'; @@ -434,7 +434,7 @@ class Translate return $lang; } - return array(); + return []; } /** @@ -463,7 +463,7 @@ class Translate \SimpleSAML\Logger::error( $_SERVER['PHP_SELF'].' - Template: Could not find dictionary file at ['.$filename.']' ); - return array(); + return []; } /** @@ -538,7 +538,7 @@ class Translate $langcfg = $sspcfg->getConfigItem('language', null); $priorities = []; if ($langcfg instanceof \SimpleSAML\Configuration) { - $priorities = $langcfg->getArray('priorities', array()); + $priorities = $langcfg->getArray('priorities', []); } if ( !empty($priorities[$context['currentLanguage']]) ) { diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 3c569a1fa..c18276ec0 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -30,14 +30,14 @@ class Logger /** * @var array */ - private static $capturedLog = array(); + private static $capturedLog = []; /** * Array with messages logged before the logging handler was initialized. * * @var array */ - private static $earlyLog = array(); + private static $earlyLog = []; /** * List of log levels. @@ -46,7 +46,7 @@ class Logger * * @var array */ - private static $logLevelStack = array(); + private static $logLevelStack = []; /** * The current mask of log levels disabled. @@ -305,7 +305,7 @@ class Logger assert(is_int($mask)); $currentEnabled = error_reporting(); - self::$logLevelStack[] = array($currentEnabled, self::$logMask); + self::$logLevelStack[] = [$currentEnabled, self::$logMask]; $currentEnabled &= ~$mask; error_reporting($currentEnabled); @@ -336,11 +336,11 @@ class Logger private static function defer($level, $message, $stats) { // save the message for later - self::$earlyLog[] = array('level' => $level, 'string' => $message, 'statsLog' => $stats); + self::$earlyLog[] = ['level' => $level, 'string' => $message, 'statsLog' => $stats]; // register a shutdown handler if needed if (!self::$shutdownRegistered) { - register_shutdown_function(array('SimpleSAML\Logger', 'flush')); + register_shutdown_function(['SimpleSAML\Logger', 'flush']); self::$shutdownRegistered = true; } } @@ -352,11 +352,11 @@ class Logger self::$loggingHandler = false; // a set of known logging handlers - $known_handlers = array( + $known_handlers = [ 'syslog' => 'SimpleSAML\Logger\SyslogLoggingHandler', 'file' => 'SimpleSAML\Logger\FileLoggingHandler', 'errorlog' => 'SimpleSAML\Logger\ErrorLogLoggingHandler', - ); + ]; // get the configuration $config = Configuration::getInstance(); @@ -429,8 +429,8 @@ class Logger $string = implode(",", $string); } - $formats = array('%trackid', '%msg', '%srcip', '%stat'); - $replacements = array(self::$trackid, $string, $_SERVER['REMOTE_ADDR']); + $formats = ['%trackid', '%msg', '%srcip', '%stat']; + $replacements = [self::$trackid, $string, $_SERVER['REMOTE_ADDR']]; $stat = ''; if ($statsLog) { diff --git a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php index 9af1f63bc..355fe24d1 100644 --- a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php @@ -17,7 +17,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface /** * This array contains the mappings from syslog log level to names. */ - private static $levelNames = array( + private static $levelNames = [ Logger::EMERG => 'EMERG', Logger::ALERT => 'ALERT', Logger::CRIT => 'CRIT', @@ -26,7 +26,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface Logger::NOTICE => 'NOTICE', Logger::INFO => 'INFO', Logger::DEBUG => 'DEBUG', - ); + ]; /** * The name of this process. @@ -72,8 +72,8 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface $levelName = sprintf('UNKNOWN%d', $level); } - $formats = array('%process', '%level'); - $replacements = array($this->processname, $levelName); + $formats = ['%process', '%level']; + $replacements = [$this->processname, $levelName]; $string = str_replace($formats, $replacements, $string); $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string); $string = trim($string); diff --git a/lib/SimpleSAML/Logger/FileLoggingHandler.php b/lib/SimpleSAML/Logger/FileLoggingHandler.php index beb9e27bb..8e9202f55 100644 --- a/lib/SimpleSAML/Logger/FileLoggingHandler.php +++ b/lib/SimpleSAML/Logger/FileLoggingHandler.php @@ -25,7 +25,7 @@ class FileLoggingHandler implements LoggingHandlerInterface * This array contains the mappings from syslog log levels to names. Copied more or less directly from * SimpleSAML\Logger\ErrorLogLoggingHandler. */ - private static $levelNames = array( + private static $levelNames = [ Logger::EMERG => 'EMERGENCY', Logger::ALERT => 'ALERT', Logger::CRIT => 'CRITICAL', @@ -34,7 +34,7 @@ class FileLoggingHandler implements LoggingHandlerInterface Logger::NOTICE => 'NOTICE', Logger::INFO => 'INFO', Logger::DEBUG => 'DEBUG', - ); + ]; protected $processname = null; protected $format; @@ -92,10 +92,10 @@ class FileLoggingHandler implements LoggingHandlerInterface $levelName = self::$levelNames[$level]; } - $formats = array('%process', '%level'); - $replacements = array($this->processname, $levelName); + $formats = ['%process', '%level']; + $replacements = [$this->processname, $levelName]; - $matches = array(); + $matches = []; if (preg_match('/%date(?:\{([^\}]+)\})?/', $this->format, $matches)) { $format = "%b %d %H:%M:%S"; if (isset($matches[1])) { diff --git a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php index 0330c3d13..8d6e21a39 100644 --- a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php @@ -64,8 +64,8 @@ class SyslogLoggingHandler implements LoggingHandlerInterface } } - $formats = array('%process', '%level'); - $replacements = array('', $level); + $formats = ['%process', '%level']; + $replacements = ['', $level]; $string = str_replace($formats, $replacements, $string); $string = preg_replace('/%\w+(\{[^\}]+\})?/', '', $string); $string = trim($string); diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index c348a966b..227022c20 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -150,10 +150,10 @@ class Memcache public static function set($key, $value, $expire = null) { Logger::debug("saving key $key to memcache"); - $savedInfo = array( + $savedInfo = [ 'timestamp' => microtime(true), 'data' => $value - ); + ]; if ($expire === null) { $expire = self::getExpireTime(); @@ -358,7 +358,7 @@ class Memcache } // initialize the servers-array - self::$serverGroups = array(); + self::$serverGroups = []; // load the configuration $config = Configuration::getInstance(); @@ -448,7 +448,7 @@ class Memcache */ public static function getStats() { - $ret = array(); + $ret = []; foreach (self::getMemcacheServers() as $sg) { $stats = method_exists($sg, 'getExtendedStats') ? $sg->getExtendedStats() : $sg->getStats(); @@ -475,7 +475,7 @@ class Memcache */ public static function getRawStats() { - $ret = array(); + $ret = []; foreach (self::getMemcacheServers() as $sg) { $stats = method_exists($sg, 'getExtendedStats') ? $sg->getExtendedStats() : $sg->getStats(); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 426d3cc63..e171ab90b 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -60,7 +60,7 @@ class MetaDataStorageHandler // for backwards compatibility, and to provide a default configuration if ($sourcesConfig === null) { $type = $config->getString('metadata.handler', 'flatfile'); - $sourcesConfig = array(array('type' => $type)); + $sourcesConfig = [['type' => $type]]; } try { @@ -140,7 +140,7 @@ class MetaDataStorageHandler { assert(is_string($set)); - $result = array(); + $result = []; foreach ($this->sources as $source) { $srcList = $source->getMetadataSet($set); @@ -335,7 +335,7 @@ class MetaDataStorageHandler assert(is_string($sha1)); assert(is_string($set)); - $result = array(); + $result = []; foreach ($this->sources as $source) { $srcList = $source->getMetadataSet($set); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php index 6901c15a3..2d7883b8c 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php @@ -27,7 +27,7 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource * * @var array */ - private $cachedMetadata = array(); + private $cachedMetadata = []; /** @@ -78,7 +78,7 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource return null; } - $metadata = array(); + $metadata = []; include($metadatasetfile); @@ -107,7 +107,7 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource $metadataSet = $this->load($set); if ($metadataSet === null) { - $metadataSet = array(); + $metadataSet = []; } // add the entity id of an entry to each entry in the metadata diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php index e5d182764..0645a0bec 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php @@ -27,12 +27,12 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource /** * This is an associative array which stores the different metadata sets we have loaded. */ - private $cachedMetadata = array(); + private $cachedMetadata = []; /** * All the metadata sets supported by this MetaDataStorageHandler */ - public $supportedSets = array( + public $supportedSets = [ 'adfs-idp-hosted', 'adfs-sp-remote', 'saml20-idp-hosted', @@ -44,7 +44,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource 'shib13-sp-remote', 'wsfed-idp-remote', 'wsfed-sp-hosted' - ); + ]; /** @@ -90,7 +90,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource $stmt = $this->db->read("SELECT entity_id, entity_data FROM $tableName"); if ($stmt->execute()) { - $metadata = array(); + $metadata = []; while ($d = $stmt->fetch()) { $data = json_decode($d['entity_data'], true); @@ -127,7 +127,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource $metadataSet = $this->load($set); if ($metadataSet === null) { - $metadataSet = array(); + $metadataSet = []; } foreach ($metadataSet as $entityId => &$entry) { @@ -164,7 +164,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource $stmt = $this->db->read( "SELECT entity_id, entity_data FROM $tableName WHERE entity_id=:entityId", - array('entityId' => $entityId) + ['entityId' => $entityId] ); if ($stmt->execute()) { $rowCount = 0; @@ -237,17 +237,17 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource $metadata = $this->db->read( "SELECT entity_id, entity_data FROM $tableName WHERE entity_id = :entity_id", - array( + [ 'entity_id' => $index, - ) + ] ); $retrivedEntityIDs = $metadata->fetch(); - $params = array( + $params = [ 'entity_id' => $index, 'entity_data' => json_encode($entityData), - ); + ]; if ($retrivedEntityIDs !== false && count($retrivedEntityIDs) > 0) { $rows = $this->db->write( diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index 9adae2f0b..8c0507756 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -74,7 +74,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource */ public function getMetadataSets() { - $ret = array(); + $ret = []; $dh = @opendir($this->directory); if ($dh === false) { @@ -120,7 +120,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource { assert(is_string($set)); - $ret = array(); + $ret = []; $dir = $this->directory.'/'.rawurlencode($set); if (!is_dir($dir)) { diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerXML.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerXML.php index 56ea35515..9430781b6 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerXML.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerXML.php @@ -48,11 +48,11 @@ class MetaDataStorageHandlerXML extends MetaDataStorageSource } - $SP1x = array(); - $IdP1x = array(); - $SP20 = array(); - $IdP20 = array(); - $AAD = array(); + $SP1x = []; + $IdP1x = []; + $SP20 = []; + $IdP20 = []; + $AAD = []; if (isset($src)) { $entities = SAMLParser::parseDescriptorsFile($src); @@ -88,13 +88,13 @@ class MetaDataStorageHandlerXML extends MetaDataStorageSource } } - $this->metadata = array( + $this->metadata = [ 'shib13-sp-remote' => $SP1x, 'shib13-idp-remote' => $IdP1x, 'saml20-sp-remote' => $SP20, 'saml20-idp-remote' => $IdP20, 'attributeauthority-remote' => $AAD, - ); + ]; } @@ -113,6 +113,6 @@ class MetaDataStorageHandlerXML extends MetaDataStorageSource } // we don't have this metadata set - return array(); + return []; } } diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index c692b4a70..76aeabb63 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -32,7 +32,7 @@ abstract class MetaDataStorageSource { assert(is_array($sourcesConfig)); - $sources = array(); + $sources = []; foreach ($sourcesConfig as $sourceConfig) { if (!is_array($sourceConfig)) { @@ -111,7 +111,7 @@ abstract class MetaDataStorageSource */ public function getMetadataSet($set) { - return array(); + return []; } @@ -176,7 +176,7 @@ abstract class MetaDataStorageSource $metadataSet = $this->getMetadataSet($set); foreach ($metadataSet as $index => $entry) { - $cidrHints = array(); + $cidrHints = []; // support hint.cidr for idp discovery if (array_key_exists('hint.cidr', $entry) && is_array($entry['hint.cidr'])) { diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 48e1f9454..2e56c1bfd 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -328,7 +328,7 @@ class SAMLBuilder { assert(is_bool($indexed)); - $ret = array(); + $ret = []; foreach ($endpoints as &$ep) { if ($indexed) { @@ -387,7 +387,7 @@ class SAMLBuilder \SAML2\XML\md\SPSSODescriptor $spDesc, \SimpleSAML\Configuration $metadata ) { - $attributes = $metadata->getArray('attributes', array()); + $attributes = $metadata->getArray('attributes', []); $name = $metadata->getLocalizedString('name', null); if ($name === null || count($attributes) == 0) { @@ -395,7 +395,7 @@ class SAMLBuilder return; } - $attributesrequired = $metadata->getArray('attributes.required', array()); + $attributesrequired = $metadata->getArray('attributes.required', []); /* * Add an AttributeConsumingService element with information as name and description and list @@ -410,7 +410,7 @@ class SAMLBuilder } $attributeconsumer->ServiceName = $name; - $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array()); + $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', []); $nameFormat = $metadata->getString('attributes.NameFormat', \SAML2\Constants::NAMEFORMAT_UNSPECIFIED); foreach ($attributes as $friendlyName => $attribute) { @@ -473,7 +473,7 @@ class SAMLBuilder * @param array $metadata The metadata. * @param array $protocols The protocols supported. Defaults to \SAML2\Constants::NS_SAMLP. */ - public function addMetadataSP20($metadata, $protocols = array(\SAML2\Constants::NS_SAMLP)) + public function addMetadataSP20($metadata, $protocols = [\SAML2\Constants::NS_SAMLP]) { assert(is_array($metadata)); assert(is_array($protocols)); @@ -501,14 +501,14 @@ class SAMLBuilder $e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), false); - $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array()); + $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', []); $endpoints = $metadata->getEndpoints('AssertionConsumerService'); - foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) { - $endpoints[] = array( + foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', []) as $acs) { + $endpoints[] = [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', 'Location' => $acs, - ); + ]; } $e->AssertionConsumerService = self::createEndpoints($endpoints, true); @@ -516,7 +516,7 @@ class SAMLBuilder $this->entityDescriptor->RoleDescriptor[] = $e; - foreach ($metadata->getArray('contacts', array()) as $contact) { + foreach ($metadata->getArray('contacts', []) as $contact) { if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) { $this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact)); } @@ -559,13 +559,13 @@ class SAMLBuilder $e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), false); - $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array()); + $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', []); $e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), false); $this->entityDescriptor->RoleDescriptor[] = $e; - foreach ($metadata->getArray('contacts', array()) as $contact) { + foreach ($metadata->getArray('contacts', []) as $contact) { if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) { $this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact)); } @@ -591,14 +591,14 @@ class SAMLBuilder $this->addCertificate($e, $metadata); - $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array()); + $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', []); $endpoints = $metadata->getEndpoints('AssertionConsumerService'); - foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) { - $endpoints[] = array( + foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', []) as $acs) { + $endpoints[] = [ 'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01', 'Location' => $acs, - ); + ]; } $e->AssertionConsumerService = self::createEndpoints($endpoints, true); @@ -627,7 +627,7 @@ class SAMLBuilder $this->addCertificate($e, $metadata); - $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array()); + $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', []); $e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), false); @@ -650,7 +650,7 @@ class SAMLBuilder $metadata = \SimpleSAML\Configuration::loadFromArray($metadata, $metadata['entityid']); $e = new \SAML2\XML\md\AttributeAuthorityDescriptor(); - $e->protocolSupportEnumeration = $metadata->getArray('protocols', array(\SAML2\Constants::NS_SAMLP)); + $e->protocolSupportEnumeration = $metadata->getArray('protocols', [\SAML2\Constants::NS_SAMLP]); $this->addExtensions($metadata, $e); $this->addCertificate($e, $metadata); @@ -661,7 +661,7 @@ class SAMLBuilder false ); - $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array()); + $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', []); $this->entityDescriptor->RoleDescriptor[] = $e; } @@ -684,7 +684,7 @@ class SAMLBuilder { assert(is_string($type)); assert(is_array($details)); - assert(in_array($type, array('technical', 'support', 'administrative', 'billing', 'other'), true)); + assert(in_array($type, ['technical', 'support', 'administrative', 'billing', 'other'], true)); // TODO: remove this check as soon as getContact() is called always before calling this function $details = \SimpleSAML\Utils\Config\Metadata::getContact($details); @@ -709,7 +709,7 @@ class SAMLBuilder if (isset($details['emailAddress'])) { $eas = $details['emailAddress']; if (!is_array($eas)) { - $eas = array($eas); + $eas = [$eas]; } foreach ($eas as $ea) { $e->EmailAddress[] = $ea; @@ -719,7 +719,7 @@ class SAMLBuilder if (isset($details['telephoneNumber'])) { $tlfNrs = $details['telephoneNumber']; if (!is_array($tlfNrs)) { - $tlfNrs = array($tlfNrs); + $tlfNrs = [$tlfNrs]; } foreach ($tlfNrs as $tlfNr) { $e->TelephoneNumber[] = $tlfNr; @@ -739,7 +739,7 @@ class SAMLBuilder */ private function addX509KeyDescriptor(\SAML2\XML\md\RoleDescriptor $rd, $use, $x509data) { - assert(in_array($use, array('encryption', 'signing'), true)); + assert(in_array($use, ['encryption', 'signing'], true)); assert(is_string($x509data)); $keyDescriptor = \SAML2\Utils::createKeyDescriptor($x509data); diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index b59d285f6..bd8725198 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -23,19 +23,19 @@ class SAMLParser * * @var string[] */ - private static $SAML1xProtocols = array( + private static $SAML1xProtocols = [ 'urn:oasis:names:tc:SAML:1.0:protocol', 'urn:oasis:names:tc:SAML:1.1:protocol', - ); + ]; /** * This is the list with the SAML 2.0 protocol. * * @var string[] */ - private static $SAML20Protocols = array( + private static $SAML20Protocols = [ 'urn:oasis:names:tc:SAML:2.0:protocol', - ); + ]; /** * This is the entity id we find in the metadata. @@ -71,7 +71,7 @@ class SAMLParser * * @var array */ - private $attributeAuthorityDescriptors = array(); + private $attributeAuthorityDescriptors = []; /** * This is an associative array with the organization name for this entity. The key of @@ -80,7 +80,7 @@ class SAMLParser * * @var string[] */ - private $organizationName = array(); + private $organizationName = []; /** * This is an associative array with the organization display name for this entity. The key of @@ -89,7 +89,7 @@ class SAMLParser * * @var string[] */ - private $organizationDisplayName = array(); + private $organizationDisplayName = []; /** * This is an associative array with the organization URI for this entity. The key of @@ -97,14 +97,14 @@ class SAMLParser * * @var string[] */ - private $organizationURL = array(); + private $organizationURL = []; /** * This is an array of the Contact Persons of this entity. * * @var array[] */ - private $contacts = array(); + private $contacts = []; /** * @var array @@ -132,7 +132,7 @@ class SAMLParser * * @var \SAML2\SignedElementHelper[] */ - private $validators = array(); + private $validators = []; /** * The original EntityDescriptor element for this entity, as a base64 encoded string. @@ -153,13 +153,13 @@ class SAMLParser private function __construct( \SAML2\XML\md\EntityDescriptor $entityElement, $maxExpireTime, - array $validators = array(), - array $parentExtensions = array() + array $validators = [], + array $parentExtensions = [] ) { assert($maxExpireTime === null || is_int($maxExpireTime)); - $this->spDescriptors = array(); - $this->idpDescriptors = array(); + $this->spDescriptors = []; + $this->idpDescriptors = []; $e = $entityElement->toXML(); $e = $e->ownerDocument->saveXML($e); @@ -271,7 +271,7 @@ class SAMLParser public static function parseElement($entityElement) { assert($entityElement instanceof \SAML2\XML\md\EntityDescriptor); - return new SAMLParser($entityElement, null, array()); + return new SAMLParser($entityElement, null, []); } @@ -373,14 +373,14 @@ class SAMLParser private static function processDescriptorsElement( $element, $maxExpireTime = null, - array $validators = array(), - array $parentExtensions = array() + array $validators = [], + array $parentExtensions = [] ) { assert($maxExpireTime === null || is_int($maxExpireTime)); if ($element instanceof \SAML2\XML\md\EntityDescriptor) { $ret = new SAMLParser($element, $maxExpireTime, $validators, $parentExtensions); - $ret = array($ret->getEntityId() => $ret); + $ret = [$ret->getEntityId() => $ret]; /** @var SAMLParser[] $ret */ return $ret; } @@ -392,7 +392,7 @@ class SAMLParser $validators[] = $element; - $ret = array(); + $ret = []; foreach ($element->children as $child) { $ret += self::processDescriptorsElement($child, $expTime, $validators, $extensions); } @@ -439,7 +439,7 @@ class SAMLParser private function getMetadataCommon() { - $ret = array(); + $ret = []; $ret['entityid'] = $this->entityId; $ret['entityDescriptor'] = $this->entityDescriptor; @@ -836,7 +836,7 @@ class SAMLParser { assert($expireTime === null || is_int($expireTime)); - $ret = array(); + $ret = []; $expireTime = self::getExpireTime($element, $expireTime); @@ -848,7 +848,7 @@ class SAMLParser $ret['protocols'] = $element->protocolSupportEnumeration; // process KeyDescriptor elements - $ret['keys'] = array(); + $ret['keys'] = []; foreach ($element->KeyDescriptor as $kd) { $key = self::parseKeyDescriptor($kd); if ($key !== null) { @@ -999,16 +999,16 @@ class SAMLParser * * @return array An associative array with the extensions parsed. */ - private static function processExtensions($element, $parentExtensions = array()) + private static function processExtensions($element, $parentExtensions = []) { - $ret = array( - 'scope' => array(), - 'tags' => array(), - 'EntityAttributes' => array(), - 'RegistrationInfo' => array(), - 'UIInfo' => array(), - 'DiscoHints' => array(), - ); + $ret = [ + 'scope' => [], + 'tags' => [], + 'EntityAttributes' => [], + 'RegistrationInfo' => [], + 'UIInfo' => [], + 'DiscoHints' => [], + ]; // Some extensions may get inherited from a parent element if (($element instanceof \SAML2\XML\md\EntityDescriptor || $element instanceof \SAML2\XML\md\EntitiesDescriptor) @@ -1052,7 +1052,7 @@ class SAMLParser $name = '{'.$attr->NameFormat.'}'.$attr->Name; } - $values = array(); + $values = []; foreach ($attr->AttributeValue as $attrvalue) { $values[] = $attrvalue->getString(); } @@ -1088,11 +1088,11 @@ class SAMLParser ) { continue; } - $logo = array( + $logo = [ 'url' => $uiItem->url, 'height' => $uiItem->height, 'width' => $uiItem->width, - ); + ]; if (!empty($uiItem->lang)) { $logo['lang'] = $uiItem->lang; } @@ -1119,7 +1119,7 @@ class SAMLParser $name = $attribute->getAttribute('Name'); $values = array_map( - array('\SimpleSAML\Utils\XML', 'getDOMText'), + ['\SimpleSAML\Utils\XML', 'getDOMText'], \SimpleSAML\Utils\XML::getDOMChildren($attribute, 'AttributeValue', '@saml2') ); @@ -1157,7 +1157,7 @@ class SAMLParser private function processContactPerson(\SAML2\XML\md\ContactPerson $element) { - $contactPerson = array(); + $contactPerson = []; if (!empty($element->contactType)) { $contactPerson['contactType'] = $element->contactType; } @@ -1196,8 +1196,8 @@ class SAMLParser $sp['description'] = $element->ServiceDescription; $format = null; - $sp['attributes'] = array(); - $sp['attributes.required'] = array(); + $sp['attributes'] = []; + $sp['attributes.required'] = []; foreach ($element->RequestedAttribute as $child) { $attrname = $child->Name; $sp['attributes'][] = $attrname; @@ -1249,7 +1249,7 @@ class SAMLParser */ private static function parseGenericEndpoint(\SAML2\XML\md\EndpointType $element) { - $ep = array(); + $ep = []; $ep['Binding'] = $element->Binding; $ep['Location'] = $element->Location; @@ -1279,7 +1279,7 @@ class SAMLParser */ private static function extractEndpoints(array $endpoints) { - $ret = array(); + $ret = []; foreach ($endpoints as $ep) { $ret[] = self::parseGenericEndpoint($ep); } @@ -1304,7 +1304,7 @@ class SAMLParser */ private static function parseKeyDescriptor(\SAML2\XML\md\KeyDescriptor $kd) { - $r = array(); + $r = []; if ($kd->use === 'encryption') { $r['encryption'] = true; @@ -1346,7 +1346,7 @@ class SAMLParser { assert(is_array($protocols)); - $ret = array(); + $ret = []; foreach ($this->spDescriptors as $spd) { $sharedProtocols = array_intersect($protocols, $spd['protocols']); @@ -1370,7 +1370,7 @@ class SAMLParser { assert(is_array($protocols)); - $ret = array(); + $ret = []; foreach ($this->idpDescriptors as $idpd) { $sharedProtocols = array_intersect($protocols, $idpd['protocols']); @@ -1435,7 +1435,7 @@ class SAMLParser $certData = file_get_contents($certFile); foreach ($this->validators as $validator) { - $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'public')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']); $key->loadKey($certData); try { if ($validator->validate($key)) { @@ -1466,7 +1466,7 @@ class SAMLParser $fingerprint = strtolower(str_replace(":", "", $fingerprint)); - $candidates = array(); + $candidates = []; foreach ($this->validators as $validator) { foreach ($validator->getValidatingCertificates() as $cert) { $fp = strtolower(sha1(base64_decode($cert))); diff --git a/lib/SimpleSAML/Metadata/Signer.php b/lib/SimpleSAML/Metadata/Signer.php index 1cb042017..98806d562 100644 --- a/lib/SimpleSAML/Metadata/Signer.php +++ b/lib/SimpleSAML/Metadata/Signer.php @@ -43,10 +43,10 @@ class Signer ); } - $ret = array( + $ret = [ 'privatekey' => $entityMetadata['metadata.sign.privatekey'], 'certificate' => $entityMetadata['metadata.sign.certificate'] - ); + ]; if (array_key_exists('metadata.sign.privatekey_pass', $entityMetadata)) { $ret['privatekey_pass'] = $entityMetadata['metadata.sign.privatekey_pass']; @@ -67,7 +67,7 @@ class Signer ' must also be specified.' ); } - $ret = array('privatekey' => $privatekey, 'certificate' => $certificate); + $ret = ['privatekey' => $privatekey, 'certificate' => $certificate]; $privatekey_pass = $config->getString('metadata.sign.privatekey_pass', null); if ($privatekey_pass !== null) { @@ -92,10 +92,10 @@ class Signer ); } - $ret = array( + $ret = [ 'privatekey' => $entityMetadata['privatekey'], 'certificate' => $entityMetadata['certificate'] - ); + ]; if (array_key_exists('privatekey_pass', $entityMetadata)) { $ret['privatekey_pass'] = $entityMetadata['privatekey_pass']; @@ -173,12 +173,12 @@ class Signer $alg = $config->getString('metadata.sign.algorithm', XMLSecurityKey::RSA_SHA256); } - $supported_algs = array( + $supported_algs = [ XMLSecurityKey::RSA_SHA1, XMLSecurityKey::RSA_SHA256, XMLSecurityKey::RSA_SHA384, XMLSecurityKey::RSA_SHA512, - ); + ]; if (!in_array($alg, $supported_algs, true)) { throw new \SimpleSAML\Error\CriticalConfigurationError("Unknown signature algorithm '$alg'"); @@ -198,10 +198,10 @@ class Signer $digest = XMLSecurityDSig::SHA1; } - return array( + return [ 'algorithm' => $alg, 'digest' => $digest, - ); + ]; } @@ -254,7 +254,7 @@ class Signer $signature_cf = self::getMetadataSigningAlgorithm($config, $entityMetadata, $type); // load the private key - $objKey = new XMLSecurityKey($signature_cf['algorithm'], array('type' => 'private')); + $objKey = new XMLSecurityKey($signature_cf['algorithm'], ['type' => 'private']); if (array_key_exists('privatekey_pass', $keyCertFiles)) { $objKey->passphrase = $keyCertFiles['privatekey_pass']; } @@ -269,10 +269,10 @@ class Signer $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); $objXMLSecDSig->addReferenceList( - array($rootNode), + [$rootNode], $signature_cf['digest'], - array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), - array('id_name' => 'ID') + ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N], + ['id_name' => 'ID'] ); $objXMLSecDSig->sign($objKey); diff --git a/lib/SimpleSAML/Metadata/Sources/MDQ.php b/lib/SimpleSAML/Metadata/Sources/MDQ.php index bb0b053f8..413846427 100644 --- a/lib/SimpleSAML/Metadata/Sources/MDQ.php +++ b/lib/SimpleSAML/Metadata/Sources/MDQ.php @@ -104,7 +104,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource public function getMetadataSet($set) { // we don't have this metadata set - return array(); + return []; } diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index e3e018c7b..9668a3673 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -17,14 +17,14 @@ class Module * * @var array */ - public static $modules = array(); + public static $modules = []; /** * A cache containing specific information for modules, like whether they are enabled or not, or their hooks. * * @var array */ - public static $module_info = array(); + public static $module_info = []; /** @@ -59,7 +59,7 @@ class Module public static function isModuleEnabled($module) { $config = Configuration::getOptionalConfig(); - return self::isModuleEnabledWithConf($module, $config->getArray('module.enable', array())); + return self::isModuleEnabledWithConf($module, $config->getArray('module.enable', [])); } @@ -219,7 +219,7 @@ class Module * * @return string The absolute URL to the given resource. */ - public static function getModuleURL($resource, array $parameters = array()) + public static function getModuleURL($resource, array $parameters = []) { assert(is_string($resource)); assert($resource[0] !== '/'); @@ -249,10 +249,10 @@ class Module $hook_dir = self::getModuleDir($module).'/hooks'; if (!is_dir($hook_dir)) { - return array(); + return []; } - $hooks = array(); + $hooks = []; $files = scandir($hook_dir); foreach ($files as $file) { if ($file[0] === '.') { @@ -264,7 +264,7 @@ class Module } $hook_name = $matches[1]; $hook_func = $module.'_hook_'.$hook_name; - $hooks[$hook_name] = array('file' => $hook_dir.'/'.$file, 'func' => $hook_func); + $hooks[$hook_name] = ['file' => $hook_dir.'/'.$file, 'func' => $hook_func]; } return $hooks; } @@ -285,7 +285,7 @@ class Module assert(is_string($hook)); $modules = self::getModules(); - $config = Configuration::getOptionalConfig()->getArray('module.enable', array()); + $config = Configuration::getOptionalConfig()->getArray('module.enable', []); sort($modules); foreach ($modules as $module) { if (!self::isModuleEnabledWithConf($module, $config)) { diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index b21a6e710..481a1d689 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -38,7 +38,7 @@ class Session implements \Serializable * * @var array */ - private static $sessions = array(); + private static $sessions = []; /** @@ -101,7 +101,7 @@ class Session implements \Serializable * * @var array */ - private $dataStore = array(); + private $dataStore = []; /** * The list of IdP-SP associations. @@ -111,7 +111,7 @@ class Session implements \Serializable * * @var array */ - private $associations = array(); + private $associations = []; /** * The authentication token. @@ -129,7 +129,7 @@ class Session implements \Serializable * * @var array Associative array of associative arrays. */ - private $authData = array(); + private $authData = []; /** * Private constructor that restricts instantiation to either getSessionFromRequest() for the current session or @@ -477,7 +477,7 @@ class Session implements \Serializable // we already have a shutdown callback registered for this object, no need to add another one return; } - $this->callback_registered = header_register_callback(array($this, 'save')); + $this->callback_registered = header_register_callback([$this, 'save']); } /** @@ -547,7 +547,7 @@ class Session implements \Serializable } $this->rememberMeExpire = $expire; - $cookieParams = array('expire' => $this->rememberMeExpire); + $cookieParams = ['expire' => $this->rememberMeExpire]; $this->updateSessionCookies($cookieParams); } @@ -576,7 +576,7 @@ class Session implements \Serializable } if ($data === null) { - $data = array(); + $data = []; } $data['Authority'] = $authority; @@ -752,7 +752,7 @@ class Session implements \Serializable $sessionHandler->setCookie($sessionHandler->getSessionCookieName(), $this->sessionId, $params); } - $params = array_merge($sessionHandler->getCookieParams(), is_array($params) ? $params : array()); + $params = array_merge($sessionHandler->getCookieParams(), is_array($params) ? $params : []); if ($this->authToken !== null) { $globalConfig = Configuration::getInstance(); @@ -798,7 +798,7 @@ class Session implements \Serializable { assert(isset($this->authData[$authority])); - $logout_handler = array($classname, $functionname); + $logout_handler = [$classname, $functionname]; if (!is_callable($logout_handler)) { throw new \Exception( @@ -878,14 +878,14 @@ class Session implements \Serializable $expires = time() + $timeout; } - $dataInfo = array( + $dataInfo = [ 'expires' => $expires, 'timeout' => $timeout, 'data' => $data - ); + ]; if (!array_key_exists($type, $this->dataStore)) { - $this->dataStore[$type] = array(); + $this->dataStore[$type] = []; } $this->dataStore[$type][$id] = $dataInfo; @@ -969,10 +969,10 @@ class Session implements \Serializable assert(is_string($type)); if (!array_key_exists($type, $this->dataStore)) { - return array(); + return []; } - $ret = array(); + $ret = []; foreach ($this->dataStore[$type] as $id => $info) { $ret[$id] = $info['data']; } @@ -1026,11 +1026,11 @@ class Session implements \Serializable assert(isset($association['Handler'])); if (!isset($this->associations)) { - $this->associations = array(); + $this->associations = []; } if (!isset($this->associations[$idp])) { - $this->associations[$idp] = array(); + $this->associations[$idp] = []; } $this->associations[$idp][$association['id']] = $association; @@ -1052,11 +1052,11 @@ class Session implements \Serializable assert(is_string($idp)); if (!isset($this->associations)) { - $this->associations = array(); + $this->associations = []; } if (!isset($this->associations[$idp])) { - return array(); + return []; } foreach ($this->associations[$idp] as $id => $assoc) { @@ -1126,7 +1126,7 @@ class Session implements \Serializable */ public function getAuthorities() { - $authorities = array(); + $authorities = []; foreach (array_keys($this->authData) as $authority) { if ($this->isValid($authority)) { $authorities[] = $authority; diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php index 25f4ab580..f8e0236f5 100644 --- a/lib/SimpleSAML/SessionHandler.php +++ b/lib/SimpleSAML/SessionHandler.php @@ -149,12 +149,12 @@ abstract class SessionHandler { $config = Configuration::getInstance(); - return array( + return [ 'lifetime' => $config->getInteger('session.cookie.lifetime', 0), 'path' => $config->getString('session.cookie.path', '/'), 'domain' => $config->getString('session.cookie.domain', null), 'secure' => $config->getBoolean('session.cookie.secure', false), 'httponly' => true, - ); + ]; } } diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index b83b6bffa..554605b98 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -34,7 +34,7 @@ class SessionHandlerPHP extends SessionHandler * * @var array */ - private $previous_session = array(); + private $previous_session = []; /** @@ -147,7 +147,7 @@ class SessionHandlerPHP extends SessionHandler $this->previous_session['cookie_params']['httponly'] ); session_id($this->previous_session['id']); - $this->previous_session = array(); + $this->previous_session = []; $this->sessionStart(); /* diff --git a/lib/SimpleSAML/Stats.php b/lib/SimpleSAML/Stats.php index 5a1dbf47f..8c2987c82 100644 --- a/lib/SimpleSAML/Stats.php +++ b/lib/SimpleSAML/Stats.php @@ -52,9 +52,9 @@ class Stats { $config = \SimpleSAML\Configuration::getInstance(); - $outputCfgs = $config->getConfigList('statistics.out', array()); + $outputCfgs = $config->getConfigList('statistics.out', []); - self::$outputs = array(); + self::$outputs = []; foreach ($outputCfgs as $cfg) { self::$outputs[] = self::createOutput($cfg); } @@ -69,7 +69,7 @@ class Stats * * @return void|boolean False if output is not enabled, void otherwise. */ - public static function log($event, array $data = array()) + public static function log($event, array $data = []) { assert(is_string($event)); assert(!isset($data['op'])); diff --git a/lib/SimpleSAML/Store/Redis.php b/lib/SimpleSAML/Store/Redis.php index 1841670ba..9091ddd63 100644 --- a/lib/SimpleSAML/Store/Redis.php +++ b/lib/SimpleSAML/Store/Redis.php @@ -33,14 +33,14 @@ class Redis extends Store $prefix = $config->getString('store.redis.prefix', 'SimpleSAMLphp'); $redis = new \Predis\Client( - array( + [ 'scheme' => 'tcp', 'host' => $host, 'port' => $port, - ), - array( + ], + [ 'prefix' => $prefix, - ) + ] ); } diff --git a/lib/SimpleSAML/Store/SQL.php b/lib/SimpleSAML/Store/SQL.php index 50d23f5d4..72bb84248 100644 --- a/lib/SimpleSAML/Store/SQL.php +++ b/lib/SimpleSAML/Store/SQL.php @@ -80,7 +80,7 @@ class SQL extends Store */ private function initTableVersionTable() { - $this->tableVersions = array(); + $this->tableVersions = []; try { $fetchTableVersion = $this->pdo->query('SELECT _name, _version FROM '.$this->prefix.'_tableVersion'); @@ -115,13 +115,13 @@ class SQL extends Store * Queries for updates, grouped by version. * New updates can be added as a new array in this array */ - $table_updates = array( - array( + $table_updates = [ + [ 'CREATE TABLE '.$this->prefix. '_kvstore (_type VARCHAR(30) NOT NULL, _key VARCHAR(50) NOT NULL, _value '.$text_t. ' NOT NULL, _expire TIMESTAMP, PRIMARY KEY (_key, _type))', 'CREATE INDEX '.$this->prefix.'_kvstore_expire ON '.$this->prefix.'_kvstore (_expire)' - ), + ], /** * This upgrade removes the default NOT NULL constraint on the _expire field in MySQL. * Because SQLite does not support field alterations, the approach is to: @@ -131,7 +131,7 @@ class SQL extends Store * Rename the new table correctly * Readd the index */ - array( + [ 'CREATE TABLE '.$this->prefix. '_kvstore_new (_type VARCHAR(30) NOT NULL, _key VARCHAR(50) NOT NULL, _value '.$text_t. ' NOT NULL, _expire TIMESTAMP NULL, PRIMARY KEY (_key, _type))', @@ -139,8 +139,8 @@ class SQL extends Store 'DROP TABLE '.$this->prefix.'_kvstore', 'ALTER TABLE '.$this->prefix.'_kvstore_new RENAME TO '.$this->prefix.'_kvstore', 'CREATE INDEX '.$this->prefix.'_kvstore_expire ON '.$this->prefix.'_kvstore (_expire)' - ) - ); + ] + ]; $latest_version = count($table_updates); @@ -193,8 +193,8 @@ class SQL extends Store $this->insertOrUpdate( $this->prefix.'_tableVersion', - array('_name'), - array('_name' => $name, '_version' => $version) + ['_name'], + ['_name' => $name, '_version' => $version] ); $this->tableVersions[$name] = $version; } @@ -246,8 +246,8 @@ class SQL extends Store } } - $updateCols = array(); - $condCols = array(); + $updateCols = []; + $condCols = []; foreach ($data as $col => $value) { $tmp = $col.' = :'.$col; @@ -272,7 +272,7 @@ class SQL extends Store Logger::debug('store.sql: Cleaning key-value store.'); $query = 'DELETE FROM '.$this->prefix.'_kvstore WHERE _expire < :now'; - $params = array('now' => gmdate('Y-m-d H:i:s')); + $params = ['now' => gmdate('Y-m-d H:i:s')]; $query = $this->pdo->prepare($query); $query->execute($params); @@ -298,7 +298,7 @@ class SQL extends Store $query = 'SELECT _value FROM '.$this->prefix. '_kvstore WHERE _type = :type AND _key = :key AND (_expire IS NULL OR _expire > :now)'; - $params = array('type' => $type, 'key' => $key, 'now' => gmdate('Y-m-d H:i:s')); + $params = ['type' => $type, 'key' => $key, 'now' => gmdate('Y-m-d H:i:s')]; $query = $this->pdo->prepare($query); $query->execute($params); @@ -351,14 +351,14 @@ class SQL extends Store $value = serialize($value); $value = rawurlencode($value); - $data = array( + $data = [ '_type' => $type, '_key' => $key, '_value' => $value, '_expire' => $expire, - ); + ]; - $this->insertOrUpdate($this->prefix.'_kvstore', array('_type', '_key'), $data); + $this->insertOrUpdate($this->prefix.'_kvstore', ['_type', '_key'], $data); } @@ -377,10 +377,10 @@ class SQL extends Store $key = sha1($key); } - $data = array( + $data = [ '_type' => $type, '_key' => $key, - ); + ]; $query = 'DELETE FROM '.$this->prefix.'_kvstore WHERE _type=:_type AND _key=:_key'; $query = $this->pdo->prepare($query); diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 0a830bb44..c6e04223e 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -191,7 +191,7 @@ class Utilities } - private static function doRedirect($url, $parameters = array()) + private static function doRedirect($url, $parameters = []) { assert(is_string($url)); assert(!empty($url)); @@ -253,7 +253,7 @@ class Utilities * @deprecated 1.12.0 This method will be removed from the API. Instead, use the redirectTrustedURL() or * redirectUntrustedURL() functions accordingly. */ - public static function redirect($url, $parameters = array(), $allowed_redirect_hosts = null) + public static function redirect($url, $parameters = [], $allowed_redirect_hosts = null) { assert(is_string($url)); assert(strlen($url) > 0); @@ -272,7 +272,7 @@ class Utilities * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::redirectTrustedURL() * instead. */ - public static function redirectTrustedURL($url, $parameters = array()) + public static function redirectTrustedURL($url, $parameters = []) { \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $parameters); } @@ -282,7 +282,7 @@ class Utilities * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::redirectUntrustedURL() * instead. */ - public static function redirectUntrustedURL($url, $parameters = array()) + public static function redirectUntrustedURL($url, $parameters = []) { \SimpleSAML\Utils\HTTP::redirectUntrustedURL($url, $parameters); } @@ -562,17 +562,17 @@ class Utilities assert(is_array($post)); $postId = \SimpleSAML\Utils\Random::generateID(); - $postData = array( + $postData = [ 'post' => $post, 'url' => $destination, - ); + ]; $session = \SimpleSAML\Session::getSessionFromRequest(); $session->setData('core_postdatalink', $postId, $postData); $redirInfo = base64_encode(\SimpleSAML\Utils\Crypto::aesEncrypt($session->getSessionId().':'.$postId)); - $url = \SimpleSAML\Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $redirInfo)); + $url = \SimpleSAML\Module::getModuleURL('core/postredirect.php', ['RedirInfo' => $redirInfo]); $url = preg_replace("#^https:#", "http:", $url); return $url; @@ -665,7 +665,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::fetch() instead. */ - public static function fetch($path, $context = array(), $getHeaders = false) + public static function fetch($path, $context = [], $getHeaders = false) { return \SimpleSAML\Utils\HTTP::fetch($path, $context, $getHeaders); } diff --git a/lib/SimpleSAML/Utils/Arrays.php b/lib/SimpleSAML/Utils/Arrays.php index 0a5129230..c27b198eb 100644 --- a/lib/SimpleSAML/Utils/Arrays.php +++ b/lib/SimpleSAML/Utils/Arrays.php @@ -23,7 +23,7 @@ class Arrays */ public static function arrayize($data, $index = 0) { - return (is_array($data)) ? $data : array($index => $data); + return (is_array($data)) ? $data : [$index => $data]; } @@ -42,7 +42,7 @@ class Arrays return false; } - $ret = array(); + $ret = []; foreach ($array as $k1 => $a2) { if (!is_array($a2)) { return false; @@ -50,7 +50,7 @@ class Arrays foreach ($a2 as $k2 => $v) { if (!array_key_exists($k2, $ret)) { - $ret[$k2] = array(); + $ret[$k2] = []; } $ret[$k2][$k1] = $v; } diff --git a/lib/SimpleSAML/Utils/Attributes.php b/lib/SimpleSAML/Utils/Attributes.php index f06efbfd6..88c87f1aa 100644 --- a/lib/SimpleSAML/Utils/Attributes.php +++ b/lib/SimpleSAML/Utils/Attributes.php @@ -85,7 +85,7 @@ class Attributes ); } - $newAttrs = array(); + $newAttrs = []; foreach ($attributes as $name => $values) { if (!is_string($name)) { throw new \InvalidArgumentException('Invalid attribute name: "'.print_r($name, true).'".'); @@ -127,6 +127,6 @@ class Attributes $defaultns = substr($name, 0, $slash); $name = substr($name, $slash + 1); } - return array(htmlspecialchars($defaultns), htmlspecialchars($name)); + return [htmlspecialchars($defaultns), htmlspecialchars($name)]; } } diff --git a/lib/SimpleSAML/Utils/Auth.php b/lib/SimpleSAML/Utils/Auth.php index 93dd52922..7cff78b27 100644 --- a/lib/SimpleSAML/Utils/Auth.php +++ b/lib/SimpleSAML/Utils/Auth.php @@ -28,7 +28,7 @@ class Auth $returnTo = HTTP::getSelfURL(); } - return Module::getModuleURL('core/login-admin.php', array('ReturnTo' => $returnTo)); + return Module::getModuleURL('core/login-admin.php', ['ReturnTo' => $returnTo]); } diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php index 5cecde300..b306d200c 100644 --- a/lib/SimpleSAML/Utils/Config/Metadata.php +++ b/lib/SimpleSAML/Utils/Config/Metadata.php @@ -35,7 +35,7 @@ class Metadata * @var array The valid configuration options for a contact configuration array. * @see "Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0", section 2.3.2.2. */ - public static $VALID_CONTACT_OPTIONS = array( + public static $VALID_CONTACT_OPTIONS = [ 'contactType', 'emailAddress', 'givenName', @@ -43,20 +43,20 @@ class Metadata 'telephoneNumber', 'company', 'attributes', - ); + ]; /** * @var array The valid types of contact for a contact configuration array. * @see "Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0", section 2.3.2.2. */ - public static $VALID_CONTACT_TYPES = array( + public static $VALID_CONTACT_TYPES = [ 'technical', 'support', 'administrative', 'billing', 'other', - ); + ]; /** diff --git a/lib/SimpleSAML/Utils/Crypto.php b/lib/SimpleSAML/Utils/Crypto.php index 7a6ea922e..dece1961c 100644 --- a/lib/SimpleSAML/Utils/Crypto.php +++ b/lib/SimpleSAML/Utils/Crypto.php @@ -220,9 +220,9 @@ class Crypto throw new Error\Exception('Unable to load private key from file "'.$file.'"'); } - $ret = array( + $ret = [ 'PEM' => $data, - ); + ]; if ($metadata->hasValue($prefix.'privatekey_pass')) { $ret['password'] = $metadata->getString($prefix.'privatekey_pass'); @@ -286,11 +286,11 @@ class Crypto "-----END CERTIFICATE-----\n"; $certFingerprint = strtolower(sha1(base64_decode($certData))); - return array( + return [ 'certData' => $certData, 'PEM' => $pem, - 'certFingerprint' => array($certFingerprint), - ); + 'certFingerprint' => [$certFingerprint], + ]; } // no valid key found } elseif ($metadata->hasValue($prefix.'certFingerprint')) { @@ -307,7 +307,7 @@ class Crypto * We can't build a full certificate from a fingerprint, and may as well return an array with only the * fingerprint(s) immediately. */ - return array('certFingerprint' => $fps); + return ['certFingerprint' => $fps]; } // no public key/certificate available diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index dc7a19289..81203e9f4 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -40,7 +40,7 @@ class HTTP // encrypt the session ID and the random ID $info = base64_encode(Crypto::aesEncrypt($session_id.':'.$id)); - $url = Module::getModuleURL('core/postredirect.php', array('RedirInfo' => $info)); + $url = Module::getModuleURL('core/postredirect.php', ['RedirInfo' => $info]); return preg_replace('#^https:#', 'http:', $url); } @@ -146,7 +146,7 @@ class HTTP * @author Mads Freek Petersen * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - private static function redirect($url, $parameters = array()) + private static function redirect($url, $parameters = []) { if (!is_string($url) || empty($url) || !is_array($parameters)) { throw new \InvalidArgumentException('Invalid input parameters.'); @@ -220,10 +220,10 @@ class HTTP { // generate a random ID to avoid replay attacks $id = Random::generateID(); - $postData = array( + $postData = [ 'post' => $data, 'url' => $destination, - ); + ]; // save the post data to the session, tied to the random ID $session->setData('core_postdatalink', $id, $postData); @@ -253,13 +253,13 @@ class HTTP $queryStart = strpos($url, '?'); if ($queryStart === false) { - $oldQuery = array(); + $oldQuery = []; $url .= '?'; } else { /** @var string|false $oldQuery */ $oldQuery = substr($url, $queryStart + 1); if ($oldQuery === false) { - $oldQuery = array(); + $oldQuery = []; } else { $oldQuery = self::parseQueryString($oldQuery); } @@ -300,7 +300,7 @@ class HTTP $url = Module::getModuleURL('core/no_cookie.php'); if ($retryURL !== null) { - $url = self::addURLParameters($url, array('retryURL' => $retryURL)); + $url = self::addURLParameters($url, ['retryURL' => $retryURL]); } self::redirectTrustedURL($url); } @@ -333,7 +333,7 @@ class HTTP // get the white list of domains if ($trustedSites === null) { - $trustedSites = Configuration::getInstance()->getValue('trusted.url.domains', array()); + $trustedSites = Configuration::getInstance()->getValue('trusted.url.domains', []); } // validates the URL's host is among those allowed @@ -407,7 +407,7 @@ class HTTP * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Marco Ferrante, University of Genova <marco@csita.unige.it> */ - public static function fetch($url, $context = array(), $getHeaders = false) + public static function fetch($url, $context = [], $getHeaders = false) { if (!is_string($url)) { throw new \InvalidArgumentException('Invalid input parameters.'); @@ -442,10 +442,10 @@ class HTTP // extract the hostname $hostname = parse_url($url, PHP_URL_HOST); if (!empty($hostname)) { - $context['ssl'] = array( + $context['ssl'] = [ 'SNI_server_name' => $hostname, 'SNI_enabled' => true, - ); + ]; } else { Logger::warning('Invalid URL format or local URL used through a proxy'); } @@ -463,10 +463,10 @@ class HTTP // data and headers if ($getHeaders) { if (isset($http_response_header)) { - $headers = array(); + $headers = []; foreach ($http_response_header as $h) { if (preg_match('@^HTTP/1\.[01]\s+\d{3}\s+@', $h)) { - $headers = array(); // reset + $headers = []; // reset $headers[0] = $h; continue; } @@ -479,7 +479,7 @@ class HTTP // no HTTP headers, probably a different protocol, e.g. file $headers = null; } - return array($data, $headers); + return [$data, $headers]; } return $data; @@ -501,12 +501,12 @@ class HTTP { if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) { // no Accept-Language header, return an empty set - return array(); + return []; } $languages = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])); - $ret = array(); + $ret = []; foreach ($languages as $l) { $opts = explode(';', $l); @@ -681,7 +681,7 @@ class HTTP // post the data directly $session = Session::getSessionFromRequest(); $id = self::savePOSTData($session, $destination, $data); - $url = Module::getModuleURL('core/postredirect.php', array('RedirId' => $id)); + $url = Module::getModuleURL('core/postredirect.php', ['RedirId' => $id]); } return $url; @@ -919,7 +919,7 @@ class HTTP throw new \InvalidArgumentException('Invalid input parameters.'); } - $res = array(); + $res = []; if (empty($query_string)) { return $res; } @@ -960,7 +960,7 @@ class HTTP * * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function redirectTrustedURL($url, $parameters = array()) + public static function redirectTrustedURL($url, $parameters = []) { if (!is_string($url) || !is_array($parameters)) { throw new \InvalidArgumentException('Invalid input parameters.'); @@ -992,7 +992,7 @@ class HTTP * * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function redirectUntrustedURL($url, $parameters = array()) + public static function redirectUntrustedURL($url, $parameters = []) { if (!is_string($url) || !is_array($parameters)) { throw new \InvalidArgumentException('Invalid input parameters.'); @@ -1115,7 +1115,7 @@ class HTTP throw new \InvalidArgumentException('Invalid input parameters.'); } - $default_params = array( + $default_params = [ 'lifetime' => 0, 'expire' => null, 'path' => '/', @@ -1123,7 +1123,7 @@ class HTTP 'secure' => false, 'httponly' => true, 'raw' => false, - ); + ]; if ($params !== null) { $params = array_merge($default_params, $params); diff --git a/lib/SimpleSAML/Utils/HttpAdapter.php b/lib/SimpleSAML/Utils/HttpAdapter.php index 71c611508..b82392076 100644 --- a/lib/SimpleSAML/Utils/HttpAdapter.php +++ b/lib/SimpleSAML/Utils/HttpAdapter.php @@ -52,7 +52,7 @@ class HttpAdapter /** * @see HTTP::fetch() */ - public function fetch($url, $context = array(), $getHeaders = false) + public function fetch($url, $context = [], $getHeaders = false) { return HTTP::fetch($url, $context, $getHeaders); } @@ -172,7 +172,7 @@ class HttpAdapter /** * @see HTTP::redirectTrustedURL() */ - public function redirectTrustedURL($url, $parameters = array()) + public function redirectTrustedURL($url, $parameters = []) { HTTP::redirectTrustedURL($url, $parameters); } @@ -180,7 +180,7 @@ class HttpAdapter /** * @see HTTP::redirectUntrustedURL() */ - public function redirectUntrustedURL($url, $parameters = array()) + public function redirectUntrustedURL($url, $parameters = []) { HTTP::redirectUntrustedURL($url, $parameters); } diff --git a/lib/SimpleSAML/Utils/Net.php b/lib/SimpleSAML/Utils/Net.php index 96526ad68..02619d221 100644 --- a/lib/SimpleSAML/Utils/Net.php +++ b/lib/SimpleSAML/Utils/Net.php @@ -35,8 +35,8 @@ class Net list ($net, $mask) = explode('/', $cidr); $mask = intval($mask); - $ip_ip = array(); - $ip_net = array(); + $ip_ip = []; + $ip_net = []; if (strstr($ip, ':') || strstr($net, ':')) { // Validate IPv6 with inet_pton, convert to hex with bin2hex // then store as a long with hexdec diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 96be4c3de..9b1f37766 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -34,7 +34,7 @@ class XML */ public static function checkSAMLMessage($message, $type) { - $allowed_types = array('saml20', 'saml11', 'saml-meta'); + $allowed_types = ['saml20', 'saml11', 'saml-meta']; if (!(is_string($message) && in_array($type, $allowed_types, true))) { throw new \InvalidArgumentException('Invalid input parameters.'); } @@ -45,7 +45,7 @@ class XML } // see if debugging is enabled for XML validation - $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', array('validatexml' => false)); + $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', ['validatexml' => false]); $enabled = \SimpleSAML\Configuration::getInstance()->getBoolean('debug.validatexml', false); if (!(in_array('validatexml', $debug, true) // implicitly enabled @@ -99,7 +99,7 @@ class XML } // see if debugging is enabled for SAML messages - $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', array('saml' => false)); + $debug = \SimpleSAML\Configuration::getInstance()->getArrayize('debug', ['saml' => false]); if (!(in_array('saml', $debug, true) // implicitly enabled || (array_key_exists('saml', $debug) && $debug['saml'] === true) @@ -163,8 +163,8 @@ class XML // check what this element contains $fullText = ''; // all text in this element - $textNodes = array(); // text nodes which should be deleted - $childNodes = array(); // other child nodes + $textNodes = []; // text nodes which should be deleted + $childNodes = []; // other child nodes for ($i = 0; $i < $root->childNodes->length; $i++) { /** @var \DOMElement $child */ $child = $root->childNodes->item($i); @@ -285,7 +285,7 @@ class XML throw new \InvalidArgumentException('Invalid input parameters.'); } - $ret = array(); + $ret = []; for ($i = 0; $i < $element->childNodes->length; $i++) { /** @var \DOMElement $child */ @@ -366,7 +366,7 @@ class XML // check if the namespace is a shortcut, and expand it if it is if ($nsURI[0] === '@') { // the defined shortcuts - $shortcuts = array( + $shortcuts = [ '@ds' => 'http://www.w3.org/2000/09/xmldsig#', '@md' => 'urn:oasis:names:tc:SAML:2.0:metadata', '@saml1' => 'urn:oasis:names:tc:SAML:1.0:assertion', @@ -375,7 +375,7 @@ class XML '@saml2' => 'urn:oasis:names:tc:SAML:2.0:assertion', '@saml2p' => 'urn:oasis:names:tc:SAML:2.0:protocol', '@shibmd' => 'urn:mace:shibboleth:metadata:1.0', - ); + ]; // check if it is a valid shortcut if (!array_key_exists($nsURI, $shortcuts)) { diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php index 3e880f1a8..a9e239029 100644 --- a/lib/SimpleSAML/XHTML/EMail.php +++ b/lib/SimpleSAML/XHTML/EMail.php @@ -17,7 +17,7 @@ class EMail private $from = null; private $replyto = null; private $subject = null; - private $headers = array(); + private $headers = []; /** diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 7957219ad..794e82543 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -94,7 +94,7 @@ class IdPDisco * * @var array */ - protected $scopedIDPList = array(); + protected $scopedIDPList = []; /** * The URL the user should be redirected to after choosing an IdP. @@ -214,13 +214,13 @@ class IdPDisco { $prefixedName = 'idpdisco_'.$this->instance.'_'.$name; - $params = array( + $params = [ // we save the cookies for 90 days 'lifetime' => (60 * 60 * 24 * 90), // the base path for cookies. This should be the installation directory for SimpleSAMLphp 'path' => $this->config->getBasePath(), 'httponly' => false, - ); + ]; \SimpleSAML\Utils\HTTP::setCookie($prefixedName, $value, $params, false); } @@ -290,7 +290,7 @@ class IdPDisco * back. Therefore we do some quick and dirty parsing of the query string. */ $qstr = $_SERVER['QUERY_STRING']; - $matches = array(); + $matches = []; if (preg_match('/(?:^|&)idp_([^=]+)=/', $qstr, $matches)) { return $this->validateIdP(urldecode($matches[1])); } @@ -459,7 +459,7 @@ class IdPDisco */ protected function getIdPList() { - $idpList = array(); + $idpList = []; foreach ($this->metadataSets as $metadataSet) { $newList = $this->metadata->getList($metadataSet); /* @@ -517,18 +517,18 @@ class IdPDisco $extDiscoveryStorage = $this->config->getString('idpdisco.extDiscoveryStorage', null); if ($extDiscoveryStorage !== null) { $this->log('Choice made ['.$idp.'] (Forwarding to external discovery storage)'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($extDiscoveryStorage, array( + \SimpleSAML\Utils\HTTP::redirectTrustedURL($extDiscoveryStorage, [ 'entityID' => $this->spEntityId, 'IdPentityID' => $idp, 'returnIDParam' => $this->returnIdParam, 'isPassive' => 'true', 'return' => $this->returnURL - )); + ]); } else { $this->log( 'Choice made ['.$idp.'] (Redirecting the user back. returnIDParam='.$this->returnIdParam.')' ); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, [$this->returnIdParam => $idp]); } } @@ -567,7 +567,7 @@ class IdPDisco ); \SimpleSAML\Utils\HTTP::redirectTrustedURL( $this->returnURL, - array($this->returnIdParam => $idpintersection[0]) + [$this->returnIdParam => $idpintersection[0]] ); } diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 554fa77b6..3ae190b88 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -19,7 +19,7 @@ class Template * * @var array */ - public $data = array(); + public $data = []; /** * A translator instance configured to work with this template. @@ -168,22 +168,22 @@ class Template $loader = new TemplateLoader(); $templateDirs = $this->findThemeTemplateDirs(); if ($this->module) { - $templateDirs[] = array($this->module => TemplateLoader::getModuleTemplateDir($this->module)); + $templateDirs[] = [$this->module => TemplateLoader::getModuleTemplateDir($this->module)]; } if ($this->theme['module']) { try { - $templateDirs[] = array( + $templateDirs[] = [ $this->theme['module'] => TemplateLoader::getModuleTemplateDir($this->theme['module']) - ); + ]; } catch (\InvalidArgumentException $e) { // either the module is not enabled or it has no "templates" directory, ignore } } // default, themeless templates are checked last - $templateDirs[] = array( + $templateDirs[] = [ \Twig_Loader_Filesystem::MAIN_NAMESPACE => $this->configuration->resolvePath('templates') - ); + ]; foreach ($templateDirs as $entry) { $loader->addPath($entry[key($entry)], key($entry)); } @@ -213,20 +213,20 @@ class Template $this->localization->addModuleDomain($this->theme['module']); } - $options = array( + $options = [ 'cache' => $cache, 'auto_reload' => $auto_reload, - 'translation_function' => array('\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'), - 'translation_function_plural' => array('\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'), - ); + 'translation_function' => ['\SimpleSAML\Locale\Translate', 'translateSingularNativeGettext'], + 'translation_function_plural' => ['\SimpleSAML\Locale\Translate', 'translatePluralNativeGettext'], + ]; // set up translation if ($this->localization->i18nBackend === \SimpleSAML\Locale\Localization::GETTEXT_I18N_BACKEND) { - $options['translation_function'] = array('\SimpleSAML\Locale\Translate', 'translateSingularGettext'); - $options['translation_function_plural'] = array( + $options['translation_function'] = ['\SimpleSAML\Locale\Translate', 'translateSingularGettext']; + $options['translation_function_plural'] = [ '\SimpleSAML\Locale\Translate', 'translatePluralGettext' - ); + ]; } // TODO: add a branch for the old SimpleSAMLphp backend $twig = new Twig_Environment($loader, $options); @@ -253,8 +253,8 @@ class Template $twig->addFilter( new \Twig_SimpleFilter( 'translateFromArray', - array('\SimpleSAML\Locale\Translate', 'translateFromArray'), - array('needs_context' => true) + ['\SimpleSAML\Locale\Translate', 'translateFromArray'], + ['needs_context' => true] ) ); @@ -274,7 +274,7 @@ class Template { if ($this->theme['module'] === null) { // no module involved - return array(); + return []; } // setup directories & namespaces @@ -284,10 +284,10 @@ class Template // no subdirectories in the theme directory, nothing to do here // this is probably wrong, log a message \SimpleSAML\Logger::warning('Empty theme directory for theme "'.$this->theme['name'].'".'); - return array(); + return []; } - $themeTemplateDirs = array(); + $themeTemplateDirs = []; foreach ($subdirs as $entry) { // discard anything that's not a directory. Expression is negated to profit from lazy evaluation if (!($entry !== '.' && $entry !== '..' && is_dir($themeDir.'/'.$entry))) { @@ -296,7 +296,7 @@ class Template // set correct name for the default namespace $ns = ($entry === 'default') ? \Twig_Loader_Filesystem::MAIN_NAMESPACE : $entry; - $themeTemplateDirs[] = array($ns => $themeDir.'/'.$entry); + $themeTemplateDirs[] = [$ns => $themeDir.'/'.$entry]; } return $themeTemplateDirs; } @@ -355,7 +355,7 @@ class Template $langmap = null; if (count($languages) > 1) { $parameterName = $this->getTranslator()->getLanguage()->getLanguageParameterName(); - $langmap = array(); + $langmap = []; foreach ($languages as $lang => $current) { $lang = strtolower($lang); $langname = $this->translator->getLanguage()->getLanguageLocalizedName($lang); @@ -363,13 +363,13 @@ class Template if (!$current) { $url = htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters( '', - array($parameterName => $lang) + [$parameterName => $lang] )); } - $langmap[$lang] = array( + $langmap[$lang] = [ 'name' => $langname, 'url' => $url, - ); + ]; } } return $langmap; @@ -434,7 +434,7 @@ class Template private function findModuleAndTemplateName($template) { $tmp = explode(':', $template, 2); - return (count($tmp) === 2) ? array($tmp[0], $tmp[1]) : array(null, $tmp[0]); + return (count($tmp) === 2) ? [$tmp[0], $tmp[1]] : [null, $tmp[0]]; } @@ -721,9 +721,9 @@ class Template */ public function t( $tag, - $replacements = array(), + $replacements = [], $fallbackdefault = true, - $oldreplacements = array(), + $oldreplacements = [], $striptags = false ) { return $this->translator->t($tag, $replacements, $fallbackdefault, $oldreplacements, $striptags); diff --git a/lib/SimpleSAML/XHTML/TemplateLoader.php b/lib/SimpleSAML/XHTML/TemplateLoader.php index ffa7e4a96..c5090d554 100644 --- a/lib/SimpleSAML/XHTML/TemplateLoader.php +++ b/lib/SimpleSAML/XHTML/TemplateLoader.php @@ -39,11 +39,11 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader if (strpos($name, ':')) { // we have our old SSP format list($namespace, $shortname) = explode(':', $name, 2); - $shortname = strtr($shortname, array( + $shortname = strtr($shortname, [ '.tpl.php' => '.twig', '.php' => '.twig', - )); - return array($namespace, $shortname); + ]); + return [$namespace, $shortname]; } return [$default, $name]; } diff --git a/lib/SimpleSAML/XML/Errors.php b/lib/SimpleSAML/XML/Errors.php index 351ca009f..6f6d228ef 100644 --- a/lib/SimpleSAML/XML/Errors.php +++ b/lib/SimpleSAML/XML/Errors.php @@ -19,7 +19,7 @@ class Errors /** * @var array This is an stack of error logs. The topmost element is the one we are currently working on. */ - private static $errorStack = array(); + private static $errorStack = []; /** * @var bool This is the xml error state we had before we began logging. @@ -66,7 +66,7 @@ class Errors } // Add a new level to the error stack - self::$errorStack[] = array(); + self::$errorStack[] = []; } @@ -81,7 +81,7 @@ class Errors // Check whether the error access functions are present if (!function_exists('libxml_use_internal_errors')) { // Pretend that no errors occurred - return array(); + return []; } // Add any errors which may have occurred diff --git a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php index 6c4fe7c7b..221951d9b 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php @@ -41,7 +41,7 @@ class AuthnRequest $desturl = $idpmetadata->getDefaultEndpoint( 'SingleSignOnService', - array('urn:mace:shibboleth:1.0:profiles:AuthnRequest') + ['urn:mace:shibboleth:1.0:profiles:AuthnRequest'] ); $desturl = $desturl['Location']; diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index 20b1db4b7..8b6c1fb6e 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -91,7 +91,7 @@ class AuthnResponse } // Validate the signature - $this->validator = new Validator($this->dom, array('ResponseID', 'AssertionID')); + $this->validator = new Validator($this->dom, ['ResponseID', 'AssertionID']); // Get the issuer of the response $issuer = $this->getIssuer(); @@ -102,7 +102,7 @@ class AuthnResponse $publicKeys = $md->getPublicKeys('signing'); if (!empty($publicKeys)) { - $certFingerprints = array(); + $certFingerprints = []; foreach ($publicKeys as $key) { if ($key['type'] !== 'X509Certificate') { continue; @@ -208,10 +208,10 @@ class AuthnResponse $base64 = isset($md['base64attributes']) ? $md['base64attributes'] : false; if (!($this->dom instanceof \DOMDocument)) { - return array(); + return []; } - $attributes = array(); + $attributes = []; $assertions = $this->doXPathQuery('/shibp:Response/shib:Assertion'); @@ -255,7 +255,7 @@ class AuthnResponse } if (!array_key_exists($name, $attributes)) { - $attributes[$name] = array(); + $attributes[$name] = []; } if ($base64) { @@ -287,7 +287,7 @@ class AuthnResponse public function getNameID() { - $nameID = array(); + $nameID = []; $query = '/shibp:Response/shib:Assertion/shib:AuthenticationStatement/shib:Subject/shib:NameIdentifier'; $nodelist = $this->doXPathQuery($query); @@ -320,7 +320,7 @@ class AuthnResponse } elseif ($idp->hasValue('scopedattributes')) { $scopedAttributes = $idp->getArray('scopedattributes'); } else { - $scopedAttributes = array(); + $scopedAttributes = []; } $id = Random::generateID(); diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php index 3e3c86c09..26f46ab62 100644 --- a/lib/SimpleSAML/XML/Signer.php +++ b/lib/SimpleSAML/XML/Signer.php @@ -39,7 +39,7 @@ class Signer /** * @var array Extra certificates which should be included in the response. */ - private $extraCertificates = array(); + private $extraCertificates = []; /** @@ -58,7 +58,7 @@ class Signer * * @param array $options Associative array with options for the constructor. Defaults to an empty array. */ - public function __construct($options = array()) + public function __construct($options = []) { assert(is_array($options)); @@ -102,7 +102,7 @@ class Signer assert(is_array($privatekey)); assert(array_key_exists('PEM', $privatekey)); - $this->privateKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'private')); + $this->privateKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'private']); if (array_key_exists('password', $privatekey)) { $this->privateKey->passphrase = $privatekey['password']; } @@ -143,7 +143,7 @@ class Signer throw new \Exception('Unable to read private key file "'.$keyFile.'".'); } - $privatekey = array('PEM' => $keyData); + $privatekey = ['PEM' => $keyData]; if ($pass !== null) { $privatekey['password'] = $pass; } @@ -284,15 +284,15 @@ class Signer $objXMLSecDSig = new XMLSecurityDSig(); $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); - $options = array(); + $options = []; if (!empty($this->idAttrName)) { $options['id_name'] = $this->idAttrName; } $objXMLSecDSig->addReferenceList( - array($node), + [$node], XMLSecurityDSig::SHA256, - array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), + ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N], $options ); diff --git a/lib/SimpleSAML/XML/Validator.php b/lib/SimpleSAML/XML/Validator.php index bbf6acdf3..8dd46f897 100644 --- a/lib/SimpleSAML/XML/Validator.php +++ b/lib/SimpleSAML/XML/Validator.php @@ -52,9 +52,9 @@ class Validator if ($publickey === null) { $publickey = false; } elseif (is_string($publickey)) { - $publickey = array( + $publickey = [ 'PEM' => $publickey, - ); + ]; } else { assert($publickey === false || is_array($publickey)); } @@ -249,7 +249,7 @@ class Validator } if (!is_array($fingerprints)) { - $fingerprints = array($fingerprints); + $fingerprints = [$fingerprints]; } // Normalize the fingerprints @@ -327,7 +327,7 @@ class Validator while (openssl_error_string() !== false) { } - $res = openssl_x509_checkpurpose($certificate, X509_PURPOSE_ANY, array($caFile)); + $res = openssl_x509_checkpurpose($certificate, X509_PURPOSE_ANY, [$caFile]); $errors = ''; // Log errors @@ -361,11 +361,11 @@ class Validator assert(is_string($certificate)); assert(is_string($caFile)); - $command = array( + $command = [ 'openssl', 'verify', '-CAfile', $caFile, '-purpose', 'any', - ); + ]; $cmdline = ''; foreach ($command as $c) { @@ -373,10 +373,10 @@ class Validator } $cmdline .= '2>&1'; - $descSpec = array( - 0 => array('pipe', 'r'), - 1 => array('pipe', 'w'), - ); + $descSpec = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + ]; $process = proc_open($cmdline, $descSpec, $pipes); if (!is_resource($process)) { throw new \Exception('Failed to execute verification command: '.$cmdline); diff --git a/lib/_autoload_modules.php b/lib/_autoload_modules.php index 1df2e4acc..41ca267a9 100644 --- a/lib/_autoload_modules.php +++ b/lib/_autoload_modules.php @@ -33,7 +33,7 @@ function temporaryLoader($class) $original = $class; // list of classes that have been renamed or moved - $renamed = array( + $renamed = [ 'SimpleSAML_Metadata_MetaDataStorageHandlerMDX' => 'SimpleSAML_Metadata_Sources_MDQ', 'SimpleSAML_Logger_LoggingHandlerSyslog' => 'SimpleSAML_Logger_SyslogLoggingHandler', 'SimpleSAML_Logger_LoggingHandlerErrorLog' => 'SimpleSAML_Logger_ErrorLogLoggingHandler', @@ -42,7 +42,7 @@ function temporaryLoader($class) 'SimpleSAML_IdP_LogoutHandler' => 'SimpleSAML_IdP_LogoutHandlerInterface', 'SimpleSAML_IdP_LogoutIFrame' => 'SimpleSAML_IdP_IFrameLogoutHandler', 'SimpleSAML_IdP_LogoutTraditional' => 'SimpleSAML_IdP_TraditionalLogoutHandler', - ); + ]; if (array_key_exists($class, $renamed)) { // the class has been renamed, try to load it and create an alias $class = $renamed[$class]; diff --git a/metadata-templates/adfs-idp-hosted.php b/metadata-templates/adfs-idp-hosted.php index 895dd23c4..dd8134069 100644 --- a/metadata-templates/adfs-idp-hosted.php +++ b/metadata-templates/adfs-idp-hosted.php @@ -1,12 +1,12 @@ <?php -$metadata['__DYNAMIC:1__'] = array( +$metadata['__DYNAMIC:1__'] = [ 'host' => '__DEFAULT__', 'privatekey' => 'server.pem', 'certificate' => 'server.crt', 'auth' => 'example-userpass', - 'authproc' => array( + 'authproc' => [ // Convert LDAP names to WS-Fed Claims. - 100 => array('class' => 'core:AttributeMap', 'name2claim'), - ), -); + 100 => ['class' => 'core:AttributeMap', 'name2claim'], + ], +]; diff --git a/metadata-templates/adfs-sp-remote.php b/metadata-templates/adfs-sp-remote.php index c72f51442..ec2d79c91 100644 --- a/metadata-templates/adfs-sp-remote.php +++ b/metadata-templates/adfs-sp-remote.php @@ -1,12 +1,12 @@ <?php -$metadata['urn:federation:localhost'] = array( +$metadata['urn:federation:localhost'] = [ 'prp' => 'https://localhost/adfs/ls/', 'simplesaml.nameidattribute' => 'uid', - 'authproc' => array( - 50 => array( + 'authproc' => [ + 50 => [ 'class' => 'core:AttributeLimit', 'cn', 'mail', 'uid', 'eduPersonAffiliation', - ), - ), -); + ], + ], +]; diff --git a/metadata-templates/saml20-idp-hosted.php b/metadata-templates/saml20-idp-hosted.php index 431e6e909..582af8ee9 100644 --- a/metadata-templates/saml20-idp-hosted.php +++ b/metadata-templates/saml20-idp-hosted.php @@ -5,7 +5,7 @@ * See: https://simplesamlphp.org/docs/stable/simplesamlphp-reference-idp-hosted */ -$metadata['__DYNAMIC:1__'] = array( +$metadata['__DYNAMIC:1__'] = [ /* * The hostname of the server (VHOST) that will use this SAML entity. * @@ -48,4 +48,4 @@ $metadata['__DYNAMIC:1__'] = array( ), ), */ -); +]; diff --git a/metadata-templates/saml20-sp-remote.php b/metadata-templates/saml20-sp-remote.php index c0f8b02bb..92ff45da1 100644 --- a/metadata-templates/saml20-sp-remote.php +++ b/metadata-templates/saml20-sp-remote.php @@ -8,10 +8,10 @@ /* * Example SimpleSAMLphp SAML 2.0 SP */ -$metadata['https://saml2sp.example.org'] = array( +$metadata['https://saml2sp.example.org'] = [ 'AssertionConsumerService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp', 'SingleLogoutService' => 'https://saml2sp.example.org/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp', -); +]; /* * This example shows an example config that works with G Suite (Google Apps) for education. @@ -19,14 +19,14 @@ $metadata['https://saml2sp.example.org'] = array( * at G Suite. In example, if your Google account is foo.com, and you have a user that has an email john@foo.com, then you * must set the simplesaml.nameidattribute to be the name of an attribute that for this user has the value of 'john'. */ -$metadata['google.com'] = array( +$metadata['google.com'] = [ 'AssertionConsumerService' => 'https://www.google.com/a/g.feide.no/acs', 'NameIDFormat' => 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress', 'simplesaml.nameidattribute' => 'uid', 'simplesaml.attributes' => false, -); +]; -$metadata['https://legacy.example.edu'] = array( +$metadata['https://legacy.example.edu'] = [ 'AssertionConsumerService' => 'https://legacy.example.edu/saml/acs', /* * Currently, SimpleSAMLphp defaults to the SHA-256 hashing algorithm. @@ -38,4 +38,4 @@ $metadata['https://legacy.example.edu'] = array( * http://csrc.nist.gov/publications/nistpubs/800-131A/sp800-131A.pdf */ //'signature.algorithm' => 'http://www.w3.org/2000/09/xmldsig#rsa-sha1', -); +]; diff --git a/metadata-templates/shib13-idp-hosted.php b/metadata-templates/shib13-idp-hosted.php index 56b048284..28ccc42b3 100644 --- a/metadata-templates/shib13-idp-hosted.php +++ b/metadata-templates/shib13-idp-hosted.php @@ -5,7 +5,7 @@ * See: https://simplesamlphp.org/docs/stable/simplesamlphp-reference-idp-hosted */ -$metadata['__DYNAMIC:1__'] = array( +$metadata['__DYNAMIC:1__'] = [ /* * The hostname of the server (VHOST) that will use this SAML entity. * @@ -22,4 +22,4 @@ $metadata['__DYNAMIC:1__'] = array( * 'config/authsources.php'. */ 'auth' => 'example-userpass', -); +]; diff --git a/metadata-templates/shib13-sp-hosted.php b/metadata-templates/shib13-sp-hosted.php index 38536ceb0..e3581c9b8 100644 --- a/metadata-templates/shib13-sp-hosted.php +++ b/metadata-templates/shib13-sp-hosted.php @@ -8,6 +8,6 @@ /* * Example of hosted Shibboleth 1.3 SP. */ -$metadata['__DYNAMIC:1__'] = array( +$metadata['__DYNAMIC:1__'] = [ 'host' => '__DEFAULT__', -); +]; diff --git a/metadata-templates/shib13-sp-remote.php b/metadata-templates/shib13-sp-remote.php index 73df2dae9..8d6a32479 100644 --- a/metadata-templates/shib13-sp-remote.php +++ b/metadata-templates/shib13-sp-remote.php @@ -8,9 +8,9 @@ /* * This is just an example: */ -$metadata['https://sp.shiblab.feide.no'] = array( +$metadata['https://sp.shiblab.feide.no'] = [ 'AssertionConsumerService' => 'http://sp.shiblab.feide.no/Shibboleth.sso/SAML/POST', 'audience' => 'urn:mace:feide:shiblab', 'base64attributes' => false, -); +]; diff --git a/metadata-templates/wsfed-idp-remote.php b/metadata-templates/wsfed-idp-remote.php index a6d20ef4a..214679ce3 100644 --- a/metadata-templates/wsfed-idp-remote.php +++ b/metadata-templates/wsfed-idp-remote.php @@ -3,7 +3,7 @@ * WS-Federation remote IdP metadata for SimpleSAMLphp. */ -$metadata['urn:federation:pingfederate:localhost'] = array( +$metadata['urn:federation:pingfederate:localhost'] = [ 'prp' => 'https://localhost:9031/idp/prp.wsf', 'certificate' => 'pingfed-localhost.pem', -); +]; diff --git a/metadata-templates/wsfed-sp-hosted.php b/metadata-templates/wsfed-sp-hosted.php index 17e3e1252..5ebdf21c1 100644 --- a/metadata-templates/wsfed-sp-hosted.php +++ b/metadata-templates/wsfed-sp-hosted.php @@ -6,6 +6,6 @@ * - host */ -$metadata['__DYNAMIC:1__'] = array( +$metadata['__DYNAMIC:1__'] = [ 'host' => '__DEFAULT__', -); +]; diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index 6a09ff988..691480b7b 100644 --- a/modules/adfs/lib/IdP/ADFS.php +++ b/modules/adfs/lib/IdP/ADFS.php @@ -23,14 +23,14 @@ class ADFS throw new \SimpleSAML\Error\Error('PROCESSAUTHNREQUEST', $exception); } - $state = array( - 'Responder' => array('\SimpleSAML\Module\adfs\IdP\ADFS', 'sendResponse'), + $state = [ + 'Responder' => ['\SimpleSAML\Module\adfs\IdP\ADFS', 'sendResponse'], 'SPMetadata' => $spMetadata->toArray(), 'ForceAuthn' => false, 'isPassive' => false, 'adfs:wctx' => $requestid, 'adfs:wreply' => false - ); + ]; if (isset($query['wreply']) && !empty($query['wreply'])) { $state['adfs:wreply'] = \SimpleSAML\Utils\HTTP::checkURLAllowed($query['wreply']); @@ -109,18 +109,18 @@ MSG; private static function signResponse($response, $key, $cert, $algo) { $objXMLSecDSig = new XMLSecurityDSig(); - $objXMLSecDSig->idKeys = array('AssertionID'); + $objXMLSecDSig->idKeys = ['AssertionID']; $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); $responsedom = \SAML2\DOMDocumentFactory::fromString(str_replace("\r", "", $response)); $firstassertionroot = $responsedom->getElementsByTagName('Assertion')->item(0); $objXMLSecDSig->addReferenceList( - array($firstassertionroot), + [$firstassertionroot], XMLSecurityDSig::SHA256, - array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), - array('id_name' => 'AssertionID') + ['http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N], + ['id_name' => 'AssertionID'] ); - $objKey = new XMLSecurityKey($algo, array('type' => 'private')); + $objKey = new XMLSecurityKey($algo, ['type' => 'private']); $objKey->loadKey($key, true); $objXMLSecDSig->sign($objKey); if ($cert) { @@ -168,11 +168,11 @@ MSG; $idpMetadata = $idp->getConfig(); $idpEntityId = $idpMetadata->getString('entityid'); - $idp->addAssociation(array( + $idp->addAssociation([ 'id' => 'adfs:'.$spEntityId, 'Handler' => '\SimpleSAML\Module\adfs\IdP\ADFS', 'adfs:entityID' => $spEntityId, - )); + ]); $assertionLifetime = $spMetadata->getInteger('assertion.lifetime', null); if ($assertionLifetime === null) { @@ -213,9 +213,9 @@ MSG; assert(false); } - $state = array( - 'Responder' => array('\SimpleSAML\Module\adfs\IdP\ADFS', 'sendLogoutResponse'), - ); + $state = [ + 'Responder' => ['\SimpleSAML\Module\adfs\IdP\ADFS', 'sendLogoutResponse'], + ]; $assocId = null; // TODO: verify that this is really no problem for: // a) SSP, because there's no caller SP. diff --git a/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php b/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php index 30f2f62d4..55a802d50 100644 --- a/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php +++ b/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php @@ -15,7 +15,7 @@ class SecurityTokenServiceType extends \SAML2\XML\md\RoleDescriptor * * @var array */ - public $protocolSupportEnumeration = array(FedConst::NS_FED); + public $protocolSupportEnumeration = [FedConst::NS_FED]; /** * The Location of Services. diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index b7a0f9721..473af96dc 100644 --- a/modules/adfs/www/idp/metadata.php +++ b/modules/adfs/www/idp/metadata.php @@ -18,18 +18,18 @@ try { $_GET['idpentityid'] : $metadata->getMetaDataCurrentEntityID('adfs-idp-hosted'); $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'adfs-idp-hosted'); - $availableCerts = array(); + $availableCerts = []; - $keys = array(); + $keys = []; $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, false, 'new_'); if ($certInfo !== null) { $availableCerts['new_idp.crt'] = $certInfo; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => true, 'X509Certificate' => $certInfo['certData'], - ); + ]; $hasNewCert = true; } else { $hasNewCert = false; @@ -37,42 +37,42 @@ try { $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true); $availableCerts['idp.crt'] = $certInfo; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => ($hasNewCert ? false : true), 'X509Certificate' => $certInfo['certData'], - ); + ]; if ($idpmeta->hasValue('https.certificate')) { $httpsCert = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true, 'https.'); assert(isset($httpsCert['certData'])); $availableCerts['https.crt'] = $httpsCert; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => false, 'X509Certificate' => $httpsCert['certData'], - ); + ]; } $adfs_service_location = \SimpleSAML\Module::getModuleURL('adfs').'/idp/prp.php'; - $metaArray = array( + $metaArray = [ 'metadata-set' => 'adfs-idp-remote', 'entityid' => $idpentityid, - 'SingleSignOnService' => array( - 0 => array( + 'SingleSignOnService' => [ + 0 => [ 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'Location' => $adfs_service_location - ) - ), - 'SingleLogoutService' => array( - 0 => array( + ] + ], + 'SingleLogoutService' => [ + 0 => [ 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'Location' => $adfs_service_location - ) - ), - ); + ] + ], + ]; if (count($keys) === 1) { $metaArray['certData'] = $keys[0]['X509Certificate']; @@ -125,11 +125,11 @@ try { $metaBuilder->addOrganizationInfo($metaArray); $technicalContactEmail = $config->getString('technicalcontact_email', null); if ($technicalContactEmail && $technicalContactEmail !== 'na@example.org') { - $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array( + $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact([ 'emailAddress' => $technicalContactEmail, 'name' => $config->getString('technicalcontact_name', null), 'contactType' => 'technical', - ))); + ])); } $output_xhtml = array_key_exists('output', $_GET) && $_GET['output'] == 'xhtml'; $metaxml = $metaBuilder->getEntityDescriptorText($output_xhtml); @@ -147,7 +147,7 @@ try { $t->data['clipboard.js'] = true; $t->data['available_certs'] = $availableCerts; - $certdata = array(); + $certdata = []; foreach (array_keys($availableCerts) as $availableCert) { $certdata[$availableCert]['name'] = $availableCert; $certdata[$availableCert]['url'] = \SimpleSAML\Module::getModuleURL('saml/idp/certs.php'). diff --git a/modules/authX509/lib/Auth/Process/ExpiryWarning.php b/modules/authX509/lib/Auth/Process/ExpiryWarning.php index 6943e6dfd..1b9c1ca87 100644 --- a/modules/authX509/lib/Auth/Process/ExpiryWarning.php +++ b/modules/authX509/lib/Auth/Process/ExpiryWarning.php @@ -93,6 +93,6 @@ class ExpiryWarning extends \SimpleSAML\Auth\ProcessingFilter // Save state and redirect $id = \SimpleSAML\Auth\State::saveState($state, 'warning:expire'); $url = \SimpleSAML\Module::getModuleURL('authX509/expirywarning.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/authX509/lib/Auth/Source/X509userCert.php b/modules/authX509/lib/Auth/Source/X509userCert.php index 2771979b8..4605c0ee9 100644 --- a/modules/authX509/lib/Auth/Source/X509userCert.php +++ b/modules/authX509/lib/Auth/Source/X509userCert.php @@ -14,13 +14,13 @@ class X509userCert extends \SimpleSAML\Auth\Source /** * x509 attributes to use from the certificate for searching the user in the LDAP directory. */ - private $x509attributes = array('UID' => 'uid'); + private $x509attributes = ['UID' => 'uid']; /** * LDAP attribute containing the user certificate. */ - private $ldapusercert = array('userCertificate;binary'); + private $ldapusercert = ['userCertificate;binary']; /** @@ -159,7 +159,7 @@ class X509userCert extends \SimpleSAML\Auth\Source } - $merged_ldapcerts = array(); + $merged_ldapcerts = []; foreach ($this->ldapusercert as $attr) { $merged_ldapcerts = array_merge($merged_ldapcerts, $ldap_certs[$attr]); } diff --git a/modules/authX509/templates/X509warning.php b/modules/authX509/templates/X509warning.php index a3daa8064..a25385ec9 100644 --- a/modules/authX509/templates/X509warning.php +++ b/modules/authX509/templates/X509warning.php @@ -10,14 +10,14 @@ * @package SimpleSAMLphp */ -$warning = $this->t('{authX509:X509warning:warning}', array( +$warning = $this->t('{authX509:X509warning:warning}', [ '%daysleft%' => htmlspecialchars($this->data['daysleft']), -)); +]); if ($this->data['renewurl']) { - $warning .= " ".$this->t('{authX509:X509warning:renew_url}', array( + $warning .= " ".$this->t('{authX509:X509warning:renew_url}', [ '%renewurl%' => $this->data['renewurl'], - )); + ]); } else { $warning .= " ".$this->t('{authX509:X509warning:renew}'); } diff --git a/modules/authX509/www/expirywarning.php b/modules/authX509/www/expirywarning.php index b5b445ca1..7bd36030d 100644 --- a/modules/authX509/www/expirywarning.php +++ b/modules/authX509/www/expirywarning.php @@ -24,7 +24,7 @@ $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'authX509:X509warning.php'); $t->data['target'] = \SimpleSAML\Module::getModuleURL('authX509/expirywarning.php'); -$t->data['data'] = array('StateId' => $id); +$t->data['data'] = ['StateId' => $id]; $t->data['daysleft'] = $state['daysleft']; $t->data['renewurl'] = $state['renewurl']; $t->data['errorcodes'] = \SimpleSAML\Error\ErrorCodes::getAllErrorCodeMessages(); diff --git a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php index 98391a72e..42ef300f3 100644 --- a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php +++ b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php @@ -67,7 +67,7 @@ class OTP2YubiPrefix extends \SimpleSAML\Auth\ProcessingFilter $token_size = 32; $identity = substr($otp, 0, strlen($otp) - $token_size); - $attributes['yubiPrefix'] = array($identity); + $attributes['yubiPrefix'] = [$identity]; \SimpleSAML\Logger::info( 'OTP2YubiPrefix: otp: '.$otp.' identity: '.$identity.' (otp keys: '.implode(',', array_keys($otps)).')' diff --git a/modules/authYubiKey/lib/Auth/Source/YubiKey.php b/modules/authYubiKey/lib/Auth/Source/YubiKey.php index 0c2a7bb15..65ddf8490 100644 --- a/modules/authYubiKey/lib/Auth/Source/YubiKey.php +++ b/modules/authYubiKey/lib/Auth/Source/YubiKey.php @@ -107,7 +107,7 @@ class YubiKey extends \SimpleSAML\Auth\Source $id = \SimpleSAML\Auth\State::saveState($state, self::STAGEID); $url = \SimpleSAML\Module::getModuleURL('authYubiKey/yubikeylogin.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('AuthState' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['AuthState' => $id]); } @@ -193,7 +193,7 @@ class YubiKey extends \SimpleSAML\Auth\Source $yubi = new \Auth_Yubico($this->yubi_id, $this->yubi_key); $yubi->verify($otp); $uid = self::getYubiKeyPrefix($otp); - $attributes = array('uid' => array($uid)); + $attributes = ['uid' => [$uid]]; } catch (\Exception $e) { \SimpleSAML\Logger::info( 'YubiKey:'.$this->authId.': Validation error (otp '.$otp.'), debug output: '.$yubi->getLastResponse() diff --git a/modules/authYubiKey/libextinc/Yubico.php b/modules/authYubiKey/libextinc/Yubico.php index e9af36322..d6f4c709a 100644 --- a/modules/authYubiKey/libextinc/Yubico.php +++ b/modules/authYubiKey/libextinc/Yubico.php @@ -136,7 +136,7 @@ class Auth_Yubico // Verify signature if ($this->key <> "") { $rows = explode("\r\n", $responseMsg); - $response = array(); + $response = []; foreach ($rows as $val) { // = is also used in BASE64 encoding so we only replace the first = by # which is not used in BASE64 $val = preg_replace('/=/', '#', $val, 1); diff --git a/modules/authYubiKey/www/yubikeylogin.php b/modules/authYubiKey/www/yubikeylogin.php index 3c432ff8a..c48428251 100644 --- a/modules/authYubiKey/www/yubikeylogin.php +++ b/modules/authYubiKey/www/yubikeylogin.php @@ -30,7 +30,7 @@ if (array_key_exists('otp', $_REQUEST)) { $t->data['header'] = $translator->t('{authYubiKey:yubikey:header}'); $t->data['autofocus'] = 'otp'; $t->data['errorCode'] = $errorCode; -$t->data['stateParams'] = array('AuthState' => $authStateId); +$t->data['stateParams'] = ['AuthState' => $authStateId]; $t->data['logoUrl'] = \SimpleSAML\Module::getModuleURL('authYubiKey/resources/logo.jpg'); $t->data['devicepicUrl'] = \SimpleSAML\Module::getModuleURL('authYubiKey/resources/yubikey.jpg'); $t->show(); diff --git a/modules/authcrypt/lib/Auth/Source/Hash.php b/modules/authcrypt/lib/Auth/Source/Hash.php index bcca962ce..aa17adcf6 100644 --- a/modules/authcrypt/lib/Auth/Source/Hash.php +++ b/modules/authcrypt/lib/Auth/Source/Hash.php @@ -37,7 +37,7 @@ class Hash extends \SimpleSAML\Module\core\Auth\UserPassBase // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $this->users = array(); + $this->users = []; // Validate and parse our configuration foreach ($config as $userpass => $attributes) { diff --git a/modules/authcrypt/lib/Auth/Source/Htpasswd.php b/modules/authcrypt/lib/Auth/Source/Htpasswd.php index 86fcc0b15..03084b08b 100644 --- a/modules/authcrypt/lib/Auth/Source/Htpasswd.php +++ b/modules/authcrypt/lib/Auth/Source/Htpasswd.php @@ -25,7 +25,7 @@ class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase * * @var array */ - private $attributes = array(); + private $attributes = []; /** @@ -44,7 +44,7 @@ class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $this->users = array(); + $this->users = []; if (!$htpasswd = file_get_contents($config['htpasswd_file'])) { throw new \Exception('Could not read '.$config['htpasswd_file']); @@ -88,7 +88,7 @@ class Htpasswd extends \SimpleSAML\Module\core\Auth\UserPassBase $crypted = $matches[1]; // This is about the only attribute we can add - $attributes = array_merge(array('uid' => array($username)), $this->attributes); + $attributes = array_merge(['uid' => [$username]], $this->attributes); // Traditional crypt(3) if (\SimpleSAML\Utils\Crypto::secureCompare($crypted, crypt($password, $crypted))) { diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index afb1ce9c5..ea661c7a9 100644 --- a/modules/authfacebook/extlibinc/base_facebook.php +++ b/modules/authfacebook/extlibinc/base_facebook.php @@ -134,24 +134,24 @@ abstract class BaseFacebook /** * Default options for curl. */ - public static $CURL_OPTS = array( + public static $CURL_OPTS = [ CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'facebook-php-3.2', - ); + ]; /** * Maps aliases to Facebook domains. */ - public static $DOMAIN_MAP = array( + public static $DOMAIN_MAP = [ 'api' => 'https://api.facebook.com/', 'api_video' => 'https://api-video.facebook.com/', 'api_read' => 'https://api-read.facebook.com/', 'graph' => 'https://graph.facebook.com/', 'graph_video' => 'https://graph-video.facebook.com/', 'www' => 'https://www.facebook.com/', - ); + ]; /** * The Application ID. @@ -362,12 +362,12 @@ abstract class BaseFacebook // directly, since response isn't JSON format $access_token_response = $this->_oauthRequest( $this->getUrl('graph', '/oauth/access_token'), - $params = array( + $params = [ 'client_id' => $this->getAppId(), 'client_secret' => $this->getAppSecret(), 'grant_type' => 'fb_exchange_token', 'fb_exchange_token' => $this->getAccessToken(), - ) + ] ); } catch (FacebookApiException $e) { // most likely that user very recently revoked authorization @@ -379,7 +379,7 @@ abstract class BaseFacebook return false; } - $response_params = array(); + $response_params = []; parse_str($access_token_response, $response_params); if (!isset($response_params['access_token'])) { @@ -592,7 +592,7 @@ abstract class BaseFacebook * @param array $params Provide custom parameters * @return string The URL for the login flow */ - public function getLoginUrl($params = array()) + public function getLoginUrl($params = []) { $this->establishCSRFTokenState(); $currentUrl = $this->getCurrentUrl(); @@ -607,11 +607,11 @@ abstract class BaseFacebook 'www', 'dialog/oauth', array_merge( - array( + [ 'client_id' => $this->getAppId(), 'redirect_uri' => $currentUrl, // possibly overwritten 'state' => $this->state - ), + ], $params ) ); @@ -626,15 +626,15 @@ abstract class BaseFacebook * @param array $params Provide custom parameters * @return string The URL for the logout flow */ - public function getLogoutUrl($params = array()) + public function getLogoutUrl($params = []) { return $this->getUrl( 'www', 'logout.php', - array_merge(array( + array_merge([ 'next' => $this->getCurrentUrl(), 'access_token' => $this->getUserAccessToken(), - ), $params) + ], $params) ); } @@ -649,18 +649,18 @@ abstract class BaseFacebook * @param array $params Provide custom parameters * @return string The URL for the logout flow */ - public function getLoginStatusUrl($params = array()) + public function getLoginStatusUrl($params = []) { return $this->getUrl( 'www', 'extern/login_status.php', - array_merge(array( + array_merge([ 'api_key' => $this->getAppId(), 'no_session' => $this->getCurrentUrl(), 'no_user' => $this->getCurrentUrl(), 'ok_session' => $this->getCurrentUrl(), 'session_version' => 3, - ), $params) + ], $params) ); } @@ -675,7 +675,7 @@ abstract class BaseFacebook if (is_array($args[0])) { return $this->_restserver($args[0]); } else { - return call_user_func_array(array($this, '_graph'), $args); + return call_user_func_array([$this, '_graph'], $args); } } @@ -807,12 +807,12 @@ abstract class BaseFacebook $access_token_response = $this->_oauthRequest( $this->getUrl('graph', '/oauth/access_token'), - $params = array( + $params = [ 'client_id' => $this->getAppId(), 'client_secret' => $this->getAppSecret(), 'redirect_uri' => $redirect_uri, 'code' => $code - ) + ] ); } catch (FacebookApiException $e) { self::errorLog($e->getMessage()); @@ -896,7 +896,7 @@ abstract class BaseFacebook * @return mixed The decoded response object * @throws FacebookApiException */ - protected function _graph($path, $method = 'GET', $params = array()) + protected function _graph($path, $method = 'GET', $params = []) { if (is_array($method) && empty($params)) { $params = $method; @@ -982,7 +982,7 @@ abstract class BaseFacebook $existing_headers[] = 'Expect:'; $opts[CURLOPT_HTTPHEADER] = $existing_headers; } else { - $opts[CURLOPT_HTTPHEADER] = array('Expect:'); + $opts[CURLOPT_HTTPHEADER] = ['Expect:']; } curl_setopt_array($ch, $opts); @@ -1001,7 +1001,7 @@ abstract class BaseFacebook // fall back to IPv6 and the error EHOSTUNREACH is returned by the // operating system if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) { - $matches = array(); + $matches = []; $regex = '/Failed to connect to ([^:].*): Network is unreachable/'; if (preg_match($regex, curl_error($ch), $matches)) { if (strlen(@inet_pton($matches[1])) === 16) { @@ -1015,13 +1015,13 @@ abstract class BaseFacebook } if ($result === false) { - $e = new FacebookApiException(array( + $e = new FacebookApiException([ 'error_code' => curl_errno($ch), - 'error' => array( + 'error' => [ 'message' => curl_error($ch), 'type' => 'CurlException', - ), - )); + ], + ]); curl_close($ch); throw $e; } @@ -1089,7 +1089,7 @@ abstract class BaseFacebook protected function getApiUrl($method) { static $READ_ONLY_CALLS = - array( + [ 'admin.getallocation' => 1, 'admin.getappproperties' => 1, 'admin.getbannedusers' => 1, @@ -1150,7 +1150,7 @@ abstract class BaseFacebook 'users.isappuser' => 1, 'users.isverified' => 1, 'video.getuploadlimits' => 1 - ); + ]; $name = 'api'; if (isset($READ_ONLY_CALLS[strtolower($method)])) { $name = 'api_read'; @@ -1169,7 +1169,7 @@ abstract class BaseFacebook * * @return string The URL for the given parameters */ - protected function getUrl($name, $path = '', $params = array()) + protected function getUrl($name, $path = '', $params = []) { $url = self::$DOMAIN_MAP[$name]; if ($path) { @@ -1367,18 +1367,18 @@ abstract class BaseFacebook { $cookie_name = $this->getMetadataCookieName(); if (!array_key_exists($cookie_name, $_COOKIE)) { - return array(); + return []; } // The cookie value can be wrapped in "-characters so remove them $cookie_value = trim($_COOKIE[$cookie_name], '"'); if (empty($cookie_value)) { - return array(); + return []; } $parts = explode('&', $cookie_value); - $metadata = array(); + $metadata = []; foreach ($parts as $part) { $pair = explode('=', $part, 2); if (!empty($pair[0])) { diff --git a/modules/authfacebook/lib/Auth/Source/Facebook.php b/modules/authfacebook/lib/Auth/Source/Facebook.php index 86d592458..a2bee6a7a 100644 --- a/modules/authfacebook/lib/Auth/Source/Facebook.php +++ b/modules/authfacebook/lib/Auth/Source/Facebook.php @@ -98,13 +98,13 @@ class Facebook extends \SimpleSAML\Auth\Source \SimpleSAML\Auth\State::saveState($state, self::STAGE_INIT); $facebook = new Module\authfacebook\Facebook( - array('appId' => $this->api_key, 'secret' => $this->secret), + ['appId' => $this->api_key, 'secret' => $this->secret], $state ); $facebook->destroySession(); $linkback = Module::getModuleURL('authfacebook/linkback.php'); - $url = $facebook->getLoginUrl(array('redirect_uri' => $linkback, 'scope' => $this->req_perms)); + $url = $facebook->getLoginUrl(['redirect_uri' => $linkback, 'scope' => $this->req_perms]); \SimpleSAML\Auth\State::saveState($state, self::STAGE_INIT); \SimpleSAML\Utils\HTTP::redirectTrustedURL($url); @@ -116,7 +116,7 @@ class Facebook extends \SimpleSAML\Auth\Source assert(is_array($state)); $facebook = new Module\authfacebook\Facebook( - array('appId' => $this->api_key, 'secret' => $this->secret), + ['appId' => $this->api_key, 'secret' => $this->secret], $state ); $uid = $facebook->getUser(); @@ -133,21 +133,21 @@ class Facebook extends \SimpleSAML\Auth\Source throw new \SimpleSAML\Error\AuthSource($this->authId, 'Error getting user profile.'); } - $attributes = array(); + $attributes = []; foreach ($info as $key => $value) { if (is_string($value) && !empty($value)) { - $attributes['facebook.'.$key] = array((string) $value); + $attributes['facebook.'.$key] = [(string) $value]; } } if (array_key_exists('third_party_id', $info)) { - $attributes['facebook_user'] = array($info['third_party_id'].'@facebook.com'); + $attributes['facebook_user'] = [$info['third_party_id'].'@facebook.com']; } else { - $attributes['facebook_user'] = array($uid.'@facebook.com'); + $attributes['facebook_user'] = [$uid.'@facebook.com']; } - $attributes['facebook_targetedID'] = array('http://facebook.com!'.$uid); - $attributes['facebook_cn'] = array($info['name']); + $attributes['facebook_targetedID'] = ['http://facebook.com!'.$uid]; + $attributes['facebook_cn'] = [$info['name']]; \SimpleSAML\Logger::debug('Facebook Returned Attributes: '.implode(", ", array_keys($attributes))); diff --git a/modules/authfacebook/lib/Facebook.php b/modules/authfacebook/lib/Facebook.php index f5d123077..cf68d348a 100644 --- a/modules/authfacebook/lib/Facebook.php +++ b/modules/authfacebook/lib/Facebook.php @@ -48,7 +48,7 @@ class Facebook extends \BaseFacebook } } - protected static $kSupportedKeys = array('state', 'code', 'access_token', 'user_id'); + protected static $kSupportedKeys = ['state', 'code', 'access_token', 'user_id']; protected function initSharedSession() { @@ -67,10 +67,10 @@ class Facebook extends \BaseFacebook $base_domain = $this->getBaseDomain(); $this->sharedSessionID = md5(uniqid(mt_rand(), true)); $cookie_value = $this->makeSignedRequest( - array( + [ 'domain' => $base_domain, 'id' => $this->sharedSessionID, - ) + ] ); $_COOKIE[$cookie_name] = $cookie_value; if (!headers_sent()) { @@ -153,7 +153,7 @@ class Facebook extends \BaseFacebook protected function constructSessionVariableName($key) { - $parts = array('authfacebook:authdata:fb', $this->getAppId(), $key); + $parts = ['authfacebook:authdata:fb', $this->getAppId(), $key]; if ($this->sharedSessionID) { array_unshift($parts, $this->sharedSessionID); } diff --git a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php index 215d7c342..0716d8663 100644 --- a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php +++ b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php @@ -84,9 +84,9 @@ class LinkedIn extends \SimpleSAML\Auth\Source // Get the request token $requestToken = $consumer->getRequestToken( 'https://api.linkedin.com/uas/oauth/requestToken', - array( - 'oauth_callback' => \SimpleSAML\Module::getModuleURL('authlinkedin').'/linkback.php?stateid='.$stateID - ) + [ + 'oauth_callback' => \SimpleSAML\Module::getModuleUrl('authlinkedin').'/linkback.php?stateid='.$stateID + ] ); \SimpleSAML\Logger::debug( @@ -119,7 +119,7 @@ class LinkedIn extends \SimpleSAML\Auth\Source $accessToken = $consumer->getAccessToken( 'https://api.linkedin.com/uas/oauth/accessToken', $requestToken, - array('oauth_verifier' => $state['authlinkedin:oauth_verifier']) + ['oauth_verifier' => $state['authlinkedin:oauth_verifier']] ); \SimpleSAML\Logger::debug( @@ -130,7 +130,7 @@ class LinkedIn extends \SimpleSAML\Auth\Source $userdata = $consumer->getUserInfo( 'https://api.linkedin.com/v1/people/~:('.$this->attributes.')', $accessToken, - array('http' => array('header' => 'x-li-format: json')) + ['http' => ['header' => 'x-li-format: json']] ); $attributes = $this->flatten($userdata, 'linkedin.'); @@ -138,8 +138,8 @@ class LinkedIn extends \SimpleSAML\Auth\Source // TODO: pass accessToken: key, secret + expiry as attributes? if (array_key_exists('id', $userdata)) { - $attributes['linkedin_targetedID'] = array('http://linkedin.com!'.$userdata['id']); - $attributes['linkedin_user'] = array($userdata['id'].'@linkedin.com'); + $attributes['linkedin_targetedID'] = ['http://linkedin.com!'.$userdata['id']]; + $attributes['linkedin_user'] = [$userdata['id'].'@linkedin.com']; } \SimpleSAML\Logger::debug('LinkedIn Returned Attributes: '.implode(", ", array_keys($attributes))); @@ -176,12 +176,12 @@ class LinkedIn extends \SimpleSAML\Auth\Source */ protected function flatten($array, $prefix = '') { - $result = array(); + $result = []; foreach ($array as $key => $value) { if (is_array($value)) { $result = $result + $this->flatten($value, $prefix.$key.'.'); } else { - $result[$prefix.$key] = array($value); + $result[$prefix.$key] = [$value]; } } return $result; diff --git a/modules/authorize/lib/Auth/Process/Authorize.php b/modules/authorize/lib/Auth/Process/Authorize.php index e546f3417..151bee965 100644 --- a/modules/authorize/lib/Auth/Process/Authorize.php +++ b/modules/authorize/lib/Auth/Process/Authorize.php @@ -31,7 +31,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter * user \ to escape special chars, like '.' etc. * */ - protected $valid_attribute_values = array(); + protected $valid_attribute_values = []; /** * Initialize this filter. @@ -62,7 +62,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter foreach ($config as $attribute => $values) { if (is_string($values)) { - $values = array($values); + $values = [$values]; } if (!is_array($values)) { throw new \Exception( @@ -99,7 +99,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter foreach ($patterns as $pattern) { $values = $attributes[$name]; if (!is_array($values)) { - $values = array($values); + $values = [$values]; } foreach ($values as $value) { if ($this->regex) { @@ -137,6 +137,6 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter // Save state and redirect to 403 page $id = \SimpleSAML\Auth\State::saveState($request, 'authorize:Authorize'); $url = \SimpleSAML\Module::getModuleURL('authorize/authorize_403.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/authorize/www/authorize_403.php b/modules/authorize/www/authorize_403.php index 4fe73632e..4598a66c8 100644 --- a/modules/authorize/www/authorize_403.php +++ b/modules/authorize/www/authorize_403.php @@ -15,7 +15,7 @@ $t = new \SimpleSAML\XHTML\Template($globalConfig, 'authorize:authorize_403.php' if (isset($state['Source']['auth'])) { $t->data['logoutURL'] = \SimpleSAML\Module::getModuleURL( 'core/authenticate.php', - array('as' => $state['Source']['auth']) + ['as' => $state['Source']['auth']] )."&logout"; } header('HTTP/1.0 403 Forbidden'); diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php index 6b004b6fb..19ff72580 100644 --- a/modules/authtwitter/lib/Auth/Source/Twitter.php +++ b/modules/authtwitter/lib/Auth/Source/Twitter.php @@ -84,10 +84,10 @@ class Twitter extends \SimpleSAML\Auth\Source $consumer = new \SimpleSAML\Module\oauth\Consumer($this->key, $this->secret); // Get the request token - $linkback = \SimpleSAML\Module::getModuleURL('authtwitter/linkback.php', array('AuthState' => $stateID)); + $linkback = \SimpleSAML\Module::getModuleURL('authtwitter/linkback.php', ['AuthState' => $stateID]); $requestToken = $consumer->getRequestToken( 'https://api.twitter.com/oauth/request_token', - array('oauth_callback' => $linkback) + ['oauth_callback' => $linkback] ); \SimpleSAML\Logger::debug("Got a request token from the OAuth service provider [". $requestToken->key."] with the secret [".$requestToken->secret."]"); @@ -98,7 +98,7 @@ class Twitter extends \SimpleSAML\Auth\Source // Authorize the request token $url = 'https://api.twitter.com/oauth/authenticate'; if ($this->force_login) { - $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array('force_login' => 'true')); + $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, ['force_login' => 'true']); } $consumer->getAuthorizeRequest($url, $requestToken); } @@ -106,7 +106,7 @@ class Twitter extends \SimpleSAML\Auth\Source public function finalStep(&$state) { $requestToken = $state['authtwitter:authdata:requestToken']; - $parameters = array(); + $parameters = []; if (!isset($_REQUEST['oauth_token'])) { throw new \SimpleSAML\Error\BadRequest("Missing oauth_token parameter."); @@ -147,16 +147,16 @@ class Twitter extends \SimpleSAML\Auth\Source ); } - $attributes = array(); + $attributes = []; foreach ($userdata as $key => $value) { if (is_string($value)) { - $attributes['twitter.'.$key] = array((string) $value); + $attributes['twitter.'.$key] = [(string) $value]; } } - $attributes['twitter_at_screen_name'] = array('@'.$userdata['screen_name']); - $attributes['twitter_screen_n_realm'] = array($userdata['screen_name'].'@twitter.com'); - $attributes['twitter_targetedID'] = array('http://twitter.com!'.$userdata['id_str']); + $attributes['twitter_at_screen_name'] = ['@'.$userdata['screen_name']]; + $attributes['twitter_screen_n_realm'] = [$userdata['screen_name'].'@twitter.com']; + $attributes['twitter_targetedID'] = ['http://twitter.com!'.$userdata['id_str']]; $state['Attributes'] = $attributes; } diff --git a/modules/authwindowslive/lib/Auth/Source/LiveID.php b/modules/authwindowslive/lib/Auth/Source/LiveID.php index facac508e..3f4dc5446 100644 --- a/modules/authwindowslive/lib/Auth/Source/LiveID.php +++ b/modules/authwindowslive/lib/Auth/Source/LiveID.php @@ -105,13 +105,13 @@ class LiveID extends \SimpleSAML\Auth\Source '&redirect_uri='.urlencode(\SimpleSAML\Module::getModuleURL('authwindowslive').'/linkback.php'). '&code='.urlencode($state['authwindowslive:verification_code']); - $context = array( - 'http' => array( + $context = [ + 'http' => [ 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postData, - ), - ); + ], + ]; $result = \SimpleSAML\Utils\HTTP::fetch('https://login.microsoftonline.com/common/oauth2/v2.0/token', $context); @@ -130,10 +130,10 @@ class LiveID extends \SimpleSAML\Auth\Source ); // documentation at: http://graph.microsoft.io/en-us/docs/overview/call_api - $opts = array( - 'http' => array('header' => "Accept: application/json\r\nAuthorization: Bearer ". - $response['access_token']."\r\n") - ); + $opts = [ + 'http' => ['header' => "Accept: application/json\r\nAuthorization: Bearer ". + $response['access_token']."\r\n"] + ]; $data = \SimpleSAML\Utils\HTTP::fetch('https://graph.microsoft.com/v1.0/me', $opts); $userdata = json_decode($data, true); @@ -144,13 +144,13 @@ class LiveID extends \SimpleSAML\Auth\Source $userdata['error']['message'] ); } - $attributes = array(); - $attributes['windowslive_targetedID'] = array( + $attributes = []; + $attributes['windowslive_targetedID'] = [ 'https://graph.microsoft.com!'.(!empty($userdata['id']) ? $userdata['id'] : 'unknown') - ); + ]; foreach ($userdata as $key => $value) { if (is_string($value)) { - $attributes['windowslive.'.$key] = array((string) $value); + $attributes['windowslive.'.$key] = [(string) $value]; } } diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php index f0afe8501..08f153c13 100644 --- a/modules/cas/lib/Auth/Source/CAS.php +++ b/modules/cas/lib/Auth/Source/CAS.php @@ -95,15 +95,15 @@ class CAS extends \SimpleSAML\Auth\Source */ private function casValidate($ticket, $service) { - $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->casConfig['validate'], array( + $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->casConfig['validate'], [ 'ticket' => $ticket, 'service' => $service, - )); + ]); $result = \SimpleSAML\Utils\HTTP::fetch($url); $res = preg_split("/\r?\n/", $result); if (strcmp($res[0], "yes") == 0) { - return array($res[1], array()); + return [$res[1], []]; } else { throw new \Exception("Failed to validate CAS service ticket: $ticket"); } @@ -122,10 +122,10 @@ class CAS extends \SimpleSAML\Auth\Source { $url = \SimpleSAML\Utils\HTTP::addURLParameters( $this->casConfig['serviceValidate'], - array( + [ 'ticket' => $ticket, 'service' => $service, - ) + ] ); $result = \SimpleSAML\Utils\HTTP::fetch($url); @@ -137,7 +137,7 @@ class CAS extends \SimpleSAML\Auth\Source $failure = $xPath->evaluate("/cas:serviceResponse/cas:authenticationFailure"); throw new \Exception("Error when validating CAS service ticket: ".$failure->item(0)->textContent); } else { - $attributes = array(); + $attributes = []; if ($casattributes = $this->casConfig['attributes']) { // Some has attributes in the xml - attributes is a list of XPath expressions to get them foreach ($casattributes as $name => $query) { @@ -149,7 +149,7 @@ class CAS extends \SimpleSAML\Auth\Source } $casusername = $success->item(0)->textContent; - return array($casusername, $attributes); + return [$casusername, $attributes]; } } @@ -183,9 +183,9 @@ class CAS extends \SimpleSAML\Auth\Source { $ticket = $state['cas:ticket']; $stateID = \SimpleSAML\Auth\State::saveState($state, self::STAGE_INIT); - $service = \SimpleSAML\Module::getModuleURL('cas/linkback.php', array('stateID' => $stateID)); + $service = \SimpleSAML\Module::getModuleURL('cas/linkback.php', ['stateID' => $stateID]); list($username, $casattributes) = $this->casValidation($ticket, $service); - $ldapattributes = array(); + $ldapattributes = []; $config = \SimpleSAML\Configuration::loadFromArray( $this->ldapConfig, @@ -223,9 +223,9 @@ class CAS extends \SimpleSAML\Auth\Source $stateID = \SimpleSAML\Auth\State::saveState($state, self::STAGE_INIT); - $serviceUrl = \SimpleSAML\Module::getModuleURL('cas/linkback.php', array('stateID' => $stateID)); + $serviceUrl = \SimpleSAML\Module::getModuleURL('cas/linkback.php', ['stateID' => $stateID]); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->loginMethod, array('service' => $serviceUrl)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->loginMethod, ['service' => $serviceUrl]); } diff --git a/modules/cdc/config-templates/module_cdc.php b/modules/cdc/config-templates/module_cdc.php index 0e5013c87..411bbc471 100644 --- a/modules/cdc/config-templates/module_cdc.php +++ b/modules/cdc/config-templates/module_cdc.php @@ -1,7 +1,7 @@ <?php -$config = array( - 'example.org' => array( +$config = [ + 'example.org' => [ /* * The shared key for this CDC server. */ @@ -18,5 +18,5 @@ $config = array( * If this is 0, the cookie will expire when the browser is closed. */ 'cookie.lifetime' => 0, - ), -); + ], +]; diff --git a/modules/cdc/lib/Auth/Process/CDC.php b/modules/cdc/lib/Auth/Process/CDC.php index d16569ef8..bf2a669d6 100644 --- a/modules/cdc/lib/Auth/Process/CDC.php +++ b/modules/cdc/lib/Auth/Process/CDC.php @@ -63,12 +63,12 @@ class CDC extends \SimpleSAML\Auth\ProcessingFilter // Save state and build request $id = \SimpleSAML\Auth\State::saveState($state, 'cdc:resume'); - $returnTo = \SimpleSAML\Module::getModuleURL('cdc/resume.php', array('domain' => $this->domain)); + $returnTo = \SimpleSAML\Module::getModuleURL('cdc/resume.php', ['domain' => $this->domain]); - $params = array( + $params = [ 'id' => $id, 'entityID' => $state['Source']['entityid'], - ); + ]; $this->client->sendRequest($returnTo, 'append', $params); } } diff --git a/modules/cdc/lib/Client.php b/modules/cdc/lib/Client.php index 6af90fa49..609aef63f 100644 --- a/modules/cdc/lib/Client.php +++ b/modules/cdc/lib/Client.php @@ -58,7 +58,7 @@ class Client * @param string $op The operation we are performing. * @param array $params Additional parameters. */ - public function sendRequest($returnTo, $op, array $params = array()) + public function sendRequest($returnTo, $op, array $params = []) { assert(is_string($returnTo)); assert(is_string($op)); diff --git a/modules/cdc/lib/Server.php b/modules/cdc/lib/Server.php index a82deb43a..affcf668a 100644 --- a/modules/cdc/lib/Server.php +++ b/modules/cdc/lib/Server.php @@ -162,9 +162,9 @@ class Server } if (is_string($response)) { - $response = array( + $response = [ 'status' => $response, - ); + ]; } $response['op'] = $op; @@ -212,12 +212,12 @@ class Server */ private function handleDelete(array $request) { - $params = array( + $params = [ 'path' => '/', 'domain' => '.'.$this->domain, 'secure' => true, 'httponly' => false, - ); + ]; \SimpleSAML\Utils\HTTP::setCookie('_saml_idp', null, $params, false); return 'ok'; @@ -234,10 +234,10 @@ class Server { $list = $this->getCDC(); - return array( + return [ 'status' => 'ok', 'cdc' => $list, - ); + ]; } @@ -330,10 +330,10 @@ class Server $signature = $this->calcSignature($message); - $params = array( + $params = [ $parameter => $message, 'Signature' => $signature, - ); + ]; $url = \SimpleSAML\Utils\HTTP::addURLParameters($to, $params); if (strlen($url) < 2048) { @@ -366,7 +366,7 @@ class Server private function getCDC() { if (!isset($_COOKIE['_saml_idp'])) { - return array(); + return []; } $ret = (string) $_COOKIE['_saml_idp']; @@ -376,7 +376,7 @@ class Server if ($idp === false) { // Not properly base64 encoded \SimpleSAML\Logger::warning('CDC - Invalid base64-encoding of CDC entry.'); - return array(); + return []; } } @@ -411,13 +411,13 @@ class Server $cookie = $tmp[1]; } - $params = array( + $params = [ 'lifetime' => $this->cookieLifetime, 'path' => '/', 'domain' => '.'.$this->domain, 'secure' => true, 'httponly' => false, - ); + ]; \SimpleSAML\Utils\HTTP::setCookie('_saml_idp', $cookie, $params, false); diff --git a/modules/consent/dictionaries/consent.php b/modules/consent/dictionaries/consent.php index 509d069ad..90932786a 100644 --- a/modules/consent/dictionaries/consent.php +++ b/modules/consent/dictionaries/consent.php @@ -1,7 +1,7 @@ <?php -$lang = array( - 'yes' => array( +$lang = [ + 'yes' => [ 'no' => 'Ja, fortsett', 'nn' => 'Ja, fortsett', 'da' => 'Ja, jeg accepterer', @@ -20,8 +20,8 @@ $lang = array( 'pt' => 'Sim, Aceito', 'pt-br' => 'Sim, Aceito', 'tr' => 'Evet, devam et', - ), - 'no' => array( + ], + 'no' => [ 'no' => 'Nei, avbryt', 'nn' => 'Nei, avbryt', 'da' => 'Nej, jeg accepterer ikke', @@ -40,8 +40,8 @@ $lang = array( 'pt' => 'NĂŁo aceito', 'pt-br' => 'NĂŁo, nĂŁo aceito', 'tr' => 'Hayır, iptal et', - ), - 'remember' => array( + ], + 'remember' => [ 'no' => 'Godta ogsĂĄ for fremtiden', 'nn' => 'Godta ogsĂĄ for framtida', 'da' => 'Husk samtykke', @@ -60,8 +60,8 @@ $lang = array( 'pt' => 'Lembrar a minha escolha', 'pt-br' => 'Lembrar Consentimento', 'tr' => 'Hatırla', - ), - 'consent_header' => array( + ], + 'consent_header' => [ 'no' => 'Samtykke om overføring av personinformasjon', 'nn' => 'Samtykke til overføring av personinformasjon', 'da' => 'Samtykke til at frigive personlige oplysninger', @@ -77,8 +77,8 @@ $lang = array( 'pl' => 'Zgoda na wysĹ‚anie danych osobistych', 'pt' => 'Consentimento do envio de informação pessoal', 'tr' => 'KiĹźisel bilgilerin verilmesi hakkında onay', - ), - 'consent_accept' => array( + ], + 'consent_accept' => [ 'no' => 'For ĂĄ fullføre innloggingen mĂĄ du godta at opplysningene nedenfor sendes til SPNAME.', 'nn' => 'For ĂĄ fullføra innlogginga mĂĄ du godta at opplysningane under blir sende til SPNAME', 'da' => 'SPNAME kræver at nedenstĂĄende oplysninger overføres fra IDPNAME. Vil du acceptere dette?', @@ -97,8 +97,8 @@ $lang = array( 'pt' => 'O serviço SPNAME necessita que a informação apresentada em baixo seja transferida.', 'pt-br' => 'VocĂŞ está prestes a acessar o serviço SPNAME. O serviço exige que as informações a seguir sejam transferidas do IDPNAME. VocĂŞ aceita isso?', 'tr' => 'SPNAME aĹźağıdaki bilgilerin gönderilmesine ihtiyaç duyuyor.', - ), - 'consent_purpose' => array( + ], + 'consent_purpose' => [ 'no' => 'FormĂĄlet med SPNAME er SPDESC', 'nn' => 'Hensikta med SPNAME er SPDESC', 'da' => 'SPNAME har til formĂĄl at SPDESC', @@ -114,8 +114,8 @@ $lang = array( 'pl' => 'Celem SPNAME jest SPDESC', 'pt' => 'O propĂłsito de SPNAME Ă© SPDESC', 'tr' => 'SPNAME\'in amacı SPDESC\'tir', - ), - 'consent_privacypolicy' => array( + ], + 'consent_privacypolicy' => [ 'no' => 'Personvern for tjenesten', 'nn' => 'Personvern for tenesta', 'da' => 'Tjenestens politik vedrørende personoplysninger', @@ -132,8 +132,8 @@ $lang = array( 'pt' => 'PolĂtica de privacidade do serviço', 'pt-br' => 'PolĂtica de Privacidade deste serviço', 'tr' => 'Servis için gizlilik politikası', - ), - 'consent_attributes_header' => array( + ], + 'consent_attributes_header' => [ 'no' => 'Opplysninger som vil bli sendt til SPNAME', 'nn' => 'Opplysningar som blir sende til SPNAME', 'da' => 'Attributter som bliver sendt til SPNAME', @@ -149,8 +149,8 @@ $lang = array( 'pl' => 'Atrybuty, ktĂłre zostanÄ… przesĹ‚ane do serwisu', 'pt' => 'Informação que irá ser enviada para SPNAME', 'tr' => 'SPNAME\'e gönderilecek bilgiler', - ), - 'show_attributes' => array( + ], + 'show_attributes' => [ 'no' => 'Vis opplysninger', 'nn' => 'Vis opplysingar', 'da' => 'Vis attributter', @@ -166,8 +166,8 @@ $lang = array( 'pl' => 'WyĹ›wietl atrybuty', 'pt' => 'Mostrar atributos', 'tr' => 'Ă–zellikleri göster', - ), - 'show_attribute' => array( + ], + 'show_attribute' => [ 'no' => 'Vis innhold', 'nn' => 'Vis innhald', 'da' => 'Vis indhold', @@ -176,8 +176,8 @@ $lang = array( 'es' => 'Mostrart consentimiento', 'nl' => 'Toon inhoud', 'sl' => 'PrikaĹľi vsebino', - ), - 'login' => array( + ], + 'login' => [ 'no' => 'innlogging', 'nn' => 'Logg inn', 'da' => 'login', @@ -196,8 +196,8 @@ $lang = array( 'pt' => 'Entrar', 'pt-br' => 'login', 'tr' => 'GiriĹź', - ), - 'service_providers_for' => array( + ], + 'service_providers_for' => [ 'no' => 'Tjenesteleverandør for', 'nn' => 'Tenesteleverandørar for', 'da' => 'Tjenesteudbyder for', @@ -216,8 +216,8 @@ $lang = array( 'pt' => 'Fornecedores de Serviço (SP) para', 'pt-br' => 'Provedor de serviços para', 'tr' => 'için Servis SaÄźlayıcılar', - ), - 'service_provider_header' => array( + ], + 'service_provider_header' => [ 'no' => 'Tjenesteleverandør', 'nn' => 'Tenesteleverandør', 'da' => 'Tjenesteudbyder', @@ -236,8 +236,8 @@ $lang = array( 'pt' => 'Fornecedor de Serviço (SP)', 'pt-br' => 'Provedor de Serviços', 'tr' => 'Servis SaÄźlayıcı', - ), - 'status_header' => array( + ], + 'status_header' => [ 'no' => 'Samtykke-status', 'nn' => 'Samtykkestatus', 'da' => 'Samtykke status', @@ -256,8 +256,8 @@ $lang = array( 'pt' => 'Consentimento', 'pt-br' => 'Status do Consentimento', 'tr' => 'Onay durumu', - ), - 'show_hide_attributes' => array( + ], + 'show_hide_attributes' => [ 'no' => 'Vis/skjul opplysninger', 'nn' => 'Vis/skjul opplysningar', 'da' => 'vis/skjul attributter', @@ -276,8 +276,8 @@ $lang = array( 'pt' => 'Mostrar/Ocultar atributos', 'pt-br' => 'mostra/esconder Atributos', 'tr' => 'bilgileri göster/gizle ', - ), - 'noconsent_title' => array( + ], + 'noconsent_title' => [ 'no' => 'Ikke akseptert overføring av informasjon', 'nn' => 'Ikkje akseptert overføring av informasjon', 'da' => 'Manglende samtykke', @@ -294,8 +294,8 @@ $lang = array( 'pt' => 'Consentimento negado', 'pt-br' => 'Nenhum consentimento dado', 'tr' => 'Onay verilmemiĹź', - ), - 'noconsent_text' => array( + ], + 'noconsent_text' => [ 'no' => 'Du har ikke akseptert ĂĄ overlevere opplysninger til tjenesteleverandøren.', 'nn' => 'Du har ikkje akseptert til at dine opplysningar kan sendast til tenesteleverandøren', 'da' => 'Du har ikke givet samtykke til overleveringen af oplysninger til tjenesten', @@ -312,8 +312,8 @@ $lang = array( 'pt' => 'Negou o consentimento para a transferĂŞncia dos seus atributos para o fornecedor de serviço.', 'pt-br' => 'VocĂŞ nĂŁo deu o consentimento para a transferĂŞncia de seus atributos para o provedor de serviços.', 'tr' => 'Bilgilerinizin servis saÄźlayıcıya gönderilmesi için onay vermediniz.', - ), - 'noconsent_return' => array( + ], + 'noconsent_return' => [ 'no' => 'GĂĄ tilbake til aksept-siden med opplysninger', 'nn' => 'GĂĄ tilbake til aksept-sida for overføring av opplysningar', 'da' => 'GĂĄ tilbage', @@ -330,8 +330,8 @@ $lang = array( 'pt' => 'Voltar Ă página de consentimento', 'pt-br' => 'Retornar a página de consentimento', 'tr' => 'Onay sayfasına geri dön', - ), - 'noconsent_goto_about' => array( + ], + 'noconsent_goto_about' => [ 'no' => 'GĂĄ til informasjonsside om tjenesten', 'nn' => 'GĂĄ til informasjonssida for tenesta', 'da' => 'GĂĄ til side med information om tjenesten', @@ -347,8 +347,8 @@ $lang = array( 'pl' => 'PrzejdĹş do strony informacyjnej dla tego serwisu', 'pt' => 'Ir para página de informação do serviço', 'tr' => 'Servis için bilgi sayfasına git', - ), - 'table_caption' => array( + ], + 'table_caption' => [ 'no' => 'Bruker innformasjon', 'da' => 'Bruger information', 'en' => 'User information', @@ -361,8 +361,8 @@ $lang = array( 'hu' => 'FelhasználĂłi informáciĂłk', 'pt' => 'Informação do utilizador', 'tr' => 'Kullanıcı bilgisi', - ), - 'table_summary' => array( + ], + 'table_summary' => [ 'no' => 'Her listes den innformasjonen om deg som blir send til den tjenesten du er i ferd med ĂĄ logge pĂĄ', 'da' => 'Informationer som vil blive sendt til den service du er ved at logge in pĂĄ', 'en' => 'List the information about you that is about to be transmitted to the service you are going to login to', @@ -374,5 +374,5 @@ $lang = array( 'hu' => 'Ezeket az adatokat fogjuk elkĂĽldeni Ă–nrĹ‘l annak a szolgáltatásnak, ahová be kĂván jelentkezni', 'pt' => 'Listar a informação acerca de si que será enviada para o serviço no qual se está autenticar', 'tr' => 'Girmek istediÄźiniz servise gönderilecek bilginizi listeleyin', - ), -); + ], +]; diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index f19c2b20e..f5b6bfc81 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -51,14 +51,14 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter * * @var array */ - private $hiddenAttributes = array(); + private $hiddenAttributes = []; /** * Attributes which should not require consent * * @var array */ - private $noconsentattributes = array(); + private $noconsentattributes = []; /** * Whether we should show the "about service"-link on the no consent page. @@ -104,7 +104,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter } if (array_key_exists('focus', $config)) { - if (!in_array($config['focus'], array('yes', 'no'), true)) { + if (!in_array($config['focus'], ['yes', 'no'], true)) { throw new \SimpleSAML\Error\Exception( 'Consent: focus must be a string with values `yes` or `no`. '. var_export($config['focus'], true).' given.' @@ -258,7 +258,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter $state['Source'] = $idpmeta; } - $statsData = array('spEntityID' => $spEntityId); + $statsData = ['spEntityID' => $spEntityId]; // Do not use consent if disabled if (isset($state['Source']['consent.disable']) && @@ -344,7 +344,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter // Save state and redirect $id = \SimpleSAML\Auth\State::saveState($state, 'consent:request'); $url = Module::getModuleURL('consent/getconsent.php'); - Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } diff --git a/modules/consent/lib/Consent/Store/Cookie.php b/modules/consent/lib/Consent/Store/Cookie.php index 19ab9b401..1a8780735 100644 --- a/modules/consent/lib/Consent/Store/Cookie.php +++ b/modules/consent/lib/Consent/Store/Cookie.php @@ -160,7 +160,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store { assert(is_string($userId)); - $ret = array(); + $ret = []; $cookieNameStart = '\SimpleSAML\Module\consent:'; $cookieNameStartLen = strlen($cookieNameStart); @@ -277,12 +277,12 @@ class Cookie extends \SimpleSAML\Module\consent\Store assert(is_string($value) || $value === null); $globalConfig = \SimpleSAML\Configuration::getInstance(); - $params = array( + $params = [ 'lifetime' => 7776000, // (90*24*60*60) 'path' => ($globalConfig->getBasePath()), 'httponly' => true, 'secure' => \SimpleSAML\Utils\HTTP::isHTTPS(), - ); + ]; \SimpleSAML\Utils\HTTP::setCookie($name, $value, $params, false); } diff --git a/modules/consent/lib/Consent/Store/Database.php b/modules/consent/lib/Consent/Store/Database.php index 74035d028..a68122020 100644 --- a/modules/consent/lib/Consent/Store/Database.php +++ b/modules/consent/lib/Consent/Store/Database.php @@ -140,14 +140,14 @@ class Database extends \SimpleSAML\Module\consent\Store */ public function __sleep() { - return array( + return [ 'dsn', 'dateTime', 'username', 'password', 'table', 'timeout', - ); + ]; } @@ -174,7 +174,7 @@ class Database extends \SimpleSAML\Module\consent\Store 'UPDATE '.$this->table.' '. 'SET usage_date = '.$this->dateTime.' '. 'WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', - array($userId, $destinationId, $attributeSet) + [$userId, $destinationId, $attributeSet] ); if ($st === false) { @@ -215,7 +215,7 @@ class Database extends \SimpleSAML\Module\consent\Store 'UPDATE '.$this->table.' '. 'SET consent_date = '.$this->dateTime.', usage_date = '.$this->dateTime.', attribute = ? '. 'WHERE hashed_user_id = ? AND service_id = ?', - array($attributeSet, $userId, $destinationId) + [$attributeSet, $userId, $destinationId] ); if ($st === false) { @@ -232,7 +232,7 @@ class Database extends \SimpleSAML\Module\consent\Store $st = $this->execute( 'INSERT INTO '.$this->table.' ('.'consent_date, usage_date, hashed_user_id, service_id, attribute'. ') '.'VALUES ('.$this->dateTime.', '.$this->dateTime.', ?, ?, ?)', - array($userId, $destinationId, $attributeSet) + [$userId, $destinationId, $attributeSet] ); if ($st !== false) { @@ -259,7 +259,7 @@ class Database extends \SimpleSAML\Module\consent\Store $st = $this->execute( 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ?;', - array($userId, $destinationId) + [$userId, $destinationId] ); if ($st === false) { @@ -289,7 +289,7 @@ class Database extends \SimpleSAML\Module\consent\Store $st = $this->execute( 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ?', - array($userId) + [$userId] ); if ($st === false) { @@ -319,16 +319,16 @@ class Database extends \SimpleSAML\Module\consent\Store { assert(is_string($userId)); - $ret = array(); + $ret = []; $st = $this->execute( 'SELECT service_id, attribute, consent_date, usage_date FROM '.$this->table. ' WHERE hashed_user_id = ?', - array($userId) + [$userId] ); if ($st === false) { - return array(); + return []; } while ($row = $st->fetch(\PDO::FETCH_NUM)) { @@ -393,13 +393,13 @@ class Database extends \SimpleSAML\Module\consent\Store */ public function getStatistics() { - $ret = array(); + $ret = []; // Get total number of consents - $st = $this->execute('SELECT COUNT(*) AS no FROM '.$this->table, array()); + $st = $this->execute('SELECT COUNT(*) AS no FROM '.$this->table, []); if ($st === false) { - return array(); + return []; } if ($row = $st->fetch(\PDO::FETCH_NUM)) { @@ -410,11 +410,11 @@ class Database extends \SimpleSAML\Module\consent\Store $st = $this->execute( 'SELECT COUNT(*) AS no '. 'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->table.' ) AS foo', - array() + [] ); if ($st === false) { - return array(); + return []; } if ($row = $st->fetch(\PDO::FETCH_NUM)) { @@ -424,11 +424,11 @@ class Database extends \SimpleSAML\Module\consent\Store // Get total number of services that has been given consent to $st = $this->execute( 'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->table.') AS foo', - array() + [] ); if ($st === false) { - return array(); + return []; } if ($row = $st->fetch(\PDO::FETCH_NUM)) { @@ -450,7 +450,7 @@ class Database extends \SimpleSAML\Module\consent\Store return $this->db; } - $driver_options = array(); + $driver_options = []; if (isset($this->timeout)) { $driver_options[\PDO::ATTR_TIMEOUT] = $this->timeout; } @@ -493,7 +493,7 @@ class Database extends \SimpleSAML\Module\consent\Store { $st = $this->execute( 'SELECT * FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', - array('test', 'test', 'test') + ['test', 'test', 'test'] ); if ($st === false) { diff --git a/modules/consent/lib/Store.php b/modules/consent/lib/Store.php index 528f2ca16..0e7c612b9 100644 --- a/modules/consent/lib/Store.php +++ b/modules/consent/lib/Store.php @@ -126,7 +126,7 @@ abstract class Store public static function parseStoreConfig($config) { if (is_string($config)) { - $config = array($config); + $config = [$config]; } if (!is_array($config)) { diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 24fe3b528..d36e5883c 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -48,9 +48,9 @@ if (array_key_exists('yes', $_REQUEST)) { \SimpleSAML\Logger::stats('consentResponse rememberNot'); } - $statsInfo = array( + $statsInfo = [ 'remember' => array_key_exists('saveconsent', $_REQUEST), - ); + ]; if (isset($state['Destination']['entityid'])) { $statsInfo['spEntityID'] = $state['Destination']['entityid']; } @@ -89,9 +89,9 @@ foreach ($attributes as $attrkey => $attrval) { unset($attributes[$attrkey]); } } -$para = array( +$para = [ 'attributes' => &$attributes -); +]; // Reorder attributes according to attributepresentation hooks \SimpleSAML\Module::callHooks('attributepresentation', $para); @@ -119,9 +119,9 @@ $translator = $t->getTranslator(); $t->data['srcMetadata'] = $state['Source']; $t->data['dstMetadata'] = $state['Destination']; $t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('consent/getconsent.php'); -$t->data['yesData'] = array('StateId' => $id); +$t->data['yesData'] = ['StateId' => $id]; $t->data['noTarget'] = \SimpleSAML\Module::getModuleURL('consent/noconsent.php'); -$t->data['noData'] = array('StateId' => $id); +$t->data['noData'] = ['StateId' => $id]; $t->data['attributes'] = $attributes; $t->data['checked'] = $state['consent:checked']; $t->data['stateId'] = $id; @@ -131,18 +131,18 @@ $dstName = htmlspecialchars(is_array($dstName) ? $translator->t($dstName) : $dst $t->data['consent_attributes_header'] = $translator->t( '{consent:consent:consent_attributes_header}', - array('SPNAME' => $dstName, 'IDPNAME' => $srcName) + ['SPNAME' => $dstName, 'IDPNAME' => $srcName] ); $t->data['consent_accept'] = $translator->t( '{consent:consent:consent_accept}', - array('SPNAME' => $dstName, 'IDPNAME' => $srcName) + ['SPNAME' => $dstName, 'IDPNAME' => $srcName] ); if (array_key_exists('descr_purpose', $state['Destination'])) { $t->data['consent_purpose'] = $translator->t( '{consent:consent:consent_purpose}', - array( + [ 'SPNAME' => $dstName, 'SPDESC' => $translator->getPreferredTranslation( \SimpleSAML\Utils\Arrays::arrayize( @@ -150,7 +150,7 @@ if (array_key_exists('descr_purpose', $state['Destination'])) { 'en' ) ), - ) + ] ); } @@ -192,7 +192,7 @@ $t->data['usestorage'] = array_key_exists('consent:store', $state); if (array_key_exists('consent:hiddenAttributes', $state)) { $t->data['hiddenAttributes'] = $state['consent:hiddenAttributes']; } else { - $t->data['hiddenAttributes'] = array(); + $t->data['hiddenAttributes'] = []; } $t->data['attributes_html'] = present_attributes($t, $attributes, ''); @@ -213,7 +213,7 @@ function present_attributes($t, $attributes, $nameParent) { $translator = $t->getTranslator(); - $alternate = array('odd', 'even'); + $alternate = ['odd', 'even']; $i = 0; $summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"'; diff --git a/modules/consent/www/logout.php b/modules/consent/www/logout.php index 0065cbea1..f84a51bb2 100644 --- a/modules/consent/www/logout.php +++ b/modules/consent/www/logout.php @@ -10,7 +10,7 @@ if (!array_key_exists('StateId', $_GET)) { } $state = \SimpleSAML\Auth\State::loadState($_GET['StateId'], 'consent:request'); -$state['Responder'] = array('\SimpleSAML\Module\consent\Logout', 'postLogout'); +$state['Responder'] = ['\SimpleSAML\Module\consent\Logout', 'postLogout']; $idp = \SimpleSAML\IdP::getByState($state); $idp->handleLogoutRequest($state, null); diff --git a/modules/consent/www/noconsent.php b/modules/consent/www/noconsent.php index 544f8bd8c..acd6ffc06 100644 --- a/modules/consent/www/noconsent.php +++ b/modules/consent/www/noconsent.php @@ -17,12 +17,12 @@ $state = \SimpleSAML\Auth\State::loadState($id, 'consent:request'); $resumeFrom = \SimpleSAML\Module::getModuleURL( 'consent/getconsent.php', - array('StateId' => $id) + ['StateId' => $id] ); $logoutLink = \SimpleSAML\Module::getModuleURL( 'consent/logout.php', - array('StateId' => $id) + ['StateId' => $id] ); $aboutService = null; @@ -32,7 +32,7 @@ if (!isset($state['consent:showNoConsentAboutService']) || $state['consent:showN } } -$statsInfo = array(); +$statsInfo = []; if (isset($state['Destination']['entityid'])) { $statsInfo['spEntityID'] = $state['Destination']['entityid']; } @@ -57,7 +57,7 @@ $t->data['logoutLink'] = $logoutLink; $dstName = htmlspecialchars(is_array($dstName) ? $translator->t($dstName) : $dstName); -$t->data['noconsent_text'] = $translator->t('{consent:consent:noconsent_text}', array('SPNAME' => $dstName)); -$t->data['noconsent_abort'] = $translator->t('{consent:consent:abort}', array('SPNAME' => $dstName)); +$t->data['noconsent_text'] = $translator->t('{consent:consent:noconsent_text}', ['SPNAME' => $dstName]); +$t->data['noconsent_abort'] = $translator->t('{consent:consent:abort}', ['SPNAME' => $dstName]); $t->show(); diff --git a/modules/consentAdmin/config-templates/module_consentAdmin.php b/modules/consentAdmin/config-templates/module_consentAdmin.php index 02fdf8d42..9c5420387 100644 --- a/modules/consentAdmin/config-templates/module_consentAdmin.php +++ b/modules/consentAdmin/config-templates/module_consentAdmin.php @@ -5,22 +5,22 @@ * @author Jacob Christiansen, <jach@wayf.dk> * @package SimpleSAMLphp */ -$config = array( +$config = [ /* * Configuration for the database connection. */ - 'consentadmin' => array( + 'consentadmin' => [ 'consent:Database', 'dsn' => 'mysql:host=DBHOST;dbname=DBNAME', 'username' => 'USERNAME', 'password' => 'PASSWORD', - ), + ], // Hash attributes including values or not 'attributes.hash' => true, // If you set attributes.exclude in the consent module, this must match - // 'attributes.exclude' => array(), + // 'attributes.exclude' => [], // Where to direct the user after logout // REMEMBER to prefix with http:// otherwise the relaystate is only appended @@ -32,4 +32,4 @@ $config = array( // Set authority 'authority' => 'saml2', -); +]; diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php index 792e2ff45..87edf27d2 100644 --- a/modules/consentAdmin/hooks/hook_frontpage.php +++ b/modules/consentAdmin/hooks/hook_frontpage.php @@ -10,8 +10,8 @@ function consentAdmin_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['config'][] = array( + $links['config'][] = [ 'href' => SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php'), 'text' => '{core:frontpage:link_consentAdmin}', - ); + ]; } diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php index b9bc74667..e8c3bcc83 100644 --- a/modules/consentAdmin/templates/consentadmin.php +++ b/modules/consentAdmin/templates/consentadmin.php @@ -83,7 +83,7 @@ TRSTART; <p> <a href=" <?php - echo \SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php', array('logout' => 1)); + echo \SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php', ['logout' => 1]); ?>">Logout</a> </p> diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index 8591a9c62..17a091d08 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -23,7 +23,7 @@ function driveProcessingChain( $attributes, $userid, $hashAttributes = false, - $excludeAttributes = array() + $excludeAttributes = [] ) { /* * Create a new processing chain @@ -34,14 +34,14 @@ function driveProcessingChain( * Construct the state. * REMEMBER: Do not set Return URL if you are calling processStatePassive */ - $authProcState = array( + $authProcState = [ 'Attributes' => $attributes, 'Destination' => $sp_metadata, 'SPMetadata' => $sp_metadata, 'Source' => $idp_metadata, 'IdPMetadata' => $idp_metadata, 'isPassive' => true, - ); + ]; /* we're being bridged, so add that info to the state */ if (strpos($source, '-idp-remote|') !== false) { $authProcState['saml:sp:IdP'] = substr($source, strpos($source, '|') + 1); @@ -74,7 +74,7 @@ function driveProcessingChain( \SimpleSAML\Logger::info('consentAdmin: attribute: '.$attribute_hash); // Return values - return array($targeted_id, $attribute_hash, $attributes); + return [$targeted_id, $attribute_hash, $attributes]; } // Get config object @@ -92,7 +92,7 @@ if (array_key_exists('logout', $_REQUEST)) { $hashAttributes = $cA_config->getValue('attributes.hash'); -$excludeAttributes = $cA_config->getValue('attributes.exclude', array()); +$excludeAttributes = $cA_config->getValue('attributes.exclude', []); // Check if valid local session exists $as->requireAuth(); @@ -223,12 +223,12 @@ if ($action !== null && $sp_entityid !== null) { $user_consent_list = $consent_storage->getConsents($hashed_user_id); // Parse list of consents -$user_consent = array(); +$user_consent = []; foreach ($user_consent_list as $c) { $user_consent[$c[0]] = $c[1]; } -$template_sp_content = array(); +$template_sp_content = []; // Init template $template = new \SimpleSAML\XHTML\Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin'); @@ -311,7 +311,7 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { $sp_description = $translator->getPreferredTranslation($translator->getTag('spdescription')); // Fill out array for the template - $sp_list[$sp_entityid] = array( + $sp_list[$sp_entityid] = [ 'spentityid' => $sp_entityid, 'name' => $sp_name, 'description' => $sp_description, @@ -319,7 +319,7 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { 'consentValue' => $sp_entityid, 'attributes_by_sp' => $attributes_new, 'serviceurl' => $sp_service_url, - ); + ]; } $template->data['header'] = 'Consent Administration'; diff --git a/modules/core/hooks/hook_frontpage.php b/modules/core/hooks/hook_frontpage.php index ea7aefd57..d2b6eef9c 100644 --- a/modules/core/hooks/hook_frontpage.php +++ b/modules/core/hooks/hook_frontpage.php @@ -10,24 +10,24 @@ function core_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['links']['frontpage_welcome'] = array( + $links['links']['frontpage_welcome'] = [ 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_welcome.php'), 'text' => '{core:frontpage:welcome}', 'shorttext' => '{core:frontpage:welcome}', - ); - $links['links']['frontpage_config'] = array( + ]; + $links['links']['frontpage_config'] = [ 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_config.php'), 'text' => '{core:frontpage:configuration}', 'shorttext' => '{core:frontpage:configuration}', - ); - $links['links']['frontpage_auth'] = array( + ]; + $links['links']['frontpage_auth'] = [ 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_auth.php'), 'text' => '{core:frontpage:auth}', 'shorttext' => '{core:frontpage:auth}', - ); - $links['links']['frontpage_federation'] = array( + ]; + $links['links']['frontpage_federation'] = [ 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_federation.php'), 'text' => '{core:frontpage:federation}', 'shorttext' => '{core:frontpage:federation}', - ); + ]; } diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index 1dd97a96c..3e3dd5270 100644 --- a/modules/core/hooks/hook_sanitycheck.php +++ b/modules/core/hooks/hook_sanitycheck.php @@ -32,10 +32,10 @@ function core_hook_sanitycheck(&$hookinfo) 'Please check the requirements for your SimpleSAMLphp version and upgrade.'; } - $info = array(); - $mihookinfo = array( + $info = []; + $mihookinfo = [ 'info' => &$info, - ); + ]; $availmodules = SimpleSAML\Module::getModules(); SimpleSAML\Module::callHooks('moduleinfo', $mihookinfo); foreach ($info as $mi => $i) { diff --git a/modules/core/lib/ACL.php b/modules/core/lib/ACL.php index 9339077aa..2c682a3e0 100644 --- a/modules/core/lib/ACL.php +++ b/modules/core/lib/ACL.php @@ -156,7 +156,7 @@ class ACL $attributeName = array_shift($rule); if (!array_key_exists($attributeName, $attributes)) { - $attributeValues = array(); + $attributeValues = []; } else { $attributeValues = $attributes[$attributeName]; } @@ -196,7 +196,7 @@ class ACL $attributeName = array_shift($rule); if (!array_key_exists($attributeName, $attributes)) { - $attributeValues = array(); + $attributeValues = []; } else { $attributeValues = $attributes[$attributeName]; } @@ -237,7 +237,7 @@ class ACL $attributeName = array_shift($rule); if (!array_key_exists($attributeName, $attributes)) { - $attributeValues = array(); + $attributeValues = []; } else { $attributeValues = $attributes[$attributeName]; } @@ -264,7 +264,7 @@ class ACL $attributeName = array_shift($rule); if (!array_key_exists($attributeName, $attributes)) { - $attributeValues = array(); + $attributeValues = []; } else { $attributeValues = $attributes[$attributeName]; } diff --git a/modules/core/lib/Auth/Process/AttributeAdd.php b/modules/core/lib/Auth/Process/AttributeAdd.php index 076287f9f..deb3ac310 100644 --- a/modules/core/lib/Auth/Process/AttributeAdd.php +++ b/modules/core/lib/Auth/Process/AttributeAdd.php @@ -23,7 +23,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter * * Assiciative array of arrays. */ - private $attributes = array(); + private $attributes = []; /** * Initialize this filter. @@ -48,7 +48,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter } if (!is_array($values)) { - $values = array($values); + $values = [$values]; } foreach ($values as $value) { if (!is_string($value)) { diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index d17c74d29..0d181a0d7 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -135,7 +135,7 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter if ($this->replace) { // replace the whole value foreach ($attributes[$this->subject] as &$value) { - $matches = array(); + $matches = []; if (preg_match($this->pattern, $value, $matches) > 0) { $new_value = $matches[0]; @@ -146,15 +146,15 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter if ($this->subject === $this->target) { $value = $new_value; } else { - $attributes[$this->target] = array($new_value); + $attributes[$this->target] = [$new_value]; } } } } elseif ($this->remove) { // remove the whole value - $removedAttrs = array(); + $removedAttrs = []; foreach ($attributes[$this->subject] as $value) { - $matches = array(); + $matches = []; if (preg_match($this->pattern, $value, $matches) > 0) { $removedAttrs[] = $value; } diff --git a/modules/core/lib/Auth/Process/AttributeCopy.php b/modules/core/lib/Auth/Process/AttributeCopy.php index 127eafec6..1b54da17a 100644 --- a/modules/core/lib/Auth/Process/AttributeCopy.php +++ b/modules/core/lib/Auth/Process/AttributeCopy.php @@ -23,7 +23,7 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter /** * Assosiative array with the mappings of attribute names. */ - private $map = array(); + private $map = []; /** * Initialize this filter, parse configuration diff --git a/modules/core/lib/Auth/Process/AttributeLimit.php b/modules/core/lib/Auth/Process/AttributeLimit.php index f5ba3aaca..b90d1b0cd 100644 --- a/modules/core/lib/Auth/Process/AttributeLimit.php +++ b/modules/core/lib/Auth/Process/AttributeLimit.php @@ -14,7 +14,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter /** * List of attributes which this filter will allow through. */ - private $allowedAttributes = array(); + private $allowedAttributes = []; /** * Whether the 'attributes' option in the metadata takes precedence. @@ -134,7 +134,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter private function filterAttributeValues(array $values, array $allowedConfigValues) { if (array_key_exists('regex', $allowedConfigValues) && $allowedConfigValues['regex'] === true) { - $matchedValues = array(); + $matchedValues = []; foreach ($allowedConfigValues as $option => $pattern) { if (!is_int($option)) { // Ignore any configuration options in $allowedConfig. e.g. regex=>true diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php index 42ab19263..cedde6877 100644 --- a/modules/core/lib/Auth/Process/AttributeMap.php +++ b/modules/core/lib/Auth/Process/AttributeMap.php @@ -14,7 +14,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter /** * Associative array with the mappings of attribute names. */ - private $map = array(); + private $map = []; /** * Should attributes be duplicated or renamed. @@ -35,7 +35,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter parent::__construct($config, $reserved); assert(is_array($config)); - $mapFiles = array(); + $mapFiles = []; foreach ($config as $origName => $newName) { if (is_int($origName)) { @@ -117,7 +117,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($request)); assert(array_key_exists('Attributes', $request)); - $mapped_attributes = array(); + $mapped_attributes = []; foreach ($request['Attributes'] as $name => $values) { if (array_key_exists($name, $this->map)) { diff --git a/modules/core/lib/Auth/Process/AttributeRealm.php b/modules/core/lib/Auth/Process/AttributeRealm.php index 866dbb0dc..f6366e9fe 100644 --- a/modules/core/lib/Auth/Process/AttributeRealm.php +++ b/modules/core/lib/Auth/Process/AttributeRealm.php @@ -53,6 +53,6 @@ class AttributeRealm extends \SimpleSAML\Auth\ProcessingFilter if (count($decomposed) !== 2) { return; } - $request['Attributes'][$this->attributename] = array($decomposed[1]); + $request['Attributes'][$this->attributename] = [$decomposed[1]]; } } diff --git a/modules/core/lib/Auth/Process/AttributeValueMap.php b/modules/core/lib/Auth/Process/AttributeValueMap.php index 15dce8e16..9979ea66f 100644 --- a/modules/core/lib/Auth/Process/AttributeValueMap.php +++ b/modules/core/lib/Auth/Process/AttributeValueMap.php @@ -24,7 +24,7 @@ class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter /** * The required $sourceattribute values and target affiliations. */ - private $values = array(); + private $values = []; /** * Whether $sourceattribute should be kept or not. @@ -114,12 +114,12 @@ class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter } $sourceattribute = $attributes[$this->sourceattribute]; - $targetvalues = array(); + $targetvalues = []; if (is_array($sourceattribute)) { foreach ($this->values as $value => $values) { if (!is_array($values)) { - $values = array($values); + $values = [$values]; } if (count(array_intersect($values, $sourceattribute)) > 0) { \SimpleSAML\Logger::debug("AttributeValueMap: intersect match for '$value'"); diff --git a/modules/core/lib/Auth/Process/Cardinality.php b/modules/core/lib/Auth/Process/Cardinality.php index 772c3a469..ac4f1aad1 100644 --- a/modules/core/lib/Auth/Process/Cardinality.php +++ b/modules/core/lib/Auth/Process/Cardinality.php @@ -14,10 +14,10 @@ use SimpleSAML\Utils\HttpAdapter; class Cardinality extends \SimpleSAML\Auth\ProcessingFilter { /** @var array Associative array with the mappings of attribute names. */ - private $cardinality = array(); + private $cardinality = []; /** @var array Entities that should be ignored */ - private $ignoreEntities = array(); + private $ignoreEntities = []; /** @var HTTPAdapter */ private $http; @@ -46,7 +46,7 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter if (!is_string($attribute)) { throw new \SimpleSAML\Error\Exception('Invalid attribute name: '.var_export($attribute, true)); } - $this->cardinality[$attribute] = array('warn' => false); + $this->cardinality[$attribute] = ['warn' => false]; /* allow either positional or name-based parameters */ if (isset($rules[0])) { @@ -118,7 +118,7 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter continue; } if (!is_array($v)) { - $v = array($v); + $v = [$v]; } /* minimum cardinality */ @@ -134,10 +134,10 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter ) ); } else { - $request['core:cardinality:errorAttributes'][$k] = array( + $request['core:cardinality:errorAttributes'][$k] = [ count($v), $this->cardinality[$k]['_expr'] - ); + ]; } continue; } @@ -155,10 +155,10 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter ) ); } else { - $request['core:cardinality:errorAttributes'][$k] = array( + $request['core:cardinality:errorAttributes'][$k] = [ count($v), $this->cardinality[$k]['_expr'] - ); + ]; } continue; } @@ -176,10 +176,10 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter $entityid )); } else { - $request['core:cardinality:errorAttributes'][$k] = array( + $request['core:cardinality:errorAttributes'][$k] = [ 0, $this->cardinality[$k]['_expr'] - ); + ]; } } @@ -187,7 +187,7 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter if (array_key_exists('core:cardinality:errorAttributes', $request)) { $id = \SimpleSAML\Auth\State::saveState($request, 'core:cardinality'); $url = \SimpleSAML\Module::getModuleURL('core/cardinality_error.php'); - $this->http->redirectTrustedURL($url, array('StateId' => $id)); + $this->http->redirectTrustedURL($url, ['StateId' => $id]); return; } } diff --git a/modules/core/lib/Auth/Process/CardinalitySingle.php b/modules/core/lib/Auth/Process/CardinalitySingle.php index da120934d..ac251319b 100644 --- a/modules/core/lib/Auth/Process/CardinalitySingle.php +++ b/modules/core/lib/Auth/Process/CardinalitySingle.php @@ -17,19 +17,19 @@ use SimpleSAML\Utils\HttpAdapter; class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter { /** @var array Attributes that should be single-valued or we generate an error */ - private $singleValued = array(); + private $singleValued = []; /** @var array Attributes for which the first value should be taken */ - private $firstValue = array(); + private $firstValue = []; /** @var array Attributes that can be flattened to a single value */ - private $flatten = array(); + private $flatten = []; /** @var string Separator for flattened value */ private $flattenWith = ';'; /** @var array Entities that should be ignored */ - private $ignoreEntities = array(); + private $ignoreEntities = []; /** @var HTTPAdapter */ private $http; @@ -100,15 +100,15 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter } if (in_array($k, $this->singleValued)) { - $request['core:cardinality:errorAttributes'][$k] = array(count($v), '0 ≤ n ≤ 1'); + $request['core:cardinality:errorAttributes'][$k] = [count($v), '0 ≤ n ≤ 1']; continue; } if (in_array($k, $this->firstValue)) { - $request['Attributes'][$k] = array(array_shift($v)); + $request['Attributes'][$k] = [array_shift($v)]; continue; } if (in_array($k, $this->flatten)) { - $request['Attributes'][$k] = array(implode($this->flattenWith, $v)); + $request['Attributes'][$k] = [implode($this->flattenWith, $v)]; continue; } } @@ -117,7 +117,7 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter if (array_key_exists('core:cardinality:errorAttributes', $request)) { $id = \SimpleSAML\Auth\State::saveState($request, 'core:cardinality'); $url = \SimpleSAML\Module::getModuleURL('core/cardinality_error.php'); - $this->http->redirectTrustedURL($url, array('StateId' => $id)); + $this->http->redirectTrustedURL($url, ['StateId' => $id]); return; } } diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php index c8069eb31..ab9d15aad 100644 --- a/modules/core/lib/Auth/Process/GenerateGroups.php +++ b/modules/core/lib/Auth/Process/GenerateGroups.php @@ -30,11 +30,11 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter if (count($config) === 0) { // Use default groups - $this->generateGroupsFrom = array( + $this->generateGroupsFrom = [ 'eduPersonAffiliation', 'eduPersonOrgUnitDN', 'eduPersonEntitlement', - ); + ]; } else { // Validate configuration foreach ($config as $attributeName) { @@ -57,7 +57,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($request)); assert(array_key_exists('Attributes', $request)); - $groups = array(); + $groups = []; $attributes = &$request['Attributes']; $realm = self::getRealm($attributes); diff --git a/modules/core/lib/Auth/Process/LanguageAdaptor.php b/modules/core/lib/Auth/Process/LanguageAdaptor.php index bcd4210fb..771fb6357 100644 --- a/modules/core/lib/Auth/Process/LanguageAdaptor.php +++ b/modules/core/lib/Auth/Process/LanguageAdaptor.php @@ -62,7 +62,7 @@ class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter \SimpleSAML\Locale\Language::setLanguageCookie($attrlang); } elseif (!isset($attrlang) && isset($lang)) { // Language set in cookie, but not in attribute. Update attribute - $request['Attributes'][$this->langattr] = array($lang); + $request['Attributes'][$this->langattr] = [$lang]; } } } diff --git a/modules/core/lib/Auth/Process/ScopeAttribute.php b/modules/core/lib/Auth/Process/ScopeAttribute.php index 46605783a..1db7d3c18 100644 --- a/modules/core/lib/Auth/Process/ScopeAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeAttribute.php @@ -78,7 +78,7 @@ class ScopeAttribute extends \SimpleSAML\Auth\ProcessingFilter } if (!isset($attributes[$this->targetAttribute])) { - $attributes[$this->targetAttribute] = array(); + $attributes[$this->targetAttribute] = []; } if ($this->onlyIfEmpty && count($attributes[$this->targetAttribute]) > 0) { diff --git a/modules/core/lib/Auth/Process/ScopeFromAttribute.php b/modules/core/lib/Auth/Process/ScopeFromAttribute.php index 8497fbb05..b043de9fd 100644 --- a/modules/core/lib/Auth/Process/ScopeFromAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeFromAttribute.php @@ -80,7 +80,7 @@ class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter $scopeIndex = strrpos($sourceAttrVal, '@'); if ($scopeIndex !== false) { - $attributes[$this->targetAttribute] = array(); + $attributes[$this->targetAttribute] = []; $scope = substr($sourceAttrVal, $scopeIndex + 1); $attributes[$this->targetAttribute][] = $scope; \SimpleSAML\Logger::debug('ScopeFromAttribute: Inserted new attribute '. diff --git a/modules/core/lib/Auth/Process/TargetedID.php b/modules/core/lib/Auth/Process/TargetedID.php index 99ebdc04e..5ea29bec7 100644 --- a/modules/core/lib/Auth/Process/TargetedID.php +++ b/modules/core/lib/Auth/Process/TargetedID.php @@ -139,7 +139,7 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter $nameId = $uid; } - $state['Attributes']['eduPersonTargetedID'] = array($nameId); + $state['Attributes']['eduPersonTargetedID'] = [$nameId]; } /** diff --git a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php index 6e6d392b9..1d488b9db 100644 --- a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php +++ b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php @@ -48,6 +48,6 @@ class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter // Save state and redirect $id = \SimpleSAML\Auth\State::saveState($state, 'core:short_sso_interval'); $url = \SimpleSAML\Module::getModuleURL('core/short_sso_interval.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/core/lib/Auth/Source/AdminPassword.php b/modules/core/lib/Auth/Source/AdminPassword.php index e7e118746..45ce4c269 100644 --- a/modules/core/lib/Auth/Source/AdminPassword.php +++ b/modules/core/lib/Auth/Source/AdminPassword.php @@ -60,6 +60,6 @@ class AdminPassword extends \SimpleSAML\Module\core\Auth\UserPassBase if (!\SimpleSAML\Utils\Crypto::pwValid($adminPassword, $password)) { throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); } - return array('user' => array('admin')); + return ['user' => ['admin']]; } } diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php index eb426d19d..5f0ee4ffa 100644 --- a/modules/core/lib/Auth/UserPassBase.php +++ b/modules/core/lib/Auth/UserPassBase.php @@ -217,7 +217,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source * state array as a parameter to the login form. */ $url = \SimpleSAML\Module::getModuleURL('core/loginuserpass.php'); - $params = array('AuthState' => $id); + $params = ['AuthState' => $id]; \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $params); // The previous function never returns, so this code is never executed. diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php index d7a718cd8..33168524c 100644 --- a/modules/core/lib/Auth/UserPassOrgBase.php +++ b/modules/core/lib/Auth/UserPassOrgBase.php @@ -130,7 +130,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source */ protected function setUsernameOrgMethod($usernameOrgMethod) { - assert(in_array($usernameOrgMethod, array('none', 'allow', 'force'), true)); + assert(in_array($usernameOrgMethod, ['none', 'allow', 'force'], true)); $this->usernameOrgMethod = $usernameOrgMethod; } @@ -205,7 +205,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source $id = \SimpleSAML\Auth\State::saveState($state, self::STAGEID); $url = \SimpleSAML\Module::getModuleURL('core/loginuserpassorg.php'); - $params = array('AuthState' => $id); + $params = ['AuthState' => $id]; \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, $params); } diff --git a/modules/core/lib/Stats/Output/Log.php b/modules/core/lib/Stats/Output/Log.php index 41d04ddf7..e3eff8666 100644 --- a/modules/core/lib/Stats/Output/Log.php +++ b/modules/core/lib/Stats/Output/Log.php @@ -24,7 +24,7 @@ class Log extends \SimpleSAML\Stats\Output public function __construct(\SimpleSAML\Configuration $config) { $logLevel = $config->getString('level', 'notice'); - $this->logger = array('\SimpleSAML\Logger', $logLevel); + $this->logger = ['\SimpleSAML\Logger', $logLevel]; if (!is_callable($this->logger)) { throw new \Exception('Invalid log level: '.var_export($logLevel, true)); } diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php index 46da86828..4360d5e84 100644 --- a/modules/core/lib/Storage/SQLPermanentStorage.php +++ b/modules/core/lib/Storage/SQLPermanentStorage.php @@ -73,10 +73,10 @@ class SQLPermanentStorage $query = "INSERT INTO data (key1, key2, type, created, updated, expire, value)". " VALUES(:key1, :key2, :type, :created, :updated, :expire, :value)"; $prepared = $this->db->prepare($query); - $data = array(':key1' => $key1, ':key2' => $key2, + $data = [':key1' => $key1, ':key2' => $key2, ':type' => $type, ':created' => time(), ':updated' => time(), ':expire' => $expire, - ':value' => serialize($value)); + ':value' => serialize($value)]; $prepared->execute($data); $results = $prepared->fetchAll(\PDO::FETCH_ASSOC); return $results; @@ -89,9 +89,9 @@ class SQLPermanentStorage $query = "UPDATE data SET updated = :updated, value = :value, ". "expire = :expire WHERE key1 = :key1 AND key2 = :key2 AND type = :type"; $prepared = $this->db->prepare($query); - $data = array(':key1' => $key1, ':key2' => $key2, + $data = [':key1' => $key1, ':key2' => $key2, ':type' => $type, ':updated' => time(), - ':expire' => $expire, ':value' => serialize($value)); + ':expire' => $expire, ':value' => serialize($value)]; $prepared->execute($data); $results = $prepared->fetchAll(\PDO::FETCH_ASSOC); return $results; @@ -130,7 +130,7 @@ class SQLPermanentStorage { $query = 'SELECT * FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2 LIMIT 1'; $prepared = $this->db->prepare($query); - $data = array(':type' => $type, ':key1' => $key1, ':key2' => $key2); + $data = [':type' => $type, ':key1' => $key1, ':key2' => $key2]; $prepared->execute($data); $results = $prepared->fetchAll(\PDO::FETCH_ASSOC); return (count($results) == 1); @@ -156,14 +156,14 @@ class SQLPermanentStorage public function getKeys($type = null, $key1 = null, $key2 = null, $whichKey = 'type') { - if (!in_array($whichKey, array('key1', 'key2', 'type'), true)) { + if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) { throw new \Exception('Invalid key type'); } $conditions = $this->getCondition($type, $key1, $key2); $query = 'SELECT DISTINCT :whichKey FROM data WHERE '.$conditions; $prepared = $this->db->prepare($query); - $data = array('whichKey' => $whichKey); + $data = ['whichKey' => $whichKey]; $prepared->execute($data); $results = $prepared->fetchAll(\PDO::FETCH_ASSOC); @@ -171,7 +171,7 @@ class SQLPermanentStorage return null; } - $resarray = array(); + $resarray = []; foreach ($results as $key => $value) { $resarray[] = $value[$whichKey]; } @@ -182,7 +182,7 @@ class SQLPermanentStorage { $query = 'DELETE FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2'; $prepared = $this->db->prepare($query); - $data = array(':type' => $type, ':key1' => $key1, ':key2' => $key2); + $data = [':type' => $type, ':key1' => $key1, ':key2' => $key2]; $prepared->execute($data); $results = $prepared->fetchAll(\PDO::FETCH_ASSOC); return (count($results) == 1); @@ -192,7 +192,7 @@ class SQLPermanentStorage { $query = "DELETE FROM data WHERE expire IS NOT NULL AND expire < :expire"; $prepared = $this->db->prepare($query); - $data = array(':expire' => time()); + $data = [':expire' => time()]; $prepared->execute($data); return $prepared->rowCount(); } @@ -202,7 +202,7 @@ class SQLPermanentStorage */ private function getCondition($type = null, $key1 = null, $key2 = null) { - $conditions = array(); + $conditions = []; if (!is_null($type)) { $conditions[] = "type = ".$this->db->quote($type); } diff --git a/modules/core/templates/cardinality_error.tpl.php b/modules/core/templates/cardinality_error.tpl.php index 036f06a67..6dd78aa1b 100644 --- a/modules/core/templates/cardinality_error.tpl.php +++ b/modules/core/templates/cardinality_error.tpl.php @@ -25,7 +25,7 @@ foreach ($this->data['cardinalityErrorAttributes'] as $attr => $v) { echo '<dt>'.$attr.'</td><dd>'; echo $this->t( '{core:cardinality:got_want}', - array('%GOT%' => $v[0], '%WANT%' => htmlspecialchars($v[1])) + ['%GOT%' => $v[0], '%WANT%' => htmlspecialchars($v[1])] ); echo '</dd></tr>'; } diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php index 2516c065a..6bdce0211 100644 --- a/modules/core/templates/frontpage_federation.tpl.php +++ b/modules/core/templates/frontpage_federation.tpl.php @@ -51,7 +51,7 @@ if (is_array($this->data['metaentries']['remote']) && count($this->data['metaent htmlspecialchars( SimpleSAML\Module::getModuleURL( 'core/show_metadata.php', - array('entityid' => $entry['entityid'], 'set' => $setkey) + ['entityid' => $entry['entityid'], 'set' => $setkey] ) ).'">'); if (!empty($entry['name'])) { diff --git a/modules/core/templates/logout-iframe.php b/modules/core/templates/logout-iframe.php index 59e6ae770..54ca2c182 100644 --- a/modules/core/templates/logout-iframe.php +++ b/modules/core/templates/logout-iframe.php @@ -5,24 +5,24 @@ $type = $this->data['type']; $from = $this->data['from']; $SPs = $this->data['SPs']; -$stateImage = array( +$stateImage = [ 'unsupported' => '/'.$this->data['baseurlpath'].'resources/icons/silk/delete.png', 'completed' => '/'.$this->data['baseurlpath'].'resources/icons/silk/accept.png', 'onhold' => '/'.$this->data['baseurlpath'].'resources/icons/bullet16_grey.png', 'inprogress' => '/'.$this->data['baseurlpath'].'resources/progress.gif', 'failed' => '/'.$this->data['baseurlpath'].'resources/icons/silk/exclamation.png', -); +]; -$stateText = array( +$stateText = [ 'unsupported' => '', 'completed' => $this->t('{logout:completed}'), 'onhold' => '', 'inprogress' => $this->t('{logout:progress}'), 'failed' => $this->t('{logout:failed}'), -); +]; -$spStatus = array(); -$spTimeout = array(); +$spStatus = []; +$spTimeout = []; $nFailed = 0; $nProgress = 0; foreach ($SPs as $assocId => $sp) { @@ -78,7 +78,7 @@ if ($from !== null) { echo '<div><img style="float: left; margin-right: 12px" src="/'.$this->data['baseurlpath']. 'resources/icons/checkmark.48x48.png" alt="Successful logout" />'; echo '<p style="padding-top: 16px; ">'. - $this->t('{logout:loggedoutfrom}', array('%SP%' => '<strong>'.htmlspecialchars($from).'</strong>')).'</p>'; + $this->t('{logout:loggedoutfrom}', ['%SP%' => '<strong>'.htmlspecialchars($from).'</strong>']).'</p>'; echo '<p style="height: 0px; clear: left;"></p></div>'; } @@ -117,7 +117,7 @@ foreach ($SPs as $assocId => $sp) { } if (isset($from)) { - $logoutCancelText = $this->t('{logout:logout_only}', array('%SP%' => htmlspecialchars($from))); + $logoutCancelText = $this->t('{logout:logout_only}', ['%SP%' => htmlspecialchars($from)]); } else { $logoutCancelText = $this->t('{logout:no}'); } diff --git a/modules/core/www/as_login.php b/modules/core/www/as_login.php index 14d8b1dc9..d73fa8ca0 100644 --- a/modules/core/www/as_login.php +++ b/modules/core/www/as_login.php @@ -17,9 +17,9 @@ if (!isset($_REQUEST['AuthId'])) { /* * Setting up the options for the requireAuth() call later.. */ -$options = array( +$options = [ 'ReturnTo' => \SimpleSAML\Utils\HTTP::checkURLAllowed($_REQUEST['ReturnTo']), -); +]; /* * Allows a saml:idp query string parameter specify the IdP entity ID to be used diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php index df978a8f1..e1484e1fe 100644 --- a/modules/core/www/authenticate.php +++ b/modules/core/www/authenticate.php @@ -28,11 +28,11 @@ if (array_key_exists(\SimpleSAML\Auth\State::EXCEPTION_PARAM, $_REQUEST)) { } if (!$as->isAuthenticated()) { - $url = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId)); - $params = array( + $url = \SimpleSAML\Module::getModuleURL('core/authenticate.php', ['as' => $asId]); + $params = [ 'ErrorURL' => $url, 'ReturnTo' => $url, - ); + ]; $as->login($params); } diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php index 9c14a8215..b3a3e5b99 100644 --- a/modules/core/www/cardinality_error.php +++ b/modules/core/www/cardinality_error.php @@ -22,7 +22,7 @@ $t->data['cardinalityErrorAttributes'] = $state['core:cardinality:errorAttribute if (isset($state['Source']['auth'])) { $t->data['LogoutURL'] = \SimpleSAML\Module::getModuleURL( 'core/authenticate.php', - array('as' => $state['Source']['auth']) + ['as' => $state['Source']['auth']] )."&logout"; } header('HTTP/1.0 403 Forbidden'); diff --git a/modules/core/www/cleardiscochoices.php b/modules/core/www/cleardiscochoices.php index afc794a0e..f997f1607 100644 --- a/modules/core/www/cleardiscochoices.php +++ b/modules/core/www/cleardiscochoices.php @@ -20,7 +20,7 @@ foreach ($_COOKIE as $cookieName => $value) { /* Delete the cookie. We delete it once without the secure flag and once with the secure flag. This * ensures that the cookie will be deleted in any case. */ - \SimpleSAML\Utils\HTTP::setCookie($cookieName, null, array('path' => $cookiePath, 'httponly' => false), false); + \SimpleSAML\Utils\HTTP::setCookie($cookieName, null, ['path' => $cookiePath, 'httponly' => false], false); } // Find where we should go now. diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php index 804f3cd6f..081151788 100644 --- a/modules/core/www/frontpage_auth.php +++ b/modules/core/www/frontpage_auth.php @@ -12,24 +12,24 @@ $loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); $isadmin = \SimpleSAML\Utils\Auth::isAdmin(); $logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); -$links = array(); -$links_welcome = array(); -$links_config = array(); -$links_auth = array(); -$links_federation = array(); +$links = []; +$links_welcome = []; +$links_config = []; +$links_auth = []; +$links_federation = []; -$links_auth[] = array( +$links_auth[] = [ 'href' => 'login.php', 'text' => '{core:frontpage:authtest}', -); +]; -$allLinks = array( +$allLinks = [ 'links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation, -); +]; \SimpleSAML\Module::callHooks('frontpage', $allLinks); $t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_auth.tpl.php'); diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php index ae7a7d6ba..dbd9a87b9 100644 --- a/modules/core/www/frontpage_config.php +++ b/modules/core/www/frontpage_config.php @@ -12,7 +12,7 @@ $loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); $isadmin = \SimpleSAML\Utils\Auth::isAdmin(); $logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); -$warnings = array(); +$warnings = []; if (!\SimpleSAML\Utils\HTTP::isHTTPS()) { $warnings[] = '{core:frontpage:warnings_https}'; @@ -29,29 +29,29 @@ if (extension_loaded('suhosin')) { } } -$links = array(); -$links_welcome = array(); -$links_config = array(); -$links_auth = array(); -$links_federation = array(); +$links = []; +$links_welcome = []; +$links_config = []; +$links_auth = []; +$links_federation = []; -$links_config[] = array( +$links_config[] = [ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL().'admin/hostnames.php', 'text' => '{core:frontpage:link_diagnostics}' -); +]; -$links_config[] = array( +$links_config[] = [ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL().'admin/phpinfo.php', 'text' => '{core:frontpage:link_phpinfo}' -); +]; -$allLinks = array( +$allLinks = [ 'links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation, -); +]; \SimpleSAML\Module::callHooks('frontpage', $allLinks); // Check for updates. Store the remote result in the session so we @@ -82,62 +82,62 @@ if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master') if ($latest && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) { $outdated = true; - $warnings[] = array( + $warnings[] = [ '{core:frontpage:warnings_outdated}', - array('%LATEST_URL%' => $latest['html_url']) - ); + ['%LATEST_URL%' => $latest['html_url']] + ]; } } } -$enablematrix = array( +$enablematrix = [ 'saml20idp' => $config->getBoolean('enable.saml20-idp', false), 'shib13idp' => $config->getBoolean('enable.shib13-idp', false), -); - - -$functionchecks = array( - 'time' => array('required', 'Date/Time Extension'), - 'hash' => array('required', 'Hashing function'), - 'gzinflate' => array('required', 'ZLib'), - 'openssl_sign' => array('required', 'OpenSSL'), - 'dom_import_simplexml' => array('required', 'XML DOM'), - 'preg_match' => array('required', 'RegEx support'), - 'json_decode' => array('required', 'JSON support'), - 'class_implements' => array('required', 'Standard PHP Library (SPL)'), - 'mb_strlen' => array('required', 'Multibyte String Extension'), - 'curl_init' => array('optional', 'cURL (required if automatic version checks are used, also by some modules.'), - 'session_start' => array('optional', 'Session Extension (required if PHP sessions are used)'), - 'pdo_drivers' => array('optional', 'PDO Extension (required if a database backend is used)'), -); +]; + + +$functionchecks = [ + 'time' => ['required', 'Date/Time Extension'], + 'hash' => ['required', 'Hashing function'], + 'gzinflate' => ['required', 'ZLib'], + 'openssl_sign' => ['required', 'OpenSSL'], + 'dom_import_simplexml' => ['required', 'XML DOM'], + 'preg_match' => ['required', 'RegEx support'], + 'json_decode' => ['required', 'JSON support'], + 'class_implements' => ['required', 'Standard PHP Library (SPL)'], + 'mb_strlen' => ['required', 'Multibyte String Extension'], + 'curl_init' => ['optional', 'cURL (required if automatic version checks are used, also by some modules.'], + 'session_start' => ['optional', 'Session Extension (required if PHP sessions are used)'], + 'pdo_drivers' => ['optional', 'PDO Extension (required if a database backend is used)'], +]; if (\SimpleSAML\Module::isModuleEnabled('ldap')) { - $functionchecks['ldap_bind'] = array('optional', 'LDAP Extension (required if an LDAP backend is used)'); + $functionchecks['ldap_bind'] = ['optional', 'LDAP Extension (required if an LDAP backend is used)']; } if (\SimpleSAML\Module::isModuleEnabled('radius')) { - $functionchecks['radius_auth_open'] = array('optional', 'Radius Extension (required if a Radius backend is used)'); + $functionchecks['radius_auth_open'] = ['optional', 'Radius Extension (required if a Radius backend is used)']; } -$funcmatrix = array(); -$funcmatrix[] = array( +$funcmatrix = []; +$funcmatrix[] = [ 'required' => 'required', 'descr' => 'PHP Version >= 5.4. You run: '.phpversion(), 'enabled' => version_compare(phpversion(), '5.4', '>=') -); +]; foreach ($functionchecks as $func => $descr) { - $funcmatrix[] = array('descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func)); + $funcmatrix[] = ['descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func)]; } -$funcmatrix[] = array( +$funcmatrix[] = [ 'required' => 'optional', 'descr' => 'predis/predis (required if the redis data store is used)', 'enabled' => class_exists('\Predis\Client'), -); +]; -$funcmatrix[] = array( +$funcmatrix[] = [ 'required' => 'optional', 'descr' => 'Memcache or Memcached Extension (required if a Memcached backend is used)', 'enabled' => class_exists('Memcache') || class_exists('Memcached'), -); +]; // Some basic configuration checks @@ -146,21 +146,21 @@ if ($config->getString('technicalcontact_email', 'na@example.org') === 'na@examp } else { $mail_ok = true; } -$funcmatrix[] = array( +$funcmatrix[] = [ 'required' => 'recommended', 'descr' => 'technicalcontact_email option set', 'enabled' => $mail_ok -); +]; if ($config->getString('auth.adminpassword', '123') === '123') { $password_ok = false; } else { $password_ok = true; } -$funcmatrix[] = array( +$funcmatrix[] = [ 'required' => 'required', 'descr' => 'auth.adminpassword option set', 'enabled' => $password_ok -); +]; $t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_config.tpl.php'); $translator = $t->getTranslator(); @@ -189,11 +189,11 @@ $t->data['links_federation'] = $links_federation; $t->data['enablematrix'] = $enablematrix; $t->data['funcmatrix'] = $funcmatrix; -$t->data['requiredmap'] = array( +$t->data['requiredmap'] = [ 'recommended' => $translator->noop('{core:frontpage:recommended}'), 'required' => $translator->noop('{core:frontpage:required}'), 'optional' => $translator->noop('{core:frontpage:optional}'), -); +]; $t->data['version'] = $config->getVersion(); $t->data['directory'] = dirname(dirname(dirname(dirname(__FILE__)))); diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php index 74d5bbb5d..1d00be38e 100644 --- a/modules/core/www/frontpage_federation.php +++ b/modules/core/www/frontpage_federation.php @@ -12,42 +12,42 @@ $logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); $loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); $isadmin = \SimpleSAML\Utils\Auth::isAdmin(); -$links = array(); -$links_welcome = array(); -$links_config = array(); -$links_auth = array(); -$links_federation = array(); +$links = []; +$links_welcome = []; +$links_config = []; +$links_auth = []; +$links_federation = []; if ($config->getBoolean('idpdisco.enableremember', false)) { - $links_federation[] = array( + $links_federation[] = [ 'href' => 'cleardiscochoices.php', 'text' => '{core:frontpage:link_cleardiscochoices}', - ); + ]; } -$links_federation[] = array( +$links_federation[] = [ 'href' => \SimpleSAML\Utils\HTTP::getBaseURL().'admin/metadata-converter.php', 'text' => '{core:frontpage:link_xmlconvert}', -); +]; -$allLinks = array( +$allLinks = [ 'links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation, -); +]; \SimpleSAML\Module::callHooks('frontpage', $allLinks); -$metadataHosted = array(); +$metadataHosted = []; \SimpleSAML\Module::callHooks('metadata_hosted', $metadataHosted); $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); -$metaentries = array('hosted' => $metadataHosted, 'remote' => array()); +$metaentries = ['hosted' => $metadataHosted, 'remote' => []]; if ($isadmin) { @@ -84,7 +84,7 @@ if ($config->getBoolean('enable.adfs-idp', false) === true) { $metaentries['hosted']['adfs-idp'] = $metadata->getMetaDataCurrent('adfs-idp-hosted'); $metaentries['hosted']['adfs-idp']['metadata-url'] = \SimpleSAML\Module::getModuleURL( 'adfs/idp/metadata.php', - array('output' => 'xhtml') + ['output' => 'xhtml'] ); if ($isadmin) { $metaentries['remote']['adfs-sp-remote'] = $metadata->getList('adfs-sp-remote'); @@ -107,11 +107,11 @@ $language = $translator->getLanguage()->getLanguage(); $fallbackLanguage = 'en'; $defaultLanguage = $config->getString('language.default', $fallbackLanguage); -$translators = array( +$translators = [ 'name' => 'name_translated', 'descr' => 'descr_translated', 'OrganizationDisplayName' => 'organizationdisplayname_translated', -); +]; foreach ($metaentries['hosted'] as $index => $entity) { foreach ($translators as $old => $new) { @@ -141,7 +141,7 @@ foreach ($metaentries['remote'] as $key => $set) { } # look up translated string -$mtype = array( +$mtype = [ 'saml20-sp-remote' => $translator->noop('{admin:metadata_saml20-sp}'), 'saml20-sp-hosted' => $translator->noop('{admin:metadata_saml20-sp}'), 'saml20-idp-remote' => $translator->noop('{admin:metadata_saml20-idp}'), @@ -154,7 +154,7 @@ $mtype = array( 'adfs-sp-hosted' => $translator->noop('{admin:metadata_adfs-sp}'), 'adfs-idp-remote' => $translator->noop('{admin:metadata_adfs-idp}'), 'adfs-idp-hosted' => $translator->noop('{admin:metadata_adfs-idp}'), -); +]; $t->data['pageid'] = 'frontpage_federation'; $t->data['isadmin'] = $isadmin; diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php index 9650fb372..4dfb4fef1 100644 --- a/modules/core/www/frontpage_welcome.php +++ b/modules/core/www/frontpage_welcome.php @@ -12,24 +12,24 @@ $logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); $loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); $isadmin = \SimpleSAML\Utils\Auth::isAdmin(); -$links = array(); -$links_welcome = array(); -$links_config = array(); -$links_auth = array(); -$links_federation = array(); +$links = []; +$links_welcome = []; +$links_config = []; +$links_auth = []; +$links_federation = []; -$allLinks = array( +$allLinks = [ 'links' => &$links, 'welcome' => &$links_welcome, 'config' => &$links_config, 'auth' => &$links_auth, 'federation' => &$links_federation, -); +]; -$links_welcome[] = array( +$links_welcome[] = [ 'href' => 'https://simplesamlphp.org/docs/stable/', 'text' => '{core:frontpage:doc_header}', -); +]; \SimpleSAML\Module::callHooks('frontpage', $allLinks); diff --git a/modules/core/www/idp/logout-iframe-done.php b/modules/core/www/idp/logout-iframe-done.php index a01665a64..7725754e4 100644 --- a/modules/core/www/idp/logout-iframe-done.php +++ b/modules/core/www/idp/logout-iframe-done.php @@ -10,13 +10,13 @@ $associations = $idp->getAssociations(); if (!isset($_REQUEST['cancel'])) { \SimpleSAML\Logger::stats('slo-iframe done'); - \SimpleSAML\Stats::log('core:idp:logout-iframe:page', array('type' => 'done')); + \SimpleSAML\Stats::log('core:idp:logout-iframe:page', ['type' => 'done']); $SPs = $state['core:Logout-IFrame:Associations']; } else { // user skipped global logout \SimpleSAML\Logger::stats('slo-iframe skip'); - \SimpleSAML\Stats::log('core:idp:logout-iframe:page', array('type' => 'skip')); - $SPs = array(); // no SPs should have been logged out + \SimpleSAML\Stats::log('core:idp:logout-iframe:page', ['type' => 'skip']); + $SPs = []; // no SPs should have been logged out $state['core:Failed'] = true; // mark as partial logout } @@ -49,7 +49,7 @@ foreach ($SPs as $assocId => $sp) { $spId = $assocId; } \SimpleSAML\Logger::stats('slo-iframe-fail '.$spId); - \SimpleSAML\Stats::log('core:idp:logout-iframe:spfail', array('sp' => $spId)); + \SimpleSAML\Stats::log('core:idp:logout-iframe:spfail', ['sp' => $spId]); $state['core:Failed'] = true; } } diff --git a/modules/core/www/idp/logout-iframe-post.php b/modules/core/www/idp/logout-iframe-post.php index 603cb1fb5..2081dfe26 100644 --- a/modules/core/www/idp/logout-iframe-post.php +++ b/modules/core/www/idp/logout-iframe-post.php @@ -44,12 +44,12 @@ if ($encryptNameId) { $lr->encryptNameId(\SimpleSAML\Module\saml\Message::getEncryptionKey($spMetadata)); } -\SimpleSAML\Stats::log('saml:idp:LogoutRequest:sent', array( +\SimpleSAML\Stats::log('saml:idp:LogoutRequest:sent', [ 'spEntityID' => $association['saml:entityID'], 'idpEntityID' => $idpMetadata->getString('entityid'), -)); +]); -$bindings = array(\SAML2\Constants::BINDING_HTTP_POST); +$bindings = [\SAML2\Constants::BINDING_HTTP_POST]; $dst = $spMetadata->getDefaultEndpoint('SingleLogoutService', $bindings); $binding = \SAML2\Binding::getBinding($dst['Binding']); diff --git a/modules/core/www/idp/logout-iframe.php b/modules/core/www/idp/logout-iframe.php index e844d558e..27195af6b 100644 --- a/modules/core/www/idp/logout-iframe.php +++ b/modules/core/www/idp/logout-iframe.php @@ -6,7 +6,7 @@ if (!isset($_REQUEST['id'])) { if (isset($_REQUEST['type'])) { $type = (string) $_REQUEST['type']; - if (!in_array($type, array('init', 'js', 'nojs', 'embed'), true)) { + if (!in_array($type, ['init', 'js', 'nojs', 'embed'], true)) { throw new \SimpleSAML\Error\BadRequest('Invalid value for type.'); } } else { @@ -15,7 +15,7 @@ if (isset($_REQUEST['type'])) { if ($type !== 'embed') { \SimpleSAML\Logger::stats('slo-iframe '.$type); - \SimpleSAML\Stats::log('core:idp:logout-iframe:page', array('type' => $type)); + \SimpleSAML\Stats::log('core:idp:logout-iframe:page', ['type' => $type]); } $state = \SimpleSAML\Auth\State::loadState($_REQUEST['id'], 'core:Logout-IFrame'); @@ -55,7 +55,7 @@ if ($type !== 'init') { if (!isset($sp['core:Logout-IFrame:Timeout'])) { if (method_exists($sp['Handler'], 'getAssociationConfig')) { $assocIdP = \SimpleSAML\IdP::getByState($sp); - $assocConfig = call_user_func(array($sp['Handler'], 'getAssociationConfig'), $assocIdP, $sp); + $assocConfig = call_user_func([$sp['Handler'], 'getAssociationConfig'], $assocIdP, $sp); $sp['core:Logout-IFrame:Timeout'] = $assocConfig->getInteger('core:logout-timeout', 5) + time(); } else { $sp['core:Logout-IFrame:Timeout'] = time() + 5; @@ -73,7 +73,7 @@ foreach ($state['core:Logout-IFrame:Associations'] as $assocId => &$sp) { try { $assocIdP = \SimpleSAML\IdP::getByState($sp); - $url = call_user_func(array($sp['Handler'], 'getLogoutURL'), $assocIdP, $sp, null); + $url = call_user_func([$sp['Handler'], 'getLogoutURL'], $assocIdP, $sp, null); $sp['core:Logout-IFrame:URL'] = $url; } catch (\Exception $e) { $sp['core:Logout-IFrame:State'] = 'failed'; @@ -91,7 +91,7 @@ if ($state['core:TerminatedAssocId'] !== null) { } // build an array with information about all services currently logged in -$remaining = array(); +$remaining = []; foreach ($state['core:Logout-IFrame:Associations'] as $association) { $key = sha1($association['id']); $mdset = 'saml20-sp-remote'; @@ -99,7 +99,7 @@ foreach ($state['core:Logout-IFrame:Associations'] as $association) { $mdset = 'adfs-sp-remote'; } - $remaining[$key] = array( + $remaining[$key] = [ 'id' => $association['id'], 'expires_on' => $association['Expires'], 'entityID' => $association['saml:entityID'], @@ -107,7 +107,7 @@ foreach ($state['core:Logout-IFrame:Associations'] as $association) { 'status' => $association['core:Logout-IFrame:State'], 'logoutURL' => $association['core:Logout-IFrame:URL'], 'metadata' => $mdh->getMetaDataConfig($association['saml:entityID'], $mdset)->toArray(), - ); + ]; if (isset($association['core:Logout-IFrame:Timeout'])) { $remaining[$key]['timeout'] = $association['core:Logout-IFrame:Timeout']; } @@ -140,7 +140,7 @@ $t->data['SPs'] = $state['core:Logout-IFrame:Associations']; if ($type !== 'nojs') { /** @deprecated The "jquery" array will be removed in 2.0 */ - $t->data['jquery'] = array('core' => true, 'ui' => false, 'css' => false); + $t->data['jquery'] = ['core' => true, 'ui' => false, 'css' => false]; } $t->show(); diff --git a/modules/core/www/login.php b/modules/core/www/login.php index 342787873..53d57ca44 100644 --- a/modules/core/www/login.php +++ b/modules/core/www/login.php @@ -40,11 +40,11 @@ if (array_key_exists(\SimpleSAML\Auth\State::EXCEPTION_PARAM, $_REQUEST)) { } if (!$as->isAuthenticated()) { - $url = \SimpleSAML\Module::getModuleURL('core/login.php', array('as' => $asId)); - $params = array( + $url = \SimpleSAML\Module::getModuleURL('core/login.php', ['as' => $asId]); + $params = [ 'ErrorURL' => $url, 'ReturnTo' => $url, - ); + ]; $as->login($params); } diff --git a/modules/core/www/loginuserpass.php b/modules/core/www/loginuserpass.php index c9569dede..747506f89 100644 --- a/modules/core/www/loginuserpass.php +++ b/modules/core/www/loginuserpass.php @@ -42,12 +42,12 @@ if (array_key_exists('password', $_REQUEST)) { $errorCode = null; $errorParams = null; -$queryParams = array(); +$queryParams = []; if (isset($state['error'])) { $errorCode = $state['error']['code']; $errorParams = $state['error']['params']; - $queryParams = array('AuthState' => $authStateId); + $queryParams = ['AuthState' => $authStateId]; } if (!empty($_REQUEST['username']) || !empty($password)) { @@ -85,12 +85,12 @@ if (!empty($_REQUEST['username']) || !empty($password)) { // Login failed. Extract error code and parameters, to display the error $errorCode = $e->getErrorCode(); $errorParams = $e->getParameters(); - $state['error'] = array( + $state['error'] = [ 'code' => $errorCode, 'params' => $errorParams - ); + ]; $authStateId = \SimpleSAML\Auth\State::saveState($state, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID); - $queryParams = array('AuthState' => $authStateId); + $queryParams = ['AuthState' => $authStateId]; } if (isset($state['error'])) { unset($state['error']); @@ -99,7 +99,7 @@ if (!empty($_REQUEST['username']) || !empty($password)) { $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php'); -$t->data['stateparams'] = array('AuthState' => $authStateId); +$t->data['stateparams'] = ['AuthState' => $authStateId]; if (array_key_exists('forcedUsername', $state)) { $t->data['username'] = $state['forcedUsername']; $t->data['forceUsername'] = true; diff --git a/modules/core/www/loginuserpassorg.php b/modules/core/www/loginuserpassorg.php index 3b480699b..2b9ec4dba 100644 --- a/modules/core/www/loginuserpassorg.php +++ b/modules/core/www/loginuserpassorg.php @@ -55,12 +55,12 @@ if (array_key_exists('organization', $_REQUEST)) { $errorCode = null; $errorParams = null; -$queryParams = array(); +$queryParams = []; if (isset($state['error'])) { $errorCode = $state['error']['code']; $errorParams = $state['error']['params']; - $queryParams = array('AuthState' => $authStateId); + $queryParams = ['AuthState' => $authStateId]; } if ($organizations === null || !empty($organization)) { @@ -107,15 +107,15 @@ if ($organizations === null || !empty($organization)) { // Login failed. Extract error code and parameters, to display the error $errorCode = $e->getErrorCode(); $errorParams = $e->getParameters(); - $state['error'] = array( + $state['error'] = [ 'code' => $errorCode, 'params' => $errorParams - ); + ]; $authStateId = \SimpleSAML\Auth\State::saveState( $state, \SimpleSAML\Module\core\Auth\UserPassOrgBase::STAGEID ); - $queryParams = array('AuthState' => $authStateId); + $queryParams = ['AuthState' => $authStateId]; } if (isset($state['error'])) { unset($state['error']); @@ -125,7 +125,7 @@ if ($organizations === null || !empty($organization)) { $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:loginuserpass.php'); -$t->data['stateparams'] = array('AuthState' => $authStateId); +$t->data['stateparams'] = ['AuthState' => $authStateId]; $t->data['username'] = $username; $t->data['forceUsername'] = false; $t->data['rememberUsernameEnabled'] = $source->getRememberUsernameEnabled(); diff --git a/modules/core/www/short_sso_interval.php b/modules/core/www/short_sso_interval.php index 9844e9c5f..5a937c66c 100644 --- a/modules/core/www/short_sso_interval.php +++ b/modules/core/www/short_sso_interval.php @@ -22,7 +22,7 @@ if (array_key_exists('continue', $_REQUEST)) { $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:short_sso_interval.php'); $t->data['target'] = \SimpleSAML\Module::getModuleURL('core/short_sso_interval.php'); -$t->data['params'] = array('StateId' => $id); +$t->data['params'] = ['StateId' => $id]; $t->data['trackId'] = $session->getTrackID(); $this->data['header'] = $this->t('{core:short_sso_interval:warning_header}'); $this->data['autofocus'] = 'contbutton'; diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php index 2beb26c59..e8f3bf223 100644 --- a/modules/core/www/show_metadata.php +++ b/modules/core/www/show_metadata.php @@ -14,7 +14,7 @@ if (!array_key_exists('set', $_REQUEST)) { } if (!in_array( $_REQUEST['set'], - array('saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote'), + ['saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote'], true )) { throw new Exception('Invalid set'); diff --git a/modules/cron/config-templates/module_cron.php b/modules/cron/config-templates/module_cron.php index fe303c9b8..29a35d9e9 100644 --- a/modules/cron/config-templates/module_cron.php +++ b/modules/cron/config-templates/module_cron.php @@ -3,9 +3,9 @@ * Configuration for the Cron module. */ -$config = array( +$config = [ 'key' => 'secret', - 'allowed_tags' => array('daily', 'hourly', 'frequent'), + 'allowed_tags' => ['daily', 'hourly', 'frequent'], 'debug_message' => true, 'sendemail' => true, -); +]; diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php index 46a7ab954..c9e2eb2dc 100644 --- a/modules/cron/hooks/hook_frontpage.php +++ b/modules/cron/hooks/hook_frontpage.php @@ -10,8 +10,8 @@ function cron_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['config'][] = array( + $links['config'][] = [ 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), 'text' => '{core:frontpage:link_cron}', - ); + ]; } diff --git a/modules/cron/lib/Cron.php b/modules/cron/lib/Cron.php index 169d248be..f8bda653b 100644 --- a/modules/cron/lib/Cron.php +++ b/modules/cron/lib/Cron.php @@ -38,11 +38,11 @@ class Cron throw new \Exception("Invalid cron tag '$tag''"); } - $summary = array(); - $croninfo = array( + $summary = []; + $croninfo = [ 'summary' => &$summary, 'tag' => $tag, - ); + ]; \SimpleSAML\Module::callHooks('cron', $croninfo); diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php index 8479de13f..8a0aac4d5 100644 --- a/modules/cron/www/croninfo.php +++ b/modules/cron/www/croninfo.php @@ -18,20 +18,20 @@ $cronconfig = \SimpleSAML\Configuration::getConfig('module_cron.php'); $key = $cronconfig->getValue('key', ''); $tags = $cronconfig->getValue('allowed_tags'); -$def = array( +$def = [ 'weekly' => "22 0 * * 0", 'daily' => "02 0 * * *", 'hourly' => "01 * * * *", 'default' => "XXXXXXXXXX", -); +]; -$urls = array(); +$urls = []; foreach ($tags as $tag) { - $urls[] = array( - 'href' => \SimpleSAML\Module::getModuleURL('cron/cron.php', array('key' => $key, 'tag' => $tag)), + $urls[] = [ + 'href' => \SimpleSAML\Module::getModuleURL('cron/cron.php', ['key' => $key, 'tag' => $tag]), 'tag' => $tag, 'int' => (array_key_exists($tag, $def) ? $def[$tag] : $def['default']), - ); + ]; } $t = new \SimpleSAML\XHTML\Template($config, 'cron:croninfo.tpl.php', 'cron:cron'); diff --git a/modules/discopower/config-templates/module_discopower.php b/modules/discopower/config-templates/module_discopower.php index dfac25817..498cadad8 100644 --- a/modules/discopower/config-templates/module_discopower.php +++ b/modules/discopower/config-templates/module_discopower.php @@ -3,7 +3,7 @@ * Configuration for the DiscoPower module. */ -$config = array( +$config = [ // Which tab should be set as default. 0 is the first tab 'defaulttab' => 0, @@ -11,7 +11,7 @@ $config = array( * List a set of tags (Tabs) that should be listed in a specific order. * All other available tabs will be listed after the ones specified below. */ - 'taborder' => array('norway'), + 'taborder' => ['norway'], /* * the 'tab' parameter allows you to limit the tabs to a specific list. (excluding unlisted tags) @@ -42,4 +42,4 @@ $config = array( * Example: 'cdc.lifetime' => 180*24*60*60, // 180 days */ 'cdc.lifetime' => null, -); +]; diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index 4e7a39149..a0955cb32 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -110,19 +110,19 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco */ protected function idplistStructured($list) { - $slist = array(); + $slist = []; $order = $this->discoconfig->getValue('taborder'); if (is_array($order)) { foreach ($order as $oe) { - $slist[$oe] = array(); + $slist[$oe] = []; } } $enableTabs = $this->discoconfig->getValue('tabs', null); foreach ($list as $key => $val) { - $tags = array('misc'); + $tags = ['misc']; if (array_key_exists('tags', $val)) { $tags = $val['tags']; } @@ -135,7 +135,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco } foreach ($slist as $tab => $tbslist) { - uasort($slist[$tab], array('\SimpleSAML\Module\discopower\PowerIdPDisco', 'mcmp')); + uasort($slist[$tab], ['\SimpleSAML\Module\discopower\PowerIdPDisco', 'mcmp']); } return $slist; @@ -203,16 +203,16 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $filter = $spmd['discopower.filter']; if (!array_key_exists('entities.include', $filter)) { - $filter['entities.include'] = array(); + $filter['entities.include'] = []; } if (!array_key_exists('entities.exclude', $filter)) { - $filter['entities.exclude'] = array(); + $filter['entities.exclude'] = []; } if (!array_key_exists('tags.include', $filter)) { - $filter['tags.include'] = array(); + $filter['tags.include'] = []; } if (!array_key_exists('tags.exclude', $filter)) { - $filter['tags.exclude'] = array(); + $filter['tags.exclude'] = []; } $defaultrule = true; @@ -222,7 +222,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $defaultrule = false; } - $returnlist = array(); + $returnlist = []; foreach ($list as $key => $entry) { if ($this->processFilter($filter, $entry, $defaultrule)) { $returnlist[$key] = $entry; @@ -247,7 +247,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $preferredIdP = $this->getRecommendedIdP(); $t = new \SimpleSAML\XHTML\Template($this->config, 'discopower:disco.tpl.php', 'disco'); - $discoPowerTabs = array( + $discoPowerTabs = [ 'denmark' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:denmark}'), 'edugain' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:edugain}'), 'finland' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:finland}'), @@ -261,7 +261,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco 'sweden' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:sweden}'), 'switzerland' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:switzerland}'), 'ukacessfederation' => \SimpleSAML\Locale\Translate::noop('{discopower:tabs:ukacessfederation}'), - ); + ]; $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; @@ -299,7 +299,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $t->data['urlpattern'] = htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); $t->data['rememberenabled'] = $this->config->getBoolean('idpdisco.enableremember', false); $t->data['rememberchecked'] = $this->config->getBoolean('idpdisco.rememberchecked', false); - $t->data['jquery'] = array('core' => true, 'ui' => true); + $t->data['jquery'] = ['core' => true, 'ui' => true]; $t->show(); } @@ -371,7 +371,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco private function getCDC() { if (!isset($_COOKIE['_saml_idp'])) { - return array(); + return []; } $ret = (string) $_COOKIE['_saml_idp']; @@ -380,7 +380,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $idp = base64_decode($idp); if ($idp === false) { // not properly base64 encoded - return array(); + return []; } } @@ -427,12 +427,12 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $newCookie = $tmp[1]; } - $params = array( + $params = [ 'lifetime' => $this->cdcLifetime, 'domain' => $this->cdcDomain, 'secure' => true, 'httponly' => false, - ); + ]; \SimpleSAML\Utils\HTTP::setCookie('_saml_idp', $newCookie, $params, false); } diff --git a/modules/discopower/templates/disco.tpl.php b/modules/discopower/templates/disco.tpl.php index 02ae742eb..4174ace4c 100644 --- a/modules/discopower/templates/disco.tpl.php +++ b/modules/discopower/templates/disco.tpl.php @@ -1,7 +1,7 @@ <?php $this->data['header'] = $this->t('selectidp'); -$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); +$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true]; $this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="'. SimpleSAML\Module::getModuleURL('discopower/assets/css/style.css').'" />'; diff --git a/modules/discopower/www/disco.php b/modules/discopower/www/disco.php index 963a9e17b..6a0747871 100644 --- a/modules/discopower/www/disco.php +++ b/modules/discopower/www/disco.php @@ -2,7 +2,7 @@ try { $discoHandler = new \SimpleSAML\Module\discopower\PowerIdPDisco( - array('saml20-idp-remote', 'shib13-idp-remote'), + ['saml20-idp-remote', 'shib13-idp-remote'], 'poweridpdisco' ); } catch (\Exception $exception) { diff --git a/modules/exampleattributeserver/www/attributeserver.php b/modules/exampleattributeserver/www/attributeserver.php index 135cc6a74..5664e415c 100644 --- a/modules/exampleattributeserver/www/attributeserver.php +++ b/modules/exampleattributeserver/www/attributeserver.php @@ -23,10 +23,10 @@ $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'saml20-sp-remote'); $endpoint = $spMetadata->getString('testAttributeEndpoint'); // The attributes we will return -$attributes = array( - 'name' => array('value1', 'value2', 'value3'), - 'test' => array('test'), -); +$attributes = [ + 'name' => ['value1', 'value2', 'value3'], + 'test' => ['test'], +]; // The name format of the attributes $attributeNameFormat = \SAML2\Constants::NAMEFORMAT_UNSPECIFIED; @@ -38,7 +38,7 @@ if (count($returnAttributes) === 0) { $returnAttributes = $attributes; } elseif ($query->getAttributeNameFormat() !== $attributeNameFormat) { SimpleSAML\Logger::debug('Requested attributes with wrong NameFormat - no attributes returned.'); - $returnAttributes = array(); + $returnAttributes = []; } else { foreach ($returnAttributes as $name => $values) { if (!array_key_exists($name, $attributes)) { @@ -63,7 +63,7 @@ $assertion->setIssuer($idpEntityId); $assertion->setNameId($query->getNameId()); $assertion->setNotBefore(time()); $assertion->setNotOnOrAfter(time() + 300); // 60*5 = 5min -$assertion->setValidAudiences(array($spEntityId)); +$assertion->setValidAudiences([$spEntityId]); $assertion->setAttributes($returnAttributes); $assertion->setAttributeNameFormat($attributeNameFormat); @@ -73,7 +73,7 @@ $sc->SubjectConfirmationData = new \SAML2\XML\saml\SubjectConfirmationData(); $sc->SubjectConfirmationData->NotOnOrAfter = time() + 300; // 60*5 = 5min $sc->SubjectConfirmationData->Recipient = $endpoint; $sc->SubjectConfirmationData->InResponseTo = $query->getId(); -$assertion->setSubjectConfirmation(array($sc)); +$assertion->setSubjectConfirmation([$sc]); \SimpleSAML\Module\saml\Message::addSign($idpMetadata, $spMetadata, $assertion); @@ -82,7 +82,7 @@ $response->setRelayState($query->getRelayState()); $response->setDestination($endpoint); $response->setIssuer($idpEntityId); $response->setInResponseTo($query->getId()); -$response->setAssertions(array($assertion)); +$response->setAssertions([$assertion]); \SimpleSAML\Module\saml\Message::addSign($idpMetadata, $spMetadata, $response); $binding = new \SAML2\HTTPPost(); diff --git a/modules/exampleauth/lib/Auth/Process/RedirectTest.php b/modules/exampleauth/lib/Auth/Process/RedirectTest.php index 4e8d3b778..13ff82dbd 100644 --- a/modules/exampleauth/lib/Auth/Process/RedirectTest.php +++ b/modules/exampleauth/lib/Auth/Process/RedirectTest.php @@ -20,11 +20,11 @@ class RedirectTest extends \SimpleSAML\Auth\ProcessingFilter assert(array_key_exists('Attributes', $state)); // To check whether the state is saved correctly - $state['Attributes']['RedirectTest1'] = array('OK'); + $state['Attributes']['RedirectTest1'] = ['OK']; // Save state and redirect $id = \SimpleSAML\Auth\State::saveState($state, 'exampleauth:redirectfilter-test'); $url = \SimpleSAML\Module::getModuleURL('exampleauth/redirecttest.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php index c349ba155..fef113edb 100644 --- a/modules/exampleauth/lib/Auth/Source/External.php +++ b/modules/exampleauth/lib/Auth/Source/External.php @@ -76,17 +76,17 @@ class External extends \SimpleSAML\Auth\Source * to store them as arrays. */ - $attributes = array( - 'uid' => array($_SESSION['uid']), - 'displayName' => array($_SESSION['name']), - 'mail' => array($_SESSION['mail']), - ); + $attributes = [ + 'uid' => [$_SESSION['uid']], + 'displayName' => [$_SESSION['name']], + 'mail' => [$_SESSION['mail']], + ]; // Here we generate a multivalued attribute based on the account type - $attributes['eduPersonAffiliation'] = array( + $attributes['eduPersonAffiliation'] = [ $_SESSION['type'], /* In this example, either 'student' or 'employee'. */ 'member', - ); + ]; return $attributes; } @@ -143,9 +143,9 @@ class External extends \SimpleSAML\Auth\Source * We assume that whatever authentication page we send the user to has an * option to return the user to a specific page afterwards. */ - $returnTo = \SimpleSAML\Module::getModuleURL('exampleauth/resume.php', array( + $returnTo = \SimpleSAML\Module::getModuleURL('exampleauth/resume.php', [ 'State' => $stateId, - )); + ]); /* * Get the URL of the authentication page. @@ -162,9 +162,9 @@ class External extends \SimpleSAML\Auth\Source * Note the 'ReturnTo' parameter. This must most likely be replaced with * the real name of the parameter for the login page. */ - \SimpleSAML\Utils\HTTP::redirectTrustedURL($authPage, array( + \SimpleSAML\Utils\HTTP::redirectTrustedURL($authPage, [ 'ReturnTo' => $returnTo, - )); + ]); /* * The redirect function never returns, so we never get this far. diff --git a/modules/exampleauth/lib/Auth/Source/UserPass.php b/modules/exampleauth/lib/Auth/Source/UserPass.php index 633125c15..19da260bb 100644 --- a/modules/exampleauth/lib/Auth/Source/UserPass.php +++ b/modules/exampleauth/lib/Auth/Source/UserPass.php @@ -34,7 +34,7 @@ class UserPass extends \SimpleSAML\Module\core\Auth\UserPassBase // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $this->users = array(); + $this->users = []; // Validate and parse our configuration foreach ($config as $userpass => $attributes) { diff --git a/modules/exampleauth/www/authpage.php b/modules/exampleauth/www/authpage.php index e975d6986..6c34995ec 100644 --- a/modules/exampleauth/www/authpage.php +++ b/modules/exampleauth/www/authpage.php @@ -39,22 +39,22 @@ if (!preg_match('@State=(.*)@', $returnTo, $matches)) { /* * Our list of users. */ -$users = array( - 'student' => array( +$users = [ + 'student' => [ 'password' => 'student', 'uid' => 'student', 'name' => 'Student Name', 'mail' => 'somestudent@example.org', 'type' => 'student', - ), - 'admin' => array( + ], + 'admin' => [ 'password' => 'admin', 'uid' => 'admin', 'name' => 'Admin Name', 'mail' => 'someadmin@example.org', 'type' => 'employee', - ), -); + ], +]; /* * Time to handle login responses. diff --git a/modules/exampleauth/www/redirecttest.php b/modules/exampleauth/www/redirecttest.php index 103d262af..9d605277d 100644 --- a/modules/exampleauth/www/redirecttest.php +++ b/modules/exampleauth/www/redirecttest.php @@ -12,6 +12,6 @@ if (!array_key_exists('StateId', $_REQUEST)) { } $state = \SimpleSAML\Auth\State::loadState($_REQUEST['StateId'], 'exampleauth:redirectfilter-test'); -$state['Attributes']['RedirectTest2'] = array('OK'); +$state['Attributes']['RedirectTest2'] = ['OK']; \SimpleSAML\Auth\ProcessingChain::resumeProcessing($state); diff --git a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php index ca7d97308..ddd5befc1 100644 --- a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php +++ b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php @@ -142,7 +142,7 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter $state['netId'] = $netId; $id = \SimpleSAML\Auth\State::saveState($state, 'expirywarning:about2expire'); $url = \SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } if (!$this->checkDate($expireOnDate)) { @@ -154,7 +154,7 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter $state['netId'] = $netId; $id = \SimpleSAML\Auth\State::saveState($state, 'expirywarning:expired'); $url = \SimpleSAML\Module::getModuleURL('expirycheck/expired.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } } diff --git a/modules/expirycheck/templates/expired.php b/modules/expirycheck/templates/expired.php index ee1e73bda..2e0e66020 100644 --- a/modules/expirycheck/templates/expired.php +++ b/modules/expirycheck/templates/expired.php @@ -7,7 +7,7 @@ $this->includeAtTemplateBase('includes/header.php'); <?php echo $this->t( '{expirycheck:expwarning:no_access_to}', - array('%NETID%' => htmlspecialchars($this->data['netId'])) + ['%NETID%' => htmlspecialchars($this->data['netId'])] ); ?> </p> diff --git a/modules/expirycheck/www/about2expire.php b/modules/expirycheck/www/about2expire.php index fa502121e..1f1766c7e 100644 --- a/modules/expirycheck/www/about2expire.php +++ b/modules/expirycheck/www/about2expire.php @@ -26,44 +26,44 @@ $daysleft = $state['daysleft']; $t = new \SimpleSAML\XHTML\Template($globalConfig, 'expirycheck:about2expire.php'); $t->data['autofocus'] = 'yesbutton'; $t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php'); -$t->data['yesData'] = array('StateId' => $id); +$t->data['yesData'] = ['StateId' => $id]; $t->data['warning'] = $warning; $t->data['expireOnDate'] = $state['expireOnDate']; $t->data['netId'] = $state['netId']; if ($daysleft == 0) { # netid will expire today - $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header_today}', array( + $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header_today}', [ '%NETID%' => htmlspecialchars($this->data['netId']) - )); - $this->data['warning'] = $this->t('{expirycheck:expwarning:warning_today}', array( + ]); + $this->data['warning'] = $this->t('{expirycheck:expwarning:warning_today}', [ '%NETID%' => htmlspecialchars($this->data['netId']) - )); + ]); } elseif ($daysleft == 1) { # netid will expire in one day - $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array( + $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', [ '%NETID%' => htmlspecialchars($this->data['netId']), '%DAYS%' => $this->t('{expirycheck:expwarning:day}'), '%DAYSLEFT%' => htmlspecialchars($daysleft), - )); - $this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', array( + ]); + $this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', [ '%NETID%' => htmlspecialchars($this->data['netId']), '%DAYS%' => $this->t('{expirycheck:expwarning:day}'), '%DAYSLEFT%' => htmlspecialchars($daysleft), - )); + ]); } else { # netid will expire in next <daysleft> days - $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array( + $this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', [ '%NETID%' => htmlspecialchars($this->data['netId']), '%DAYS%' => $this->t('{expirycheck:expwarning:days}'), '%DAYSLEFT%' => htmlspecialchars($daysleft), - )); - $this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', array( + ]); + $this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', [ '%NETID%' => htmlspecialchars($this->data['netId']), '%DAYS%' => $this->t('{expirycheck:expwarning:days}'), '%DAYSLEFT%' => htmlspecialchars($daysleft), - )); + ]); } $t->show(); diff --git a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php index b8d1a1eb7..a1062376d 100644 --- a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php +++ b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php @@ -120,7 +120,7 @@ class AttributeAddFromLDAP extends BaseFilter parent::__construct($config, $reserved); // Get filter specific config options - $this->search_attributes = $this->config->getArrayize('attributes', array()); + $this->search_attributes = $this->config->getArrayize('attributes', []); if (empty($this->search_attributes)) { $new_attribute = $this->config->getString('attribute.new', ''); $this->search_attributes[$new_attribute] = $this->config->getString('search.attribute'); @@ -146,8 +146,8 @@ class AttributeAddFromLDAP extends BaseFilter // perform a merge on the ldap_search_filter // loop over the attributes and build the search and replace arrays - $arrSearch = array(); - $arrReplace = array(); + $arrSearch = []; + $arrReplace = []; foreach ($attributes as $attr => $val) { $arrSearch[] = '%'.$attr.'%'; @@ -167,7 +167,7 @@ class AttributeAddFromLDAP extends BaseFilter return; } - if (!in_array($this->attr_policy, array('merge', 'replace', 'add'), true)) { + if (!in_array($this->attr_policy, ['merge', 'replace', 'add'], true)) { \SimpleSAML\Logger::warning("AttributeAddFromLDAP: 'attribute.policy' must be one of 'merge',". "'replace' or 'add'."); return; diff --git a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php index 76d78fba8..6101e7b16 100644 --- a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php +++ b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php @@ -41,7 +41,7 @@ class AttributeAddUsersGroups extends BaseFilter // Make the array if it is not set already if (!isset($attributes[$map['groups']])) { - $attributes[$map['groups']] = array(); + $attributes[$map['groups']] = []; } // Must be an array, else cannot merge groups @@ -155,15 +155,15 @@ class AttributeAddUsersGroups extends BaseFilter "=".$attributes[$map['username']][0].") and attributes ".$map['member'] ); - $groups = array(); + $groups = []; try { /* Intention is to filter in 'ou=groups,dc=example,dc=com' for * '(memberUid = <value of attribute.username>)' and take only the attributes 'cn' (=name of the group) */ $all_groups = $this->getLdap()->searchformultiple( $openldap_base, - array($map['memberof'] => $attributes[$map['username']][0]), - array($map['member']) + [$map['memberof'] => $attributes[$map['username']][0]], + [$map['member']] ); } catch (\SimpleSAML\Error\UserNotFound $e) { return $groups; // if no groups found return with empty (still just initialized) groups array @@ -231,10 +231,10 @@ class AttributeAddUsersGroups extends BaseFilter assert(is_array($memberof)); // Used to determine what DN's have already been searched - static $searched = array(); + static $searched = []; // Init the groups variable - $groups = array(); + $groups = []; // Shorten the variable name $map = &$this->attribute_map; @@ -249,7 +249,7 @@ class AttributeAddUsersGroups extends BaseFilter // Work out what attributes to get for a group $use_group_name = false; - $get_attributes = array($map['memberof'], $map['type']); + $get_attributes = [$map['memberof'], $map['type']]; if (isset($map['name']) && $map['name']) { $get_attributes[] = $map['name']; $use_group_name = false; @@ -263,7 +263,7 @@ class AttributeAddUsersGroups extends BaseFilter } // Track all DN's that are searched - // Use DN for key as well, isset() is faster than in_array() + // Use DN for key as well, isset() is faster than in_[] $searched[$dn] = $dn; // Query LDAP for the attribute values for the DN @@ -329,18 +329,18 @@ class AttributeAddUsersGroups extends BaseFilter try { $entries = $this->getLdap()->searchformultiple( $this->base_dn, - array($map['type'] => $this->type_map['group'], $map['member'].':1.2.840.113556.1.4.1941:' => $dn), - array($map['dn']) + [$map['type'] => $this->type_map['group'], $map['member'].':1.2.840.113556.1.4.1941:' => $dn], + [$map['dn']] ); // The search may throw an exception if no entries // are found, unlikely but possible. } catch (\SimpleSAML\Error\UserNotFound $e) { - return array(); + return []; } //Init the groups - $groups = array(); + $groups = []; // Check each entry.. foreach ($entries as $entry) { @@ -365,7 +365,7 @@ class AttributeAddUsersGroups extends BaseFilter // Could not find DN, log and continue \SimpleSAML\Logger::notice( $this->title.'The DN attribute ['. - implode(', ', array($map['dn'], strtolower($map['dn']), 'dn')). + implode(', ', [$map['dn'], strtolower($map['dn']), 'dn']). '] could not be found in the entry. '.$this->var_export($entry) ); } diff --git a/modules/ldap/lib/Auth/Process/BaseFilter.php b/modules/ldap/lib/Auth/Process/BaseFilter.php index 42d5abb26..f7de0656f 100644 --- a/modules/ldap/lib/Auth/Process/BaseFilter.php +++ b/modules/ldap/lib/Auth/Process/BaseFilter.php @@ -141,7 +141,7 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter } // Build the authsource config - $authconfig = array(); + $authconfig = []; if (isset($authsource['hostname'])) { $authconfig['ldap.hostname'] = $authsource['hostname']; } @@ -223,7 +223,7 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter ); // Setup the attribute map which will be used to search LDAP - $this->attribute_map = array( + $this->attribute_map = [ 'dn' => $this->config->getString('attribute.dn', 'distinguishedName'), 'groups' => $this->config->getString('attribute.groups', 'groups'), 'member' => $this->config->getString('attribute.member', 'member'), @@ -231,7 +231,7 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter 'name' => $this->config->getString('attribute.groupname', 'name'), 'type' => $this->config->getString('attribute.type', 'objectClass'), 'username' => $this->config->getString('attribute.username', 'sAMAccountName') - ); + ]; // Log the attribute map \SimpleSAML\Logger::debug( @@ -239,10 +239,10 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter ); // Setup the object type map which is used to determine a DNs' type - $this->type_map = array( + $this->type_map = [ 'group' => $this->config->getString('type.group', 'group'), 'user' => $this->config->getString('type.user', 'user') - ); + ]; // Log the type map \SimpleSAML\Logger::debug( diff --git a/modules/ldap/lib/Auth/Source/LDAPMulti.php b/modules/ldap/lib/Auth/Source/LDAPMulti.php index 88a575b74..c923e9846 100644 --- a/modules/ldap/lib/Auth/Source/LDAPMulti.php +++ b/modules/ldap/lib/Auth/Source/LDAPMulti.php @@ -51,13 +51,13 @@ class LDAPMulti extends \SimpleSAML\Module\core\Auth\UserPassOrgBase ); - $this->orgs = array(); - $this->ldapOrgs = array(); + $this->orgs = []; + $this->ldapOrgs = []; foreach ($config as $name => $value) { if ($name === 'username_organization_method') { $usernameOrgMethod = $cfgHelper->getValueValidate( 'username_organization_method', - array('none', 'allow', 'force') + ['none', 'allow', 'force'] ); $this->setUsernameOrgMethod($usernameOrgMethod); continue; diff --git a/modules/memcacheMonitor/hooks/hook_frontpage.php b/modules/memcacheMonitor/hooks/hook_frontpage.php index c7f59bc6c..9329d5531 100644 --- a/modules/memcacheMonitor/hooks/hook_frontpage.php +++ b/modules/memcacheMonitor/hooks/hook_frontpage.php @@ -10,8 +10,8 @@ function memcacheMonitor_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['config'][] = array( + $links['config'][] = [ 'href' => SimpleSAML\Module::getModuleURL('memcacheMonitor/memcachestat.php'), 'text' => '{core:frontpage:link_memcacheMonitor}', - ); + ]; } diff --git a/modules/memcacheMonitor/templates/memcachestat.tpl.php b/modules/memcacheMonitor/templates/memcachestat.tpl.php index e3815c72b..02505ed2d 100644 --- a/modules/memcacheMonitor/templates/memcachestat.tpl.php +++ b/modules/memcacheMonitor/templates/memcachestat.tpl.php @@ -7,7 +7,7 @@ $title = $this->data['title']; $table = $this->data['table']; // Identify column headings -$column_titles = array(); +$column_titles = []; foreach ($table as $row_title => $row_data) { foreach ($row_data as $ct => $foo) { if (!in_array($ct, $column_titles, true)) { diff --git a/modules/memcacheMonitor/www/memcachestat.php b/modules/memcacheMonitor/www/memcachestat.php index 78bf44f56..a5cb0d202 100644 --- a/modules/memcacheMonitor/www/memcachestat.php +++ b/modules/memcacheMonitor/www/memcachestat.php @@ -72,14 +72,14 @@ $config = \SimpleSAML\Configuration::getInstance(); // Make sure that the user has admin access rights \SimpleSAML\Utils\Auth::requireAdmin(); -$formats = array( +$formats = [ 'bytes' => 'humanreadable', 'bytes_read' => 'humanreadable', 'bytes_written' => 'humanreadable', 'limit_maxbytes' => 'humanreadable', 'time' => 'tdate', 'uptime' => 'hours', -); +]; $statsraw = \SimpleSAML\Memcache::getStats(); @@ -95,7 +95,7 @@ foreach ($stats as $key => &$entry) { } $t = new \SimpleSAML\XHTML\Template($config, 'memcacheMonitor:memcachestat.tpl.php'); -$rowTitles = array( +$rowTitles = [ 'accepting_conns' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:accepting_conns}'), 'auth_cmds' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:auth_cmds}'), 'auth_errors' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:auth_errors}'), @@ -146,10 +146,10 @@ $rowTitles = array( 'touch_misses' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:touch_misses}'), 'uptime' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:uptime}'), 'version' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:version}'), -); +]; // Identify column headings -$colTitles = array(); +$colTitles = []; foreach ($stats as $rowTitle => $rowData) { foreach ($rowData as $colTitle => $foo) { if (!in_array($colTitle, $colTitles, true)) { @@ -159,7 +159,7 @@ foreach ($stats as $rowTitle => $rowData) { } if (array_key_exists('bytes', $statsraw) && array_key_exists('limit_maxbytes', $statsraw)) { - $usage = array(); + $usage = []; $maxpix = 400; foreach ($statsraw['bytes'] as $key => $row_data) { $pix = floor($statsraw['bytes'][$key] * $maxpix / $statsraw['limit_maxbytes'][$key]); diff --git a/modules/metarefresh/bin/metarefresh.php b/modules/metarefresh/bin/metarefresh.php index 08a08a0bf..b02fb75a6 100755 --- a/modules/metarefresh/bin/metarefresh.php +++ b/modules/metarefresh/bin/metarefresh.php @@ -45,7 +45,7 @@ $certificates = null; $validateFingerprint = null; // This variable contains the files we will parse -$files = array(); +$files = []; // Parse arguments @@ -71,11 +71,11 @@ foreach ($argv as $a) { } // Map short options to long options - $shortOptMap = array( + $shortOptMap = [ '-h' => '--help', '-o' => '--out-dir', '-s' => '--stdout', - ); + ]; if (array_key_exists($a, $shortOptMap)) { $a = $shortOptMap[$a]; } @@ -127,7 +127,7 @@ if (count($files) === 0) { $metaloader = new \SimpleSAML\Module\metarefresh\MetaLoader(); foreach ($files as $f) { - $source = array('src' => $f); + $source = ['src' => $f]; if (isset($certificates)) { $source['certificates'] = $certificates; } diff --git a/modules/metarefresh/config-templates/config-metarefresh.php b/modules/metarefresh/config-templates/config-metarefresh.php index e86585c6a..c8009d4c2 100644 --- a/modules/metarefresh/config-templates/config-metarefresh.php +++ b/modules/metarefresh/config-templates/config-metarefresh.php @@ -1,6 +1,6 @@ <?php -$config = array( +$config = [ /* * Global blacklist: entityIDs that should be excluded from ALL sets. */ @@ -16,12 +16,12 @@ $config = array( */ #'conditionalGET' => true, - 'sets' => array( + 'sets' => [ - 'kalmar' => array( - 'cron' => array('hourly'), - 'sources' => array( - array( + 'kalmar' => [ + 'cron' => ['hourly'], + 'sources' => [ + [ /* * entityIDs that should be excluded from this src. */ @@ -39,17 +39,17 @@ $config = array( #'conditionalGET' => true, 'src' => 'https://kalmar2.org/simplesaml/module.php/aggregator/?id=kalmarcentral&set=saml2&exclude=norway', - 'certificates' => array( + 'certificates' => [ 'current.crt', 'rollover.crt', - ), + ], 'validateFingerprint' => '59:1D:4B:46:70:46:3E:ED:A9:1F:CC:81:6D:C0:AF:2A:09:2A:A8:01', - 'template' => array( - 'tags' => array('kalmar'), - 'authproc' => array( - 51 => array('class' => 'core:AttributeMap', 'oid2name'), - ), - ), + 'template' => [ + 'tags' => ['kalmar'], + 'authproc' => [ + 51 => ['class' => 'core:AttributeMap', 'oid2name'], + ], + ], /* * The sets of entities to load, any combination of: @@ -63,9 +63,9 @@ $config = array( * * This option takes precedence over the same option per metadata set. */ - //'types' => array(), - ), - ), + //'types' => [], + ], + ], 'expireAfter' => 34560060, // Maximum 4 days cache time (3600*24*4) 'outputDir' => 'metadata/metadata-kalmar-consuming/', @@ -86,7 +86,7 @@ $config = array( * * All of them will be used by default. */ - //'types' => array(), - ), - ), -); + //'types' => [], + ], + ], +]; diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index bb396b8a0..4ab82e227 100644 --- a/modules/metarefresh/hooks/hook_cron.php +++ b/modules/metarefresh/hooks/hook_cron.php @@ -19,7 +19,7 @@ function metarefresh_hook_cron(&$croninfo) $config = \SimpleSAML\Configuration::getInstance(); $mconfig = \SimpleSAML\Configuration::getOptionalConfig('config-metarefresh.php'); - $sets = $mconfig->getConfigList('sets', array()); + $sets = $mconfig->getConfigList('sets', []); $stateFile = $config->getPathValue('datadir', 'data/').'metarefresh-state.php'; foreach ($sets as $setkey => $set) { @@ -40,28 +40,28 @@ function metarefresh_hook_cron(&$croninfo) $outputDir = $set->getString('outputDir'); $outputDir = $config->resolvePath($outputDir); - $outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile'); + $outputFormat = $set->getValueValidate('outputFormat', ['flatfile', 'serialize'], 'flatfile'); - $oldMetadataSrc = \SimpleSAML\Metadata\MetaDataStorageSource::getSource(array( + $oldMetadataSrc = \SimpleSAML\Metadata\MetaDataStorageSource::getSource([ 'type' => $outputFormat, 'directory' => $outputDir, - )); + ]); $metaloader = new \SimpleSAML\Module\metarefresh\MetaLoader($expire, $stateFile, $oldMetadataSrc); // Get global blacklist, whitelist and caching info - $blacklist = $mconfig->getArray('blacklist', array()); - $whitelist = $mconfig->getArray('whitelist', array()); + $blacklist = $mconfig->getArray('blacklist', []); + $whitelist = $mconfig->getArray('whitelist', []); $conditionalGET = $mconfig->getBoolean('conditionalGET', false); // get global type filters - $available_types = array( + $available_types = [ 'saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote' - ); + ]; $set_types = $set->getArrayize('types', $available_types); foreach ($set->getArray('sources') as $source) { diff --git a/modules/metarefresh/hooks/hook_frontpage.php b/modules/metarefresh/hooks/hook_frontpage.php index 917936839..e66c583f2 100644 --- a/modules/metarefresh/hooks/hook_frontpage.php +++ b/modules/metarefresh/hooks/hook_frontpage.php @@ -10,8 +10,8 @@ function metarefresh_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['federation'][] = array( + $links['federation'][] = [ 'href' => SimpleSAML\Module::getModuleURL('metarefresh/fetch.php'), 'text' => '{metarefresh:metarefresh:frontpage_link}', - ); + ]; } diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php index 1398a623b..b13e8a3c7 100644 --- a/modules/metarefresh/lib/MetaLoader.php +++ b/modules/metarefresh/lib/MetaLoader.php @@ -17,13 +17,13 @@ class MetaLoader private $stateFile; private $changed; private $state; - private $types = array( + private $types = [ 'saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote' - ); + ]; /** * Constructor @@ -35,7 +35,7 @@ class MetaLoader public function __construct($expire = null, $stateFile = null, $oldMetadataSrc = null) { $this->expire = $expire; - $this->metadata = array(); + $this->metadata = []; $this->oldMetadataSrc = $oldMetadataSrc; $this->stateFile = $stateFile; $this->changed = false; @@ -45,7 +45,7 @@ class MetaLoader include $stateFile; } - $this->state = array(); + $this->state = []; } /** @@ -67,7 +67,7 @@ class MetaLoader public function setTypes($types) { if (!is_array($types)) { - $types = array($types); + $types = [$types]; } $this->types = $types; } @@ -223,7 +223,7 @@ class MetaLoader } } - return array('http' => array('header' => $rawheader)); + return ['http' => ['header' => $rawheader]]; } @@ -251,7 +251,7 @@ class MetaLoader if (isset($source['conditionalGET']) && $source['conditionalGET']) { // Headers section if ($responseHeaders !== null) { - $candidates = array('last-modified', 'etag'); + $candidates = ['last-modified', 'etag']; foreach ($candidates as $candidate) { if (array_key_exists($candidate, $responseHeaders)) { @@ -347,7 +347,7 @@ class MetaLoader $metadata['metarefresh:src'] = $filename; if (!array_key_exists($type, $this->metadata)) { - $this->metadata[$type] = array(); + $this->metadata[$type] = []; } // If expire is defined in constructor... @@ -364,7 +364,7 @@ class MetaLoader $metadata['expire'] = $this->expire; } } - $this->metadata[$type][] = array('filename' => $filename, 'metadata' => $metadata); + $this->metadata[$type][] = ['filename' => $filename, 'metadata' => $metadata]; } @@ -376,9 +376,9 @@ class MetaLoader assert($config instanceof \SimpleSAML\Configuration); $arpfile = $config->getValue('arpfile'); - $types = array('saml20-sp-remote'); + $types = ['saml20-sp-remote']; - $md = array(); + $md = []; foreach ($this->metadata as $category => $elements) { if (!in_array($category, $types, true)) { continue; @@ -458,7 +458,7 @@ class MetaLoader { assert(is_string($outputDir)); - $metaHandler = new \SimpleSAML\Metadata\MetaDataStorageHandlerSerialize(array('directory' => $outputDir)); + $metaHandler = new \SimpleSAML\Metadata\MetaDataStorageHandlerSerialize(['directory' => $outputDir]); // First we add all the metadata entries to the metadata handler foreach ($this->metadata as $set => $elements) { diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php index 0ecb548d0..a715886fa 100644 --- a/modules/metarefresh/www/fetch.php +++ b/modules/metarefresh/www/fetch.php @@ -7,7 +7,7 @@ $mconfig = \SimpleSAML\Configuration::getOptionalConfig('config-metarefresh.php' \SimpleSAML\Logger::setCaptureLog(true); -$sets = $mconfig->getConfigList('sets', array()); +$sets = $mconfig->getConfigList('sets', []); foreach ($sets as $setkey => $set) { \SimpleSAML\Logger::info('[metarefresh]: Executing set ['.$setkey.']'); @@ -22,17 +22,17 @@ foreach ($sets as $setkey => $set) { $metaloader = new \SimpleSAML\Module\metarefresh\MetaLoader($expire); # Get global black/whitelists - $blacklist = $mconfig->getArray('blacklist', array()); - $whitelist = $mconfig->getArray('whitelist', array()); + $blacklist = $mconfig->getArray('blacklist', []); + $whitelist = $mconfig->getArray('whitelist', []); // get global type filters - $available_types = array( + $available_types = [ 'saml20-idp-remote', 'saml20-sp-remote', 'shib13-idp-remote', 'shib13-sp-remote', 'attributeauthority-remote' - ); + ]; $set_types = $set->getArrayize('types', $available_types); foreach ($set->getArray('sources') as $source) { @@ -64,7 +64,7 @@ foreach ($sets as $setkey => $set) { $outputDir = $set->getString('outputDir'); $outputDir = $config->resolvePath($outputDir); - $outputFormat = $set->getValueValidate('outputFormat', array('flatfile', 'serialize'), 'flatfile'); + $outputFormat = $set->getValueValidate('outputFormat', ['flatfile', 'serialize'], 'flatfile'); switch ($outputFormat) { case 'flatfile': $metaloader->writeMetadataFiles($outputDir); diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index a0f9778a2..4fa786252 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -58,18 +58,18 @@ class MultiAuth extends \SimpleSAML\Auth\Source $globalConfiguration = \SimpleSAML\Configuration::getInstance(); $defaultLanguage = $globalConfiguration->getString('language.default', 'en'); $authsources = \SimpleSAML\Configuration::getConfig('authsources.php'); - $this->sources = array(); + $this->sources = []; foreach ($config['sources'] as $source => $info) { if (is_int($source)) { // Backwards compatibility $source = $info; - $info = array(); + $info = []; } if (array_key_exists('text', $info)) { $text = $info['text']; } else { - $text = array($defaultLanguage => $source); + $text = [$defaultLanguage => $source]; } if (array_key_exists('help', $info)) { @@ -87,12 +87,12 @@ class MultiAuth extends \SimpleSAML\Auth\Source } } - $this->sources[] = array( + $this->sources[] = [ 'source' => $source, 'text' => $text, 'help' => $help, 'css_class' => $css_class, - ); + ]; } } @@ -122,7 +122,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * saved state array as a parameter to the login form */ $url = \SimpleSAML\Module::getModuleURL('multiauth/selectsource.php'); - $params = array('AuthState' => $id); + $params = ['AuthState' => $id]; // Allowes the user to specify the auth souce to be used if (isset($_GET['source'])) { @@ -221,13 +221,13 @@ class MultiAuth extends \SimpleSAML\Auth\Source $cookieName = 'multiauth_source_'.$this->authId; $config = \SimpleSAML\Configuration::getInstance(); - $params = array( + $params = [ // We save the cookies for 90 days 'lifetime' => 7776000, //60*60*24*90 // The base path for cookies. This should be the installation directory for SimpleSAMLphp. 'path' => $config->getBasePath(), 'httponly' => false, - ); + ]; \SimpleSAML\Utils\HTTP::setCookie($cookieName, $source, $params, false); } diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php index 5ef72f4cf..21601452f 100644 --- a/modules/negotiate/lib/Auth/Source/Negotiate.php +++ b/modules/negotiate/lib/Auth/Source/Negotiate.php @@ -25,8 +25,8 @@ class Negotiate extends \SimpleSAML\Auth\Source protected $debugLDAP = false; protected $timeout = 30; protected $keytab = ''; - protected $base = array(); - protected $attr = array('uid'); + protected $base = []; + protected $attr = ['uid']; protected $subnet = null; protected $admin_user = null; protected $admin_pw = null; @@ -88,9 +88,9 @@ class Negotiate extends \SimpleSAML\Auth\Source assert(is_array($state)); // set the default backend to config - $state['LogoutState'] = array( + $state['LogoutState'] = [ 'negotiate:backend' => $this->backend, - ); + ]; $state['negotiate:authId'] = $this->authId; @@ -157,9 +157,9 @@ class Negotiate extends \SimpleSAML\Auth\Source if ($lookup !== null) { $state['Attributes'] = $lookup; // Override the backend so logout will know what to look for - $state['LogoutState'] = array( + $state['LogoutState'] = [ 'negotiate:backend' => null, - ); + ]; Logger::info('Negotiate - authenticate(): '.$user.' authorized.'); \SimpleSAML\Auth\Source::completeAuth($state); // Never reached. @@ -175,7 +175,7 @@ class Negotiate extends \SimpleSAML\Auth\Source // Save the $state array, so that we can restore if after a redirect Logger::debug('Negotiate - fallback: '.$state['LogoutState']['negotiate:backend']); $id = \SimpleSAML\Auth\State::saveState($state, self::STAGEID); - $params = array('AuthState' => $id); + $params = ['AuthState' => $id]; $this->sendNegotiate($params); exit; @@ -269,7 +269,7 @@ class Negotiate extends \SimpleSAML\Auth\Source $authId = $state['LogoutState']['negotiate:backend']; if ($authId === null) { - throw new \SimpleSAML\Error\Error(array(500, "Unable to determine auth source.")); + throw new \SimpleSAML\Error\Error([500, "Unable to determine auth source."]); } $source = \SimpleSAML\Auth\Source::getById($authId); diff --git a/modules/negotiate/templates/disable.php b/modules/negotiate/templates/disable.php index f9e2d5508..fd8338e9f 100644 --- a/modules/negotiate/templates/disable.php +++ b/modules/negotiate/templates/disable.php @@ -10,7 +10,7 @@ $this->includeAtTemplateBase('includes/header.php'); ?> <h1><?php echo $this->t('{negotiate:negotiate:disable_title}'); ?></h1> -<?php echo $this->t('{negotiate:negotiate:disable_info_pre}', array('URL' => htmlspecialchars($this->data['url']))); ?> +<?php echo $this->t('{negotiate:negotiate:disable_info_pre}', ['URL' => htmlspecialchars($this->data['url'])]); ?> <?php echo $this->t('{negotiate:negotiate:info_post}'); ?> diff --git a/modules/negotiate/templates/enable.php b/modules/negotiate/templates/enable.php index 939af6fb6..a25b6a213 100644 --- a/modules/negotiate/templates/enable.php +++ b/modules/negotiate/templates/enable.php @@ -11,7 +11,7 @@ $this->includeAtTemplateBase('includes/header.php'); ?> <h1><?php echo $this->t('{negotiate:negotiate:enable_title}'); ?></h1> -<?php echo $this->t('{negotiate:negotiate:enable_info_pre}', array('URL' => htmlspecialchars($this->data['url']))); ?> +<?php echo $this->t('{negotiate:negotiate:enable_info_pre}', ['URL' => htmlspecialchars($this->data['url'])]); ?> <?php echo $this->t('{negotiate:negotiate:info_post}'); ?> diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php index 1832f4a32..2734f05c3 100644 --- a/modules/negotiate/www/disable.php +++ b/modules/negotiate/www/disable.php @@ -5,11 +5,11 @@ * @package SimpleSAMLphp */ -$params = array( +$params = [ 'expire' => (mktime(0, 0, 0, 1, 1, 2038)), 'secure' => false, 'httponly' => true, -); +]; \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', 'True', $params, false); $globalConfig = \SimpleSAML\Configuration::getInstance(); diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php index 891eac6d7..be52928db 100644 --- a/modules/negotiate/www/enable.php +++ b/modules/negotiate/www/enable.php @@ -5,10 +5,10 @@ * @package SimpleSAMLphp */ -$params = array( +$params = [ 'secure' => false, 'httponly' => true, -); +]; \SimpleSAML\Utils\HTTP::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', null, $params, false); $globalConfig = \SimpleSAML\Configuration::getInstance(); diff --git a/modules/oauth/config-template/module_oauth.php b/modules/oauth/config-template/module_oauth.php index 475acb3e2..63327d6be 100644 --- a/modules/oauth/config-template/module_oauth.php +++ b/modules/oauth/config-template/module_oauth.php @@ -4,7 +4,7 @@ * */ -$config = array( +$config = [ /* Enable the getUserInfo endpoint. Do not enable unless you know what you do. * It may give external parties access to userInfo unless properly secured. */ @@ -21,4 +21,4 @@ $config = array( // useridattr is the attribute-name that contains the userid as returned from idp 'auth' => 'default-sp', 'useridattr', 'user', -); +]; diff --git a/modules/oauth/hooks/hook_frontpage.php b/modules/oauth/hooks/hook_frontpage.php index 23ebb76d5..028e11c85 100644 --- a/modules/oauth/hooks/hook_frontpage.php +++ b/modules/oauth/hooks/hook_frontpage.php @@ -9,8 +9,8 @@ function oauth_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['federation']['oauthregistry'] = array( + $links['federation']['oauthregistry'] = [ 'href' => SimpleSAML\Module::getModuleURL('oauth/registry.php'), 'text' => '{core:frontpage:link_oauth}', - ); + ]; } diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php index 0f7b81bca..b3a4080ae 100644 --- a/modules/oauth/lib/Consumer.php +++ b/modules/oauth/lib/Consumer.php @@ -103,7 +103,7 @@ class Consumer public function getAuthorizeRequest($url, $requestToken, $redirect = true, $callback = null) { - $params = array('oauth_token' => $requestToken->key); + $params = ['oauth_token' => $requestToken->key]; if ($callback) { $params['oauth_callback'] = $callback; } @@ -146,18 +146,18 @@ class Consumer $data_req->sign_request($this->signer, $this->consumer, $accessToken); $postdata = $data_req->to_postdata(); - $opts = array( - 'ssl' => array( + $opts = [ + 'ssl' => [ 'verify_peer' => false, 'capture_peer_cert' => true, 'capture_peer_chain' => true - ), - 'http' => array( + ], + 'http' => [ 'method' => 'POST', 'content' => $postdata, 'header' => 'Content-Type: application/x-www-form-urlencoded', - ), - ); + ], + ]; try { $response = \SimpleSAML\Utils\HTTP::fetch($url, $opts); diff --git a/modules/oauth/lib/OAuthStore.php b/modules/oauth/lib/OAuthStore.php index ee5725cb1..b0c9d222d 100644 --- a/modules/oauth/lib/OAuthStore.php +++ b/modules/oauth/lib/OAuthStore.php @@ -21,14 +21,14 @@ class OAuthStore extends \OAuthDataStore private $config; private $defaultversion = '1.0'; - protected $_store_tables = array( + protected $_store_tables = [ 'consumers' => 'consumer = array with consumer attributes', 'nonce' => 'nonce+consumer_key = -boolean-', 'requesttorequest' => 'requestToken.key = array(version,callback,consumerKey,)', 'authorized' => 'requestToken.key, verifier = array(authenticated-user-attributes)', 'access' => 'accessToken.key+consumerKey = accesstoken', 'request' => 'requestToken.key+consumerKey = requesttoken', - ); + ]; public function __construct() @@ -66,11 +66,11 @@ class OAuthStore extends \OAuthDataStore } $verifier = \SimpleSAML\Utils\Random::generateID(); - $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array("oauth_verifier"=>$verifier)); + $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, ["oauth_verifier"=>$verifier]); $this->store->set('authorized', $requestTokenKey, $verifier, $data, $this->config->getValue('requestTokenDuration', 1800)); //60*30=1800 - return array($url, $verifier); + return [$url, $verifier]; } /** @@ -160,11 +160,11 @@ class OAuthStore extends \OAuthDataStore $this->store->set('request', $token->key, $consumer->key, $token, $lifetime); // also store in requestToken->key => array('callback'=>CallbackURL, 'version'=>oauth_version - $request_attributes = array( + $request_attributes = [ 'callback' => $callback, 'version' => ($version ? $version : $this->defaultversion), 'consumerKey' => $consumer->key, - ); + ]; $this->store->set('requesttorequest', $token->key, '', $request_attributes, $lifetime); /* also store in requestToken->key => diff --git a/modules/oauth/lib/Registry.php b/modules/oauth/lib/Registry.php index 984638b6f..0ff3b5105 100644 --- a/modules/oauth/lib/Registry.php +++ b/modules/oauth/lib/Registry.php @@ -20,7 +20,7 @@ class Registry } } - public function formToMeta($request, $entry = array(), $override = null) + public function formToMeta($request, $entry = [], $override = null) { $this->getStandardField($request, $entry, 'name'); $this->getStandardField($request, $entry, 'description'); diff --git a/modules/oauth/libextinc/OAuth.php b/modules/oauth/libextinc/OAuth.php index 994241b33..c8811d6ce 100644 --- a/modules/oauth/libextinc/OAuth.php +++ b/modules/oauth/libextinc/OAuth.php @@ -148,10 +148,10 @@ class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod $base_string = $request->get_signature_base_string(); $request->base_string = $base_string; - $key_parts = array( + $key_parts = [ $consumer->secret, ($token) ? $token->secret : "" - ); + ]; $key_parts = OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key_parts); @@ -183,10 +183,10 @@ class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod */ public function build_signature($request, $consumer, $token) { - $key_parts = array( + $key_parts = [ $consumer->secret, ($token) ? $token->secret : "" - ); + ]; $key_parts = OAuthUtil::urlencode_rfc3986($key_parts); $key = implode('&', $key_parts); @@ -279,7 +279,7 @@ class OAuthRequest public function __construct($http_method, $http_url, $parameters = null) { - $parameters = ($parameters) ? $parameters : array(); + $parameters = ($parameters) ? $parameters : []; $parameters = array_merge(OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters); $this->parameters = $parameters; $this->http_method = $http_method; @@ -345,11 +345,11 @@ class OAuthRequest */ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters = null) { - $parameters = ($parameters) ? $parameters : array(); - $defaults = array("oauth_version" => OAuthRequest::$version, + $parameters = ($parameters) ? $parameters : []; + $defaults = ["oauth_version" => OAuthRequest::$version, "oauth_nonce" => OAuthRequest::generate_nonce(), "oauth_timestamp" => OAuthRequest::generate_timestamp(), - "oauth_consumer_key" => $consumer->key); + "oauth_consumer_key" => $consumer->key]; if ($token) { $defaults['oauth_token'] = $token->key; } @@ -366,7 +366,7 @@ class OAuthRequest if (is_scalar($this->parameters[$name])) { // This is the first duplicate, so transform scalar (string) // into an array so we can add the duplicates - $this->parameters[$name] = array($this->parameters[$name]); + $this->parameters[$name] = [$this->parameters[$name]]; } $this->parameters[$name][] = $value; @@ -417,11 +417,11 @@ class OAuthRequest */ public function get_signature_base_string() { - $parts = array( + $parts = [ $this->get_normalized_http_method(), $this->get_normalized_http_url(), $this->get_signable_parameters() - ); + ]; $parts = OAuthUtil::urlencode_rfc3986($parts); @@ -554,7 +554,7 @@ class OAuthServer { protected $timestamp_threshold = 300; // in seconds, five minutes protected $version = '1.0'; // hi blaine - protected $signature_methods = array(); + protected $signature_methods = []; protected $data_store; @@ -624,7 +624,7 @@ class OAuthServer $consumer = $this->getConsumer($request); $token = $this->getToken($request, $consumer, "access"); $this->checkSignature($request, $consumer, $token); - return array($consumer, $token); + return [$consumer, $token]; } // Internals from here @@ -823,7 +823,7 @@ class OAuthUtil public static function urlencode_rfc3986($input) { if (is_array($input)) { - return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input); + return array_map(['OAuthUtil', 'urlencode_rfc3986'], $input); } elseif (is_scalar($input)) { return str_replace( '+', @@ -851,7 +851,7 @@ class OAuthUtil // see http://code.google.com/p/oauth/issues/detail?id=163 public static function split_header($header, $only_allow_oauth_parameters = true) { - $params = array(); + $params = []; if (preg_match_all( '/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, @@ -879,7 +879,7 @@ class OAuthUtil // we always want the keys to be Cased-Like-This and arh() // returns the headers in the same case as they are in the // request - $out = array(); + $out = []; foreach ($headers as $key => $value) { $key = str_replace( " ", @@ -891,7 +891,7 @@ class OAuthUtil } else { // otherwise we don't have apache and are just going to have to hope // that $_SERVER actually contains what we need - $out = array(); + $out = []; if (isset($_SERVER['CONTENT_TYPE'])) { $out['Content-Type'] = $_SERVER['CONTENT_TYPE']; } @@ -926,12 +926,12 @@ class OAuthUtil public static function parse_parameters($input) { if (!isset($input) || !$input) { - return array(); + return []; } $pairs = explode('&', $input); - $parsed_parameters = array(); + $parsed_parameters = []; foreach ($pairs as $pair) { $split = explode('=', $pair, 2); $parameter = OAuthUtil::urldecode_rfc3986($split[0]); @@ -944,7 +944,7 @@ class OAuthUtil if (is_scalar($parsed_parameters[$parameter])) { // This is the first duplicate, so transform scalar (string) into an array // so we can add the duplicates - $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]); + $parsed_parameters[$parameter] = [$parsed_parameters[$parameter]]; } $parsed_parameters[$parameter][] = $value; @@ -970,7 +970,7 @@ class OAuthUtil // Ref: Spec: 9.1.1 (1) uksort($params, 'strcmp'); - $pairs = array(); + $pairs = []; foreach ($params as $parameter => $value) { if (is_array($value)) { // If two or more parameters share the same name, they are sorted by their value diff --git a/modules/oauth/templates/registry.edit.tpl.php b/modules/oauth/templates/registry.edit.tpl.php index 58a58d010..b43c40d39 100644 --- a/modules/oauth/templates/registry.edit.tpl.php +++ b/modules/oauth/templates/registry.edit.tpl.php @@ -1,6 +1,6 @@ <?php -$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); +$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true]; $this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'. $this->data['baseurlpath'].'module.php/oauth/assets/css/oauth.css" />'."\n"; $this->data['head'] .= '<script type="text/javascript" src="/'. diff --git a/modules/oauth/templates/registry.list.php b/modules/oauth/templates/registry.list.php index bbccab1d9..1c3b287fb 100644 --- a/modules/oauth/templates/registry.list.php +++ b/modules/oauth/templates/registry.list.php @@ -1,5 +1,5 @@ <?php -$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); +$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true]; $this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'. $this->data['baseurlpath'].'module.php/oauth/assets/oauth.css" />'."\n"; $this->includeAtTemplateBase('includes/header.php'); @@ -11,7 +11,7 @@ echo '<p>Here you can register new OAuth Clients. You are successfully logged in echo '<h2>Your clients</h2>'; echo '<table class="metalist" style="width: 100%">'; $i = 0; -$rows = array('odd', 'even'); +$rows = ['odd', 'even']; foreach ($this->data['entries']['mine'] as $entryc) { $entry = $entryc['value']; $i++; @@ -30,7 +30,7 @@ echo '<p><a href="registry.edit.php">Add new client</a></p>'; echo '<h2>Other clients</h2>'; echo '<table class="metalist" style="width: 100%">'; $i = 0; -$rows = array('odd', 'even'); +$rows = ['odd', 'even']; foreach ($this->data['entries']['others'] as $entryc) { $entry = $entryc['value']; $i++; diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php index b475e0aa9..c9a50b2f3 100644 --- a/modules/oauth/www/registry.edit.php +++ b/modules/oauth/www/registry.edit.php @@ -39,11 +39,11 @@ if (array_key_exists('editkey', $_REQUEST)) { $entry = $entryc['value']; requireOwnership($entry, $userid); } else { - $entry = array( + $entry = [ 'owner' => $userid, 'key' => \SimpleSAML\Utils\Random::generateID(), 'secret' => \SimpleSAML\Utils\Random::generateID(), - ); + ]; } $editor = new \SimpleSAML\Module\oauth\Registry(); @@ -51,7 +51,7 @@ $editor = new \SimpleSAML\Module\oauth\Registry(); if (isset($_POST['submit'])) { $editor->checkForm($_POST); - $entry = $editor->formToMeta($_POST, array(), array('owner' => $userid)); + $entry = $editor->formToMeta($_POST, [], ['owner' => $userid]); requireOwnership($entry, $userid); @@ -67,5 +67,5 @@ $form = $editor->metaToForm($entry); $template = new \SimpleSAML\XHTML\Template($config, 'oauth:registry.edit.tpl.php'); $template->data['form'] = $form; -$template->data['jquery'] = array('core' => false, 'ui' => true, 'css' => true); +$template->data['jquery'] = ['core' => false, 'ui' => true, 'css' => true]; $template->show(); diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php index 9f97762ac..3f3403bf1 100644 --- a/modules/oauth/www/registry.php +++ b/modules/oauth/www/registry.php @@ -43,7 +43,7 @@ if (isset($_REQUEST['delete'])) { $list = $store->getList('consumers'); -$slist = array('mine' => array(), 'others' => array()); +$slist = ['mine' => [], 'others' => []]; if (is_array($list)) { foreach ($list as $listitem) { if (array_key_exists('owner', $listitem['value'])) { diff --git a/modules/portal/config-templates/module_portal.php b/modules/portal/config-templates/module_portal.php index 99cdaf4f9..85df6f99a 100644 --- a/modules/portal/config-templates/module_portal.php +++ b/modules/portal/config-templates/module_portal.php @@ -3,9 +3,9 @@ * Configuration for the module portal. */ -$config = array( - 'pagesets' => array( - array('frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'), - array('sanitycheck', 'statistics'), - ), -); +$config = [ + 'pagesets' => [ + ['frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'], + ['sanitycheck', 'statistics'], + ], +]; diff --git a/modules/portal/hooks/hook_htmlinject.php b/modules/portal/hooks/hook_htmlinject.php index 5fffdf608..efa1984a3 100644 --- a/modules/portal/hooks/hook_htmlinject.php +++ b/modules/portal/hooks/hook_htmlinject.php @@ -12,19 +12,19 @@ function portal_hook_htmlinject(&$hookinfo) assert(array_key_exists('post', $hookinfo)); assert(array_key_exists('page', $hookinfo)); - $links = array('links' => array()); + $links = ['links' => []]; \SimpleSAML\Module::callHooks('frontpage', $links); $portalConfig = \SimpleSAML\Configuration::getOptionalConfig('module_portal.php'); - $allLinks = array(); + $allLinks = []; foreach ($links as $ls) { $allLinks = array_merge($allLinks, $ls); } - $pagesets = $portalConfig->getValue('pagesets', array( - array('frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'), - )); + $pagesets = $portalConfig->getValue('pagesets', [ + ['frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'], + ]); \SimpleSAML\Module::callHooks('portalextras', $pagesets); $portal = new \SimpleSAML\Module\portal\Portal($allLinks, $pagesets); diff --git a/modules/portal/lib/Portal.php b/modules/portal/lib/Portal.php index a27bb343d..517ce2edf 100644 --- a/modules/portal/lib/Portal.php +++ b/modules/portal/lib/Portal.php @@ -38,7 +38,7 @@ class Portal public function getLoginInfo($translator, $thispage) { - $info = array('info' => '', 'translator' => $translator, 'thispage' => $thispage); + $info = ['info' => '', 'translator' => $translator, 'thispage' => $thispage]; \SimpleSAML\Module::callHooks('portalLoginInfo', $info); return $info['info']; } diff --git a/modules/preprodwarning/lib/Auth/Process/Warning.php b/modules/preprodwarning/lib/Auth/Process/Warning.php index 1a235a83a..bbc6fdadb 100644 --- a/modules/preprodwarning/lib/Auth/Process/Warning.php +++ b/modules/preprodwarning/lib/Auth/Process/Warning.php @@ -30,6 +30,6 @@ class Warning extends \SimpleSAML\Auth\ProcessingFilter // Save state and redirect. $id = \SimpleSAML\Auth\State::saveState($state, 'warning:request'); $url = \SimpleSAML\Module::getModuleURL('preprodwarning/showwarning.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/preprodwarning/www/showwarning.php b/modules/preprodwarning/www/showwarning.php index 41eff2055..394617d35 100644 --- a/modules/preprodwarning/www/showwarning.php +++ b/modules/preprodwarning/www/showwarning.php @@ -24,5 +24,5 @@ $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'preprodwarning:warning.php'); $t->data['yesTarget'] = \SimpleSAML\Module::getModuleURL('preprodwarning/showwarning.php'); -$t->data['yesData'] = array('StateId' => $id); +$t->data['yesData'] = ['StateId' => $id]; $t->show(); diff --git a/modules/radius/lib/Auth/Source/Radius.php b/modules/radius/lib/Auth/Source/Radius.php index 4709f3bec..70a192b41 100644 --- a/modules/radius/lib/Auth/Source/Radius.php +++ b/modules/radius/lib/Auth/Source/Radius.php @@ -88,17 +88,17 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase 'Authentication source '.var_export($this->authId, true) ); - $this->servers = $config->getArray('servers', array()); + $this->servers = $config->getArray('servers', []); // For backwards compatibility if (empty($this->servers)) { $this->hostname = $config->getString('hostname'); $this->port = $config->getIntegerRange('port', 1, 65535, 1812); $this->secret = $config->getString('secret'); - $this->servers[] = array( + $this->servers[] = [ 'hostname' => $this->hostname, 'port' => $this->port, 'secret' => $this->secret - ); + ]; } $this->timeout = $config->getInteger('timeout', 5); $this->retries = $config->getInteger('retries', 3); @@ -189,10 +189,10 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase // If we get this far, we have a valid login - $attributes = array(); + $attributes = []; if ($this->usernameAttribute !== null) { - $attributes[$this->usernameAttribute] = array($username); + $attributes[$this->usernameAttribute] = [$username]; } if ($this->vendor === null) { @@ -213,7 +213,7 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase // Use the received user name if ($resa['attr'] == \RADIUS_USER_NAME) { - $attributes[$this->usernameAttribute] = array($resa['data']); + $attributes[$this->usernameAttribute] = [$resa['data']]; continue; } @@ -243,7 +243,7 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase if (array_key_exists($attrib_name, $attributes)) { $attributes[$attrib_name][] = $attrib_value; } else { - $attributes[$attrib_name] = array($attrib_value); + $attributes[$attrib_name] = [$attrib_value]; } } // end of contribution diff --git a/modules/riak/config-templates/module_riak.php b/modules/riak/config-templates/module_riak.php index 4d3043195..99f535fee 100644 --- a/modules/riak/config-templates/module_riak.php +++ b/modules/riak/config-templates/module_riak.php @@ -4,7 +4,7 @@ * */ -$config = array( +$config = [ /* * This module has the following config options and defaults. * @@ -13,4 +13,4 @@ $config = array( * 'port' => 8098, * 'bucket' => 'SimpleSAMLphp', */ -); +]; diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php index f04ee40cd..e1dc65c36 100644 --- a/modules/saml/hooks/hook_metadata_hosted.php +++ b/modules/saml/hooks/hook_metadata_hosted.php @@ -23,13 +23,13 @@ function saml_hook_metadata_hosted(&$metadataHosted) $name = $source->getAuthId(); } - $md = array( + $md = [ 'entityid' => $source->getEntityId(), 'metadata-index' => $source->getEntityId(), 'metadata-set' => 'saml20-sp-hosted', 'metadata-url' => $source->getMetadataURL().'?output=xhtml', 'name' => $name, - ); + ]; $metadataHosted[] = $md; } diff --git a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php index d7ae42fbc..fd6277732 100644 --- a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php +++ b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php @@ -99,6 +99,6 @@ class ExpectedAuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter $url = \SimpleSAML\Module::getModuleURL( 'saml/sp/wrong_authncontextclassref.php' ); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['StateId' => $id]); } } diff --git a/modules/saml/lib/Auth/Process/FilterScopes.php b/modules/saml/lib/Auth/Process/FilterScopes.php index 6b9eda30f..67ef886df 100644 --- a/modules/saml/lib/Auth/Process/FilterScopes.php +++ b/modules/saml/lib/Auth/Process/FilterScopes.php @@ -17,10 +17,10 @@ class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter /** * Stores any pre-configured scoped attributes which come from the filter configuration. */ - private $scopedAttributes = array( + private $scopedAttributes = [ 'eduPersonScopedAffiliation', 'eduPersonPrincipalName' - ); + ]; /** @@ -53,7 +53,7 @@ class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter Logger::warning('No scoped attributes configured.'); return; } - $validScopes = array(); + $validScopes = []; if (array_key_exists('scope', $src) && is_array($src['scope']) && !empty($src['scope'])) { $validScopes = $src['scope']; } @@ -64,7 +64,7 @@ class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter } $values = $request['Attributes'][$attribute]; - $newValues = array(); + $newValues = []; foreach ($values as $value) { $ep = \SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint($request['Source']['SingleSignOnService']); $loc = $ep['Location']; diff --git a/modules/saml/lib/Auth/Process/NameIDAttribute.php b/modules/saml/lib/Auth/Process/NameIDAttribute.php index 29387ba0a..e1455b214 100644 --- a/modules/saml/lib/Auth/Process/NameIDAttribute.php +++ b/modules/saml/lib/Auth/Process/NameIDAttribute.php @@ -65,7 +65,7 @@ class NameIDAttribute extends \SimpleSAML\Auth\ProcessingFilter { assert(is_string($format)); - $ret = array(); + $ret = []; $pos = 0; while (($next = strpos($format, '%', $pos)) !== false) { $ret[] = substr($format, $pos, $next - $pos); @@ -139,6 +139,6 @@ class NameIDAttribute extends \SimpleSAML\Auth\ProcessingFilter $isString = !$isString; } - $state['Attributes'][$this->attribute] = array($value); + $state['Attributes'][$this->attribute] = [$value]; } } diff --git a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php index 021630afa..d07d8ee0a 100644 --- a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php +++ b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php @@ -70,6 +70,6 @@ class PersistentNameID2TargetedID extends \SimpleSAML\Auth\ProcessingFilter /** @var \SAML2\XML\saml\NameID $nameID */ $nameID = $state['saml:NameID'][\SAML2\Constants::NAMEID_PERSISTENT]; - $state['Attributes'][$this->attribute] = array((!$this->nameId) ? $nameID->value : $nameID); + $state['Attributes'][$this->attribute] = [(!$this->nameId) ? $nameID->value : $nameID]; } } diff --git a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php index c1b3bf51a..38b6d0c98 100644 --- a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php +++ b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php @@ -92,11 +92,11 @@ class SQLPersistentNameID extends \SimpleSAML\Module\saml\BaseNameIDGenerator return null; } - $validNameIdFormats = @array_filter(array( + $validNameIdFormats = @array_filter([ $state['saml:NameIDFormat'], $state['SPMetadata']['NameIDPolicy'], $state['SPMetadata']['NameIDFormat'] - )); + ]); if (count($validNameIdFormats) && !in_array($this->format, $validNameIdFormats, true) && !$this->allowDifferent ) { diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 58e43744f..ecd1e852c 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -201,15 +201,15 @@ class SP extends Source $accr = \SimpleSAML\Utils\Arrays::arrayize($state['saml:AuthnContextClassRef']); $comp = \SAML2\Constants::COMPARISON_EXACT; if (isset($state['saml:AuthnContextComparison']) - && in_array($state['AuthnContextComparison'], array( + && in_array($state['AuthnContextComparison'], [ \SAML2\Constants::COMPARISON_EXACT, \SAML2\Constants::COMPARISON_MINIMUM, \SAML2\Constants::COMPARISON_MAXIMUM, \SAML2\Constants::COMPARISON_BETTER, - ), true)) { + ], true)) { $comp = $state['saml:AuthnContextComparison']; } - $ar->setRequestedAuthnContext(array('AuthnContextClassRef' => $accr, 'Comparison' => $comp)); + $ar->setRequestedAuthnContext(['AuthnContextClassRef' => $accr, 'Comparison' => $comp]); } if (isset($state['ForceAuthn'])) { @@ -229,10 +229,10 @@ class SP extends Source if (isset($state['saml:NameIDPolicy'])) { if (is_string($state['saml:NameIDPolicy'])) { - $policy = array( + $policy = [ 'Format' => (string) $state['saml:NameIDPolicy'], 'AllowCreate' => true, - ); + ]; } elseif (is_array($state['saml:NameIDPolicy'])) { $policy = $state['saml:NameIDPolicy']; } else { @@ -244,14 +244,14 @@ class SP extends Source if (isset($state['saml:IDPList'])) { $IDPList = $state['saml:IDPList']; } else { - $IDPList = array(); + $IDPList = []; } $ar->setIDPList( array_unique( array_merge( - $this->metadata->getArray('IDPList', array()), - $idpMetadata->getArray('IDPList', array()), + $this->metadata->getArray('IDPList', []), + $idpMetadata->getArray('IDPList', []), (array) $IDPList ) ) @@ -265,7 +265,7 @@ class SP extends Source $ar->setProxyCount($this->metadata->getInteger('ProxyCount', null)); } - $requesterID = array(); + $requesterID = []; if (isset($state['saml:RequesterID'])) { $requesterID = $state['saml:RequesterID']; } @@ -294,9 +294,9 @@ class SP extends Source if ($ar->getProtocolBinding() === \SAML2\Constants::BINDING_HOK_SSO) { $dst = $idpMetadata->getDefaultEndpoint( 'SingleSignOnService', - array( + [ \SAML2\Constants::BINDING_HOK_SSO - ) + ] ); } else { $dst = $idpMetadata->getEndpointPrioritizedByBinding( @@ -372,13 +372,13 @@ class SP extends Source $discoURL = \SimpleSAML\Module::getModuleURL('saml/disco.php'); } - $returnTo = \SimpleSAML\Module::getModuleURL('saml/sp/discoresp.php', array('AuthID' => $id)); + $returnTo = \SimpleSAML\Module::getModuleURL('saml/sp/discoresp.php', ['AuthID' => $id]); - $params = array( + $params = [ 'entityID' => $this->entityId, 'return' => $returnTo, 'returnIDParam' => 'idpentityid' - ); + ]; if (isset($state['saml:IDPList'])) { $params['IDPList'] = $state['saml:IDPList']; @@ -556,7 +556,7 @@ class SP extends Source // save the state WITHOUT a restart URL, so that we don't try an IdP-initiated login if something goes wrong $id = State::saveState($state, 'saml:proxy:invalid_idp', true); $url = \SimpleSAML\Module::getModuleURL('saml/proxy/invalid_session.php'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('AuthState' => $id)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, ['AuthState' => $id]); assert(false); } @@ -574,7 +574,7 @@ class SP extends Source if (isset($state['Responder'])) { $state['saml:proxy:reauthLogout:PrevResponder'] = $state['Responder']; } - $state['Responder'] = array('\SimpleSAML\Module\saml\Auth\Source\SP', 'reauthPostLogout'); + $state['Responder'] = ['\SimpleSAML\Module\saml\Auth\Source\SP', 'reauthPostLogout']; $idp = \SimpleSAML\IdP::getByState($state); $idp->handleLogoutRequest($state, null); @@ -645,9 +645,9 @@ class SP extends Source $idpMetadata = $this->getIdPMetadata($idp); - $endpoint = $idpMetadata->getEndpointPrioritizedByBinding('SingleLogoutService', array( + $endpoint = $idpMetadata->getEndpointPrioritizedByBinding('SingleLogoutService', [ \SAML2\Constants::BINDING_HTTP_REDIRECT, - \SAML2\Constants::BINDING_HTTP_POST), false); + \SAML2\Constants::BINDING_HTTP_POST], false); if ($endpoint === false) { \SimpleSAML\Logger::info('No logout endpoint for IdP '.var_export($idp, true).'.'); return; @@ -719,15 +719,15 @@ class SP extends Source $state['saml:sp:IdP'] = $idp; $state['PersistentAuthData'][] = 'saml:sp:IdP'; - $authProcState = array( + $authProcState = [ 'saml:sp:IdP' => $idp, 'saml:sp:State' => $state, - 'ReturnCall' => array('\SimpleSAML\Module\saml\Auth\Source\SP', 'onProcessingCompleted'), + 'ReturnCall' => ['\SimpleSAML\Module\saml\Auth\Source\SP', 'onProcessingCompleted'], 'Attributes' => $attributes, 'Destination' => $spMetadataArray, 'Source' => $idpMetadataArray, - ); + ]; if (isset($state['saml:sp:NameID'])) { $authProcState['saml:sp:NameID'] = $state['saml:sp:NameID']; diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php index 15c3e56ba..3f1d734d4 100644 --- a/modules/saml/lib/IdP/SAML1.php +++ b/modules/saml/lib/IdP/SAML1.php @@ -45,11 +45,11 @@ class SAML1 $config = \SimpleSAML\Configuration::getInstance(); $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); - $statsData = array( + $statsData = [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml1', - ); + ]; if (isset($state['saml:AuthnRequestReceivedAt'])) { $statsData['logintime'] = microtime(true) - $state['saml:AuthnRequestReceivedAt']; } @@ -124,25 +124,25 @@ class SAML1 \SimpleSAML\Stats::log( 'saml:idp:AuthnRequest', - array( + [ 'spEntityID' => $spEntityId, 'protocol' => 'saml1', - ) + ] ); $sessionLostURL = HTTP::addURLParameters( HTTP::getSelfURL(), - array('cookieTime' => time()) + ['cookieTime' => time()] ); - $state = array( - 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML1', 'sendResponse'), + $state = [ + 'Responder' => ['\SimpleSAML\Module\saml\IdP\SAML1', 'sendResponse'], 'SPMetadata' => $spMetadata->toArray(), \SimpleSAML\Auth\State::RESTART => $sessionLostURL, 'saml:shire' => $shire, 'saml:target' => $target, 'saml:AuthnRequestReceivedAt' => microtime(true), - ); + ]; $idp->handleAuthenticationRequest($state); } diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 5309d081e..4118b56b7 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -53,14 +53,14 @@ class SAML2 } // create the session association (for logout) - $association = array( + $association = [ 'id' => 'saml:'.$spEntityId, 'Handler' => '\SimpleSAML\Module\saml\IdP\SAML2', 'Expires' => $assertion->getSessionNotOnOrAfter(), 'saml:entityID' => $spEntityId, 'saml:NameID' => $state['saml:idp:NameID'], 'saml:SessionIndex' => $assertion->getSessionIndex(), - ); + ]; // maybe encrypt the assertion $assertion = self::encryptAssertion($idpMetadata, $spMetadata, $assertion); @@ -69,16 +69,16 @@ class SAML2 $ar = self::buildResponse($idpMetadata, $spMetadata, $consumerURL); $ar->setInResponseTo($requestId); $ar->setRelayState($relayState); - $ar->setAssertions(array($assertion)); + $ar->setAssertions([$assertion]); // register the session association with the IdP $idp->addAssociation($association); - $statsData = array( + $statsData = [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml2', - ); + ]; if (isset($state['saml:AuthnRequestReceivedAt'])) { $statsData['logintime'] = microtime(true) - $state['saml:AuthnRequestReceivedAt']; } @@ -129,19 +129,19 @@ class SAML2 $ar->setInResponseTo($requestId); $ar->setRelayState($relayState); - $status = array( + $status = [ 'Code' => $error->getStatus(), 'SubCode' => $error->getSubStatus(), 'Message' => $error->getStatusMessage(), - ); + ]; $ar->setStatus($status); - $statsData = array( + $statsData = [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'protocol' => 'saml2', 'error' => $status, - ); + ]; if (isset($state['saml:AuthnRequestReceivedAt'])) { $statsData['logintime'] = microtime(true) - $state['saml:AuthnRequestReceivedAt']; } @@ -254,7 +254,7 @@ class SAML2 $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpMetadata = $idp->getConfig(); - $supportedBindings = array(\SAML2\Constants::BINDING_HTTP_POST); + $supportedBindings = [\SAML2\Constants::BINDING_HTTP_POST]; if ($idpMetadata->getBoolean('saml20.sendartifact', false)) { $supportedBindings[] = \SAML2\Constants::BINDING_HTTP_ARTIFACT; } @@ -301,7 +301,7 @@ class SAML2 } $requestId = null; - $IDPList = array(); + $IDPList = []; $ProxyCount = null; $RequesterID = null; $forceAuthn = false; @@ -374,14 +374,14 @@ class SAML2 ); } - \SimpleSAML\Stats::log('saml:idp:AuthnRequest', array( + \SimpleSAML\Stats::log('saml:idp:AuthnRequest', [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'forceAuthn' => $forceAuthn, 'isPassive' => $isPassive, 'protocol' => 'saml2', 'idpInit' => $idpInit, - )); + ]); $acsEndpoint = self::getAssertionConsumerService( $supportedBindings, @@ -391,7 +391,7 @@ class SAML2 $consumerIndex ); - $IDPList = array_unique(array_merge($IDPList, $spMetadata->getArrayizeString('IDPList', array()))); + $IDPList = array_unique(array_merge($IDPList, $spMetadata->getArrayizeString('IDPList', []))); if ($ProxyCount === null) { $ProxyCount = $spMetadata->getInteger('ProxyCount', null); } @@ -400,10 +400,10 @@ class SAML2 $forceAuthn = $spMetadata->getBoolean('ForceAuthn', false); } - $sessionLostParams = array( + $sessionLostParams = [ 'spentityid' => $spEntityId, 'cookieTime' => time(), - ); + ]; if ($relayState !== null) { $sessionLostParams['RelayState'] = $relayState; } @@ -413,12 +413,12 @@ class SAML2 $sessionLostParams ); - $state = array( - 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML2', 'sendResponse'), - \SimpleSAML\Auth\State::EXCEPTION_HANDLER_FUNC => array( + $state = [ + 'Responder' => ['\SimpleSAML\Module\saml\IdP\SAML2', 'sendResponse'], + \SimpleSAML\Auth\State::EXCEPTION_HANDLER_FUNC => [ '\SimpleSAML\Module\saml\IdP\SAML2', 'handleAuthError' - ), + ], \SimpleSAML\Auth\State::RESTART => $sessionLostURL, 'SPMetadata' => $spMetadata->toArray(), @@ -436,7 +436,7 @@ class SAML2 'saml:Extensions' => $extensions, 'saml:AuthnRequestReceivedAt' => microtime(true), 'saml:RequestedAuthnContext' => $authnContext, - ); + ]; // ECP AuthnRequests need to supply credentials if ($binding instanceof SOAP) { @@ -475,17 +475,17 @@ class SAML2 $idpMetadata = $idp->getConfig(); $spMetadata = $metadata->getMetaDataConfig($association['saml:entityID'], 'saml20-sp-remote'); - \SimpleSAML\Stats::log('saml:idp:LogoutRequest:sent', array( + \SimpleSAML\Stats::log('saml:idp:LogoutRequest:sent', [ 'spEntityID' => $association['saml:entityID'], 'idpEntityID' => $idpMetadata->getString('entityid'), - )); + ]); $dst = $spMetadata->getEndpointPrioritizedByBinding( 'SingleLogoutService', - array( + [ \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HTTP_POST - ) + ] ); $binding = \SAML2\Binding::getBinding($dst['Binding']); $lr = self::buildLogoutRequest($idpMetadata, $spMetadata, $association, $relayState); @@ -519,27 +519,27 @@ class SAML2 if (isset($state['core:Failed']) && $state['core:Failed']) { $partial = true; - $lr->setStatus(array( + $lr->setStatus([ 'Code' => \SAML2\Constants::STATUS_SUCCESS, 'SubCode' => \SAML2\Constants::STATUS_PARTIAL_LOGOUT, - )); + ]); Logger::info('Sending logout response for partial logout to SP '.var_export($spEntityId, true)); } else { $partial = false; Logger::debug('Sending logout response to SP '.var_export($spEntityId, true)); } - \SimpleSAML\Stats::log('saml:idp:LogoutResponse:sent', array( + \SimpleSAML\Stats::log('saml:idp:LogoutResponse:sent', [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), 'partial' => $partial - )); + ]); $dst = $spMetadata->getEndpointPrioritizedByBinding( 'SingleLogoutService', - array( + [ \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HTTP_POST - ) + ] ); $binding = \SAML2\Binding::getBinding($dst['Binding']); if (isset($dst['ResponseLocation'])) { @@ -578,10 +578,10 @@ class SAML2 if ($message instanceof \SAML2\LogoutResponse) { Logger::info('Received SAML 2.0 LogoutResponse from: '.var_export($spEntityId, true)); - $statsData = array( + $statsData = [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), - ); + ]; if (!$message->isSuccess()) { $statsData['error'] = $message->getStatus(); } @@ -601,20 +601,20 @@ class SAML2 $idp->handleLogoutResponse($assocId, $relayState, $logoutError); } elseif ($message instanceof \SAML2\LogoutRequest) { Logger::info('Received SAML 2.0 LogoutRequest from: '.var_export($spEntityId, true)); - \SimpleSAML\Stats::log('saml:idp:LogoutRequest:recv', array( + \SimpleSAML\Stats::log('saml:idp:LogoutRequest:recv', [ 'spEntityID' => $spEntityId, 'idpEntityID' => $idpMetadata->getString('entityid'), - )); + ]); $spStatsId = $spMetadata->getString('core:statistics-id', $spEntityId); Logger::stats('saml20-idp-SLO spinit '.$spStatsId.' '.$idpMetadata->getString('entityid')); - $state = array( - 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML2', 'sendLogoutResponse'), + $state = [ + 'Responder' => ['\SimpleSAML\Module\saml\IdP\SAML2', 'sendLogoutResponse'], 'saml:SPEntityId' => $spEntityId, 'saml:RelayState' => $message->getRelayState(), 'saml:RequestId' => $message->getId(), - ); + ]; $assocId = 'saml:'.$spEntityId; $idp->handleLogoutRequest($state, $assocId); @@ -643,14 +643,14 @@ class SAML2 $idpMetadata = $idp->getConfig(); $spMetadata = $metadata->getMetaDataConfig($association['saml:entityID'], 'saml20-sp-remote'); - $bindings = array( + $bindings = [ \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HTTP_POST - ); + ]; $dst = $spMetadata->getEndpointPrioritizedByBinding('SingleLogoutService', $bindings); if ($dst['Binding'] === \SAML2\Constants::BINDING_HTTP_POST) { - $params = array('association' => $association['id'], 'idp' => $idp->getId()); + $params = ['association' => $association['id'], 'idp' => $idp->getId()]; if ($relayState !== null) { $params['RelayState'] = $relayState; } @@ -679,7 +679,7 @@ class SAML2 try { return $metadata->getMetaDataConfig($association['saml:entityID'], 'saml20-sp-remote'); } catch (\Exception $e) { - return Configuration::loadFromArray(array(), 'Unknown SAML 2 entity.'); + return Configuration::loadFromArray([], 'Unknown SAML 2 entity.'); } } @@ -761,8 +761,8 @@ class SAML2 $defaultEncoding = 'string'; } - $srcEncodings = $idpMetadata->getArray('attributeencodings', array()); - $dstEncodings = $spMetadata->getArray('attributeencodings', array()); + $srcEncodings = $idpMetadata->getArray('attributeencodings', []); + $dstEncodings = $spMetadata->getArray('attributeencodings', []); /* * Merge the two encoding arrays. Encodings specified in the target metadata @@ -770,9 +770,9 @@ class SAML2 */ $encodings = array_merge($srcEncodings, $dstEncodings); - $ret = array(); + $ret = []; foreach ($attributes as $name => $values) { - $ret[$name] = array(); + $ret[$name] = []; if (array_key_exists($name, $encodings)) { $encoding = $encodings[$name]; } else { @@ -888,7 +888,7 @@ class SAML2 } $a->setIssuer($idpMetadata->getString('entityid')); - $a->setValidAudiences(array($spMetadata->getString('entityid'))); + $a->setValidAudiences([$spMetadata->getString('entityid')]); $a->setNotBefore($now - 30); @@ -943,7 +943,7 @@ class SAML2 if (preg_match($pattern, $clientCert, $matches)) { // we have a client certificate from the browser which we add to the HoK assertion $x509Certificate = new \SAML2\XML\ds\X509Certificate(); - $x509Certificate->certificate = str_replace(array("\r", "\n", " "), '', $matches[1]); + $x509Certificate->certificate = str_replace(["\r", "\n", " "], '', $matches[1]); $x509Data = new \SAML2\XML\ds\X509Data(); $x509Data->data[] = $x509Certificate; @@ -972,7 +972,7 @@ class SAML2 // Bearer $sc->Method = \SAML2\Constants::CM_BEARER; } - $a->setSubjectConfirmation(array($sc)); + $a->setSubjectConfirmation([$sc]); // add attributes if ($spMetadata->getBoolean('simplesaml.attributes', true)) { @@ -1090,7 +1090,7 @@ class SAML2 } // extract the public key from the certificate for encryption - $key = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, ['type' => 'public']); $key->loadKey($pemKey); } else { throw new \SimpleSAML\Error\ConfigurationError( diff --git a/modules/saml/lib/IdP/SQLNameID.php b/modules/saml/lib/IdP/SQLNameID.php index 0df0a9607..95d5712df 100644 --- a/modules/saml/lib/IdP/SQLNameID.php +++ b/modules/saml/lib/IdP/SQLNameID.php @@ -78,12 +78,12 @@ class SQLNameID $store = self::getStore(); - $params = array( + $params = [ '_idp' => $idpEntityId, '_sp' => $spEntityId, '_user' => $user, '_value' => $value, - ); + ]; $query = 'INSERT INTO '.$store->prefix; $query .= '_saml_PersistentNameID (_idp, _sp, _user, _value) VALUES(:_idp, :_sp, :_user, :_value)'; @@ -108,11 +108,11 @@ class SQLNameID $store = self::getStore(); - $params = array( + $params = [ '_idp' => $idpEntityId, '_sp' => $spEntityId, '_user' => $user, - ); + ]; $query = 'SELECT _value FROM '.$store->prefix; $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; @@ -144,11 +144,11 @@ class SQLNameID $store = self::getStore(); - $params = array( + $params = [ '_idp' => $idpEntityId, '_sp' => $spEntityId, '_user' => $user, - ); + ]; $query = 'DELETE FROM '.$store->prefix; $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; @@ -171,17 +171,17 @@ class SQLNameID $store = self::getStore(); - $params = array( + $params = [ '_idp' => $idpEntityId, '_sp' => $spEntityId, - ); + ]; $query = 'SELECT _user, _value FROM '.$store->prefix; $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp'; $query = $store->pdo->prepare($query); $query->execute($params); - $res = array(); + $res = []; while (($row = $query->fetch(\PDO::FETCH_ASSOC)) !== false) { $res[$row['_user']] = $row['_value']; } diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index 8cc89f647..1af7164e8 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -38,7 +38,7 @@ class Message $algo = $srcMetadata->getString('signature.algorithm', XMLSecurityKey::RSA_SHA256); } - $privateKey = new XMLSecurityKey($algo, array('type' => 'private')); + $privateKey = new XMLSecurityKey($algo, ['type' => 'private']); if (array_key_exists('password', $keyArray)) { $privateKey->passphrase = $keyArray['password']; } @@ -56,7 +56,7 @@ class Message return; } - $element->setCertificates(array($certArray['PEM'])); + $element->setCertificates([$certArray['PEM']]); } @@ -114,7 +114,7 @@ class Message */ private static function findCertificate(array $certFingerprints, array $certificates) { - $candidates = array(); + $candidates = []; foreach ($certificates as $cert) { $fp = strtolower(sha1(base64_decode($cert))); @@ -152,7 +152,7 @@ class Message // find the public key that should verify signatures by this entity $keys = $srcMetadata->getPublicKeys('signing'); if (!empty($keys)) { - $pemKeys = array(); + $pemKeys = []; foreach ($keys as $key) { switch ($key['type']) { case 'X509Certificate': @@ -187,7 +187,7 @@ class Message } $pemCert = self::findCertificate($certFingerprint, $certificates); - $pemKeys = array($pemCert); + $pemKeys = [$pemCert]; } else { throw new \SimpleSAML\Error\Exception( 'Missing certificate in metadata for '. @@ -199,7 +199,7 @@ class Message $lastException = null; foreach ($pemKeys as $i => $pem) { - $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type' => 'public')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']); $key->loadKey($pem); try { @@ -287,17 +287,17 @@ class Message if ($sharedKey !== null) { $key = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); $key->loadKey($sharedKey); - return array($key); + return [$key]; } - $keys = array(); + $keys = []; // load the new private key if it exists $keyArray = \SimpleSAML\Utils\Crypto::loadPrivateKey($dstMetadata, false, 'new_'); if ($keyArray !== null) { assert(isset($keyArray['PEM'])); - $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type' => 'private')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, ['type' => 'private']); if (array_key_exists('password', $keyArray)) { $key->passphrase = $keyArray['password']; } @@ -309,7 +309,7 @@ class Message $keyArray = \SimpleSAML\Utils\Crypto::loadPrivateKey($dstMetadata, true); assert(isset($keyArray['PEM'])); - $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type' => 'private')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, ['type' => 'private']); if (array_key_exists('password', $keyArray)) { $key->passphrase = $keyArray['password']; } @@ -336,7 +336,7 @@ class Message ) { $blacklist = $srcMetadata->getArray('encryption.blacklisted-algorithms', null); if ($blacklist === null) { - $blacklist = $dstMetadata->getArray('encryption.blacklisted-algorithms', array(XMLSecurityKey::RSA_1_5)); + $blacklist = $dstMetadata->getArray('encryption.blacklisted-algorithms', [XMLSecurityKey::RSA_1_5]); } return $blacklist; } @@ -471,7 +471,7 @@ class Message $ar = new \SAML2\AuthnRequest(); // get the NameIDPolicy to apply. IdP metadata has precedence. - $nameIdPolicy = array(); + $nameIdPolicy = []; if ($idpMetadata->hasValue('NameIDPolicy')) { $nameIdPolicy = $idpMetadata->getValue('NameIDPolicy'); } elseif ($spMetadata->hasValue('NameIDPolicy')) { @@ -480,14 +480,14 @@ class Message if (!is_array($nameIdPolicy)) { // handle old configurations where 'NameIDPolicy' was used to specify just the format - $nameIdPolicy = array('Format' => $nameIdPolicy); + $nameIdPolicy = ['Format' => $nameIdPolicy]; } $nameIdPolicy_cf = \SimpleSAML\Configuration::loadFromArray($nameIdPolicy); - $policy = array( + $policy = [ 'Format' => $nameIdPolicy_cf->getString('Format', \SAML2\Constants::NAMEID_TRANSIENT), 'AllowCreate' => $nameIdPolicy_cf->getBoolean('AllowCreate', true), - ); + ]; $spNameQualifier = $nameIdPolicy_cf->getString('SPNameQualifier', false); if ($spNameQualifier !== false) { $policy['SPNameQualifier'] = $spNameQualifier; @@ -497,12 +497,12 @@ class Message $ar->setForceAuthn($spMetadata->getBoolean('ForceAuthn', false)); $ar->setIsPassive($spMetadata->getBoolean('IsPassive', false)); - $protbind = $spMetadata->getValueValidate('ProtocolBinding', array( + $protbind = $spMetadata->getValueValidate('ProtocolBinding', [ \SAML2\Constants::BINDING_HTTP_POST, \SAML2\Constants::BINDING_HOK_SSO, \SAML2\Constants::BINDING_HTTP_ARTIFACT, \SAML2\Constants::BINDING_HTTP_REDIRECT, - ), \SAML2\Constants::BINDING_HTTP_POST); + ], \SAML2\Constants::BINDING_HTTP_POST); // Shoaib: setting the appropriate binding based on parameter in sp-metadata defaults to HTTP_POST $ar->setProtocolBinding($protbind); @@ -512,13 +512,13 @@ class Message if ($spMetadata->hasValue('AuthnContextClassRef')) { $accr = $spMetadata->getArrayizeString('AuthnContextClassRef'); - $comp = $spMetadata->getValueValidate('AuthnContextComparison', array( + $comp = $spMetadata->getValueValidate('AuthnContextComparison', [ \SAML2\Constants::COMPARISON_EXACT, \SAML2\Constants::COMPARISON_MINIMUM, \SAML2\Constants::COMPARISON_MAXIMUM, \SAML2\Constants::COMPARISON_BETTER, - ), \SAML2\Constants::COMPARISON_EXACT); - $ar->setRequestedAuthnContext(array('AuthnContextClassRef' => $accr, 'Comparison' => $comp)); + ], \SAML2\Constants::COMPARISON_EXACT); + $ar->setRequestedAuthnContext(['AuthnContextClassRef' => $accr, 'Comparison' => $comp]); } self::addRedirectSign($spMetadata, $idpMetadata, $ar); @@ -609,7 +609,7 @@ class Message throw new \SimpleSAML\Error\Exception('No assertions found in response from IdP.'); } - $ret = array(); + $ret = []; foreach ($assertion as $a) { $ret[] = self::processAssertion($spMetadata, $idpMetadata, $response, $a, $responseSigned); } @@ -686,7 +686,7 @@ class Message $found = false; $lastError = 'No SubjectConfirmation element in Subject.'; - $validSCMethods = array(\SAML2\Constants::CM_BEARER, \SAML2\Constants::CM_HOK, \SAML2\Constants::CM_VOUCHES); + $validSCMethods = [\SAML2\Constants::CM_BEARER, \SAML2\Constants::CM_HOK, \SAML2\Constants::CM_VOUCHES]; foreach ($assertion->getSubjectConfirmation() as $sc) { if (!in_array($sc->Method, $validSCMethods, true)) { $lastError = 'Invalid Method on SubjectConfirmation: '.var_export($sc->Method, true); @@ -728,9 +728,9 @@ class Message continue; } // we have a valid client certificate from the browser - $clientCert = str_replace(array("\r", "\n", " "), '', $matches[1]); + $clientCert = str_replace(["\r", "\n", " "], '', $matches[1]); - $keyInfo = array(); + $keyInfo = []; foreach ($scd->info as $thing) { if ($thing instanceof \SAML2\XML\ds\KeyInfo) { $keyInfo[] = $thing; @@ -742,7 +742,7 @@ class Message continue; } - $x509data = array(); + $x509data = []; foreach ($keyInfo[0]->info as $thing) { if ($thing instanceof \SAML2\XML\ds\X509Data) { $x509data[] = $thing; @@ -754,7 +754,7 @@ class Message continue; } - $x509cert = array(); + $x509cert = []; foreach ($x509data[0]->data as $thing) { if ($thing instanceof \SAML2\XML\ds\X509Certificate) { $x509cert[] = $thing; @@ -811,9 +811,9 @@ class Message // maybe we need to base64 decode the attributes in the assertion? if ($idpMetadata->getBoolean('base64attributes', false)) { $attributes = $assertion->getAttributes(); - $newAttributes = array(); + $newAttributes = []; foreach ($attributes as $name => $values) { - $newAttributes[$name] = array(); + $newAttributes[$name] = []; foreach ($values as $value) { foreach (explode('_', $value) as $v) { $newAttributes[$name][] = base64_decode($v); @@ -880,7 +880,7 @@ class Message $pemKey = "-----BEGIN CERTIFICATE-----\n". chunk_split($key['X509Certificate'], 64). "-----END CERTIFICATE-----\n"; - $key = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public')); + $key = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, ['type' => 'public']); $key->loadKey($pemKey); return $key; } diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index 641c24604..8ea35423a 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -76,7 +76,7 @@ class LogoutStore \SimpleSAML\Logger::debug('saml.LogoutStore: Cleaning logout store.'); $query = 'DELETE FROM '.$store->prefix.'_saml_LogoutStore WHERE _expire < :now'; - $params = array('now' => gmdate('Y-m-d H:i:s')); + $params = ['now' => gmdate('Y-m-d H:i:s')]; $query = $store->pdo->prepare($query); $query->execute($params); @@ -111,16 +111,16 @@ class LogoutStore self::cleanLogoutStore($store); } - $data = array( + $data = [ '_authSource' => $authId, '_nameId' => $nameId, '_sessionIndex' => $sessionIndex, '_expire' => gmdate('Y-m-d H:i:s', $expire), '_sessionId' => $sessionId, - ); + ]; $store->insertOrUpdate( $store->prefix.'_saml_LogoutStore', - array('_authSource', '_nameId', '_sessionIndex'), + ['_authSource', '_nameId', '_sessionIndex'], $data ); } @@ -141,11 +141,11 @@ class LogoutStore self::createLogoutTable($store); - $params = array( + $params = [ '_authSource' => $authId, '_nameId' => $nameId, 'now' => gmdate('Y-m-d H:i:s'), - ); + ]; // We request the columns in lowercase in order to be compatible with PostgreSQL $query = 'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM '.$store->prefix; @@ -153,7 +153,7 @@ class LogoutStore $query = $store->pdo->prepare($query); $query->execute($params); - $res = array(); + $res = []; while (($row = $query->fetch(\PDO::FETCH_ASSOC)) !== false) { $res[$row['_sessionindex']] = $row['_sessionid']; } @@ -176,7 +176,7 @@ class LogoutStore assert(is_string($authId)); assert(is_string($nameId)); - $res = array(); + $res = []; foreach ($sessionIndexes as $sessionIndex) { $sessionId = $store->get('saml.LogoutStore', $nameId.':'.$sessionIndex); if ($sessionId === null) { diff --git a/modules/saml/templates/proxy/invalid_session.php b/modules/saml/templates/proxy/invalid_session.php index 94d63f9cd..ede358580 100644 --- a/modules/saml/templates/proxy/invalid_session.php +++ b/modules/saml/templates/proxy/invalid_session.php @@ -16,10 +16,10 @@ $this->includeAtTemplateBase('includes/header.php'); $translator = $this->getTranslator(); -$params = array( +$params = [ '%IDP%' => $this->data['idp_name'], '%SP%' => $this->data['sp_name'], -); +]; ?> <h2><?php echo $translator->t('{saml:proxy:invalid_idp}'); ?></h2> <p><?php echo $translator->t('{saml:proxy:invalid_idp_description}', $params); ?></p> diff --git a/modules/saml/www/disco.php b/modules/saml/www/disco.php index 147338f0d..b7d06c454 100644 --- a/modules/saml/www/disco.php +++ b/modules/saml/www/disco.php @@ -4,5 +4,5 @@ * Built-in IdP discovery service. */ -$discoHandler = new \SimpleSAML\XHTML\IdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'saml'); +$discoHandler = new \SimpleSAML\XHTML\IdPDisco(['saml20-idp-remote', 'shib13-idp-remote'], 'saml'); $discoHandler->handleRequest(); diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php index abc914092..355218d08 100644 --- a/modules/saml/www/sp/metadata.php +++ b/modules/saml/www/sp/metadata.php @@ -25,12 +25,12 @@ $entityId = $source->getEntityId(); $spconfig = $source->getMetadata(); $store = \SimpleSAML\Store::getInstance(); -$metaArray20 = array(); +$metaArray20 = []; -$slosvcdefault = array( +$slosvcdefault = [ \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_SOAP, -); +]; $slob = $spconfig->getArray('SingleLogoutServiceBinding', $slosvcdefault); $slol = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-logout.php/'.$sourceId); @@ -40,18 +40,18 @@ foreach ($slob as $binding) { // we cannot properly support SOAP logout continue; } - $metaArray20['SingleLogoutService'][] = array( + $metaArray20['SingleLogoutService'][] = [ 'Binding' => $binding, 'Location' => $slol, - ); + ]; } -$assertionsconsumerservicesdefault = array( +$assertionsconsumerservicesdefault = [ 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST', 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post', 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact', 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01', -); +]; if ($spconfig->getString('ProtocolBinding', '') == 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser') { $assertionsconsumerservicesdefault[] = 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser'; @@ -60,10 +60,10 @@ if ($spconfig->getString('ProtocolBinding', '') == 'urn:oasis:names:tc:SAML:2.0: $assertionsconsumerservices = $spconfig->getArray('acs.Bindings', $assertionsconsumerservicesdefault); $index = 0; -$eps = array(); -$supported_protocols = array(); +$eps = []; +$supported_protocols = []; foreach ($assertionsconsumerservices as $services) { - $acsArray = array('index' => $index); + $acsArray = ['index' => $index]; switch ($services) { case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST': $acsArray['Binding'] = \SAML2\Constants::BINDING_HTTP_POST; @@ -108,19 +108,19 @@ foreach ($assertionsconsumerservices as $services) { $metaArray20['AssertionConsumerService'] = $eps; -$keys = array(); +$keys = []; $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig, false, 'new_'); if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $hasNewCert = true; $certData = $certInfo['certData']; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => true, 'X509Certificate' => $certInfo['certData'], - ); + ]; } else { $hasNewCert = false; } @@ -129,12 +129,12 @@ $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig); if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $certData = $certInfo['certData']; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => ($hasNewCert ? false : true), 'X509Certificate' => $certInfo['certData'], - ); + ]; } else { $certData = null; } @@ -145,12 +145,12 @@ if ($format !== null) { } $name = $spconfig->getLocalizedString('name', null); -$attributes = $spconfig->getArray('attributes', array()); +$attributes = $spconfig->getArray('attributes', []); if ($name !== null && !empty($attributes)) { $metaArray20['name'] = $name; $metaArray20['attributes'] = $attributes; - $metaArray20['attributes.required'] = $spconfig->getArray('attributes.required', array()); + $metaArray20['attributes.required'] = $spconfig->getArray('attributes.required', []); if (empty($metaArray20['attributes.required'])) { unset($metaArray20['attributes.required']); diff --git a/modules/saml/www/sp/saml1-acs.php b/modules/saml/www/sp/saml1-acs.php index 66392f4ce..db18627fd 100644 --- a/modules/saml/www/sp/saml1-acs.php +++ b/modules/saml/www/sp/saml1-acs.php @@ -29,11 +29,11 @@ $target = (string) $_REQUEST['TARGET']; if (preg_match('@^https?://@i', $target)) { // Unsolicited response - $state = array( + $state = [ 'saml:sp:isUnsolicited' => true, 'saml:sp:AuthId' => $sourceId, 'saml:sp:RelayState' => \SimpleSAML\Utils\HTTP::checkURLAllowed($target), - ); + ]; } else { $state = \SimpleSAML\Auth\State::loadState($_REQUEST['TARGET'], 'saml:sp:sso'); @@ -82,9 +82,9 @@ if (isset($state['saml:idp']) && $responseIssuer !== $state['saml:idp']) { throw new \SimpleSAML\Error\Exception('The issuer of the response wasn\'t the destination of the request.'); } -$logoutState = array( +$logoutState = [ 'saml:logout:Type' => 'saml1' - ); +]; $state['LogoutState'] = $logoutState; $state['saml:sp:NameID'] = $response->getNameID(); diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php index 75504252d..9dcec80c5 100644 --- a/modules/saml/www/sp/saml2-acs.php +++ b/modules/saml/www/sp/saml2-acs.php @@ -72,7 +72,7 @@ if ($prevAuth !== null && $prevAuth['id'] === $response->getId() && $prevAuth['i throw new \SimpleSAML\Error\Exception('Duplicate assertion received.'); } -$idpMetadata = array(); +$idpMetadata = []; $state = null; $stateId = $response->getInResponseTo(); @@ -100,7 +100,7 @@ if ($state) { assert(array_key_exists('ExpectedIssuer', $state)); if ($state['ExpectedIssuer'] !== $idp) { $idpMetadata = $source->getIdPMetadata($idp); - $idplist = $idpMetadata->getArrayize('IDPList', array()); + $idplist = $idpMetadata->getArrayize('IDPList', []); if (!in_array($state['ExpectedIssuer'], $idplist, true)) { throw new \SimpleSAML\Error\Exception( 'The issuer of the response does not match to the identity provider we sent the request to.' @@ -109,7 +109,7 @@ if ($state) { } } else { // this is an unsolicited response - $state = array( + $state = [ 'saml:sp:isUnsolicited' => true, 'saml:sp:AuthId' => $sourceId, 'saml:sp:RelayState' => \SimpleSAML\Utils\HTTP::checkURLAllowed( @@ -118,7 +118,7 @@ if ($state) { $response->getRelayState() ) ), - ); + ]; } SimpleSAML\Logger::debug('Received SAML2 Response from '.var_export($idp, true).'.'); @@ -140,7 +140,7 @@ $authenticatingAuthority = null; $nameId = null; $sessionIndex = null; $expire = null; -$attributes = array(); +$attributes = []; $foundAuthnStatement = false; foreach ($assertions as $assertion) { // check for duplicate assertion (replay attack) @@ -201,12 +201,12 @@ if (!empty($nameId)) { \SimpleSAML\Module\saml\SP\LogoutStore::addSession($sourceId, $nameId, $sessionIndex, $logoutExpire); // we need to save the NameID and SessionIndex for logout - $logoutState = array( + $logoutState = [ 'saml:logout:Type' => 'saml2', 'saml:logout:IdP' => $idp, 'saml:logout:NameID' => $nameId, 'saml:logout:SessionIndex' => $sessionIndex, - ); + ]; $state['saml:sp:NameID'] = $nameId; // no need to mark it as persistent, it already is } else { @@ -223,9 +223,9 @@ if (!empty($nameId)) { * it to the store), marking the IdP as SAML 1.0, which does not implement logout. Then we can safely log the user * out from the local session, skipping Single Logout upstream to the IdP. */ - $logoutState = array( + $logoutState = [ 'saml:logout:Type' => 'saml1', - ); + ]; } $state['LogoutState'] = $logoutState; @@ -244,10 +244,10 @@ if ($expire !== null) { } // note some information about the authentication, in case we receive the same response again -$state['saml:sp:prevAuth'] = array( +$state['saml:sp:prevAuth'] = [ 'id' => $response->getId(), 'issuer' => $idp, -); +]; if (isset($state['\SimpleSAML\Auth\Source.ReturnURL'])) { $state['saml:sp:prevAuth']['redirect'] = $state['\SimpleSAML\Auth\Source.ReturnURL']; } elseif (isset($state['saml:sp:RelayState'])) { diff --git a/modules/saml/www/sp/saml2-logout.php b/modules/saml/www/sp/saml2-logout.php index 710966efd..e67431f83 100644 --- a/modules/saml/www/sp/saml2-logout.php +++ b/modules/saml/www/sp/saml2-logout.php @@ -120,10 +120,10 @@ if ($message instanceof \SAML2\LogoutResponse) { $dst = $idpMetadata->getEndpointPrioritizedByBinding( 'SingleLogoutService', - array( + [ \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HTTP_POST - ) + ] ); if (!$binding instanceof \SAML2\SOAP) { diff --git a/modules/sanitycheck/config-templates/config-sanitycheck.php b/modules/sanitycheck/config-templates/config-sanitycheck.php index 543ebbba9..d9b45bb8a 100644 --- a/modules/sanitycheck/config-templates/config-sanitycheck.php +++ b/modules/sanitycheck/config-templates/config-sanitycheck.php @@ -3,7 +3,7 @@ * The configuration of SimpleSAMLphp sanitycheck package */ -$config = array( +$config = [ /* * Do you want to generate statistics using the cron module? If so, specify which cron tag to use. * Examples: daily, weekly @@ -11,4 +11,4 @@ $config = array( * 'cron_tag' => null, */ 'cron_tag' => 'hourly', -); +]; diff --git a/modules/sanitycheck/hooks/hook_cron.php b/modules/sanitycheck/hooks/hook_cron.php index dcea2adef..15e0736dd 100644 --- a/modules/sanitycheck/hooks/hook_cron.php +++ b/modules/sanitycheck/hooks/hook_cron.php @@ -21,12 +21,12 @@ function sanitycheck_hook_cron(&$croninfo) return; } - $info = array(); - $errors = array(); - $hookinfo = array( + $info = []; + $errors = []; + $hookinfo = [ 'info' => &$info, 'errors' => &$errors, - ); + ]; SimpleSAML\Module::callHooks('sanitycheck', $hookinfo); diff --git a/modules/sanitycheck/hooks/hook_frontpage.php b/modules/sanitycheck/hooks/hook_frontpage.php index 7a13de7c7..95dddf7aa 100644 --- a/modules/sanitycheck/hooks/hook_frontpage.php +++ b/modules/sanitycheck/hooks/hook_frontpage.php @@ -9,8 +9,8 @@ function sanitycheck_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['config']['sanitycheck'] = array( + $links['config']['sanitycheck'] = [ 'href' => SimpleSAML\Module::getModuleURL('sanitycheck/index.php'), 'text' => '{core:frontpage:link_sanitycheck}', - ); + ]; } diff --git a/modules/sanitycheck/hooks/hook_moduleinfo.php b/modules/sanitycheck/hooks/hook_moduleinfo.php index 0621b972c..87d014e2e 100644 --- a/modules/sanitycheck/hooks/hook_moduleinfo.php +++ b/modules/sanitycheck/hooks/hook_moduleinfo.php @@ -9,11 +9,11 @@ function sanitycheck_hook_moduleinfo(&$moduleinfo) assert(is_array($moduleinfo)); assert(array_key_exists('info', $moduleinfo)); - $moduleinfo['info']['sanitycheck'] = array( - 'name' => array('en' => 'Sanity check'), - 'description' => array('en' => 'This module adds functionality for other modules to provide sanity checks.'), + $moduleinfo['info']['sanitycheck'] = [ + 'name' => ['en' => 'Sanity check'], + 'description' => ['en' => 'This module adds functionality for other modules to provide sanity checks.'], - 'dependencies' => array('core'), - 'uses' => array('cron'), - ); + 'dependencies' => ['core'], + 'uses' => ['cron'], + ]; } diff --git a/modules/sanitycheck/www/index.php b/modules/sanitycheck/www/index.php index ccfd7daec..8946bad07 100644 --- a/modules/sanitycheck/www/index.php +++ b/modules/sanitycheck/www/index.php @@ -2,12 +2,12 @@ $config = \SimpleSAML\Configuration::getInstance(); -$info = array(); -$errors = array(); -$hookinfo = array( +$info = []; +$errors = []; +$hookinfo = [ 'info' => &$info, 'errors' => &$errors, -); +]; \SimpleSAML\Module::callHooks('sanitycheck', $hookinfo); if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') { diff --git a/modules/smartattributes/lib/Auth/Process/SmartID.php b/modules/smartattributes/lib/Auth/Process/SmartID.php index d2aebb452..00ca468ea 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartID.php +++ b/modules/smartattributes/lib/Auth/Process/SmartID.php @@ -11,7 +11,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter * etc., be sure to comment out the entries that map xxx_targetedID to * eduPersonTargetedID, or there will be no way to see its origin any more. */ - private $candidates = array( + private $candidates = [ 'eduPersonTargetedID', 'eduPersonPrincipalName', 'pairwise-id', @@ -21,7 +21,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter 'twitter_targetedID', 'windowslive_targetedID', 'linkedin_targetedID', - ); + ]; /** * The name of the generated ID attribute. @@ -44,7 +44,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter * * Associative array of arrays. */ - private $attributes = array(); + private $attributes = []; public function __construct($config, $reserved) @@ -119,7 +119,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter $id = $this->addID($request['Attributes'], $request); if (isset($id)) { - $request['Attributes'][$this->id_attribute] = array($id); + $request['Attributes'][$this->id_attribute] = [$id]; } } } diff --git a/modules/smartattributes/lib/Auth/Process/SmartName.php b/modules/smartattributes/lib/Auth/Process/SmartName.php index 4ed5af036..19a69baa6 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartName.php +++ b/modules/smartattributes/lib/Auth/Process/SmartName.php @@ -16,7 +16,7 @@ class SmartName extends \SimpleSAML\Auth\ProcessingFilter * * Assiciative array of arrays. */ - private $attributes = array(); + private $attributes = []; private function getFullName($attributes) @@ -86,7 +86,7 @@ class SmartName extends \SimpleSAML\Auth\ProcessingFilter $fullname = $this->getFullName($attributes); if (isset($fullname)) { - $request['Attributes']['smartname-fullname'] = array($fullname); + $request['Attributes']['smartname-fullname'] = [$fullname]; } } } diff --git a/modules/sqlauth/lib/Auth/Source/SQL.php b/modules/sqlauth/lib/Auth/Source/SQL.php index 2ec835f9a..b820a6a3e 100644 --- a/modules/sqlauth/lib/Auth/Source/SQL.php +++ b/modules/sqlauth/lib/Auth/Source/SQL.php @@ -55,7 +55,7 @@ class SQL extends \SimpleSAML\Module\core\Auth\UserPassBase parent::__construct($info, $config); // Make sure that all required parameters are present. - foreach (array('dsn', 'username', 'password', 'query') as $param) { + foreach (['dsn', 'username', 'password', 'query'] as $param) { if (!array_key_exists($param, $config)) { throw new \Exception('Missing required attribute \''.$param. '\' for authentication source '.$this->authId); @@ -142,7 +142,7 @@ class SQL extends \SimpleSAML\Module\core\Auth\UserPassBase } try { - $sth->execute(array('username' => $username, 'password' => $password)); + $sth->execute(['username' => $username, 'password' => $password]); } catch (\PDOException $e) { throw new \Exception('sqlauth:'.$this->authId. ': - Failed to execute query: '.$e->getMessage()); @@ -169,7 +169,7 @@ class SQL extends \SimpleSAML\Module\core\Auth\UserPassBase * which are present in more than one row will become multivalued. null values and * duplicate values will be skipped. All values will be converted to strings. */ - $attributes = array(); + $attributes = []; foreach ($data as $row) { foreach ($row as $name => $value) { if ($value === null) { @@ -179,7 +179,7 @@ class SQL extends \SimpleSAML\Module\core\Auth\UserPassBase $value = (string) $value; if (!array_key_exists($name, $attributes)) { - $attributes[$name] = array(); + $attributes[$name] = []; } if (in_array($value, $attributes[$name], true)) { diff --git a/modules/statistics/bin/loganalyzer.php b/modules/statistics/bin/loganalyzer.php index 0f0f7bfbf..85ae093f3 100755 --- a/modules/statistics/bin/loganalyzer.php +++ b/modules/statistics/bin/loganalyzer.php @@ -29,7 +29,7 @@ foreach ($argv as $a) { } // Map short options to long options. - $shortOptMap = array('-d' => '--debug'); + $shortOptMap = ['-d' => '--debug']; if (array_key_exists($a, $shortOptMap)) { $a = $shortOptMap[$a]; } diff --git a/modules/statistics/bin/logcleaner.php b/modules/statistics/bin/logcleaner.php index 440780d02..b160cdab2 100755 --- a/modules/statistics/bin/logcleaner.php +++ b/modules/statistics/bin/logcleaner.php @@ -30,7 +30,7 @@ foreach ($argv as $a) { } // Map short options to long options. - $shortOptMap = array('-d' => '--debug'); + $shortOptMap = ['-d' => '--debug']; if (array_key_exists($a, $shortOptMap)) { $a = $shortOptMap[$a]; } diff --git a/modules/statistics/config-templates/module_statistics.php b/modules/statistics/config-templates/module_statistics.php index 143494418..9e186dc29 100644 --- a/modules/statistics/config-templates/module_statistics.php +++ b/modules/statistics/config-templates/module_statistics.php @@ -3,7 +3,7 @@ * The configuration of SimpleSAMLphp statistics package */ -$config = array( +$config = [ // Authentication & authorization for statistics // Whether the statistics require authentication before use. @@ -49,32 +49,32 @@ $config = array( */ 'time_limit' => 300, - 'timeres' => array( - 'day' => array( + 'timeres' => [ + 'day' => [ 'name' => 'Day', 'slot' => 60 * 15, // Slots of 15 minutes 'fileslot' => 60 * 60 * 24, // One day (24 hours) file slots 'axislabelint' => 6 * 4, // Number of slots per label. 4 per hour *6 = 6 hours 'dateformat-period' => 'j. M', // 4. Mars 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 - ), - 'week' => array( + ], + 'week' => [ 'name' => 'Week', 'slot' => 60 * 60, // Slots of one hour 'fileslot' => 60 * 60 * 24 * 7, // 7 days of data in each file 'axislabelint' => 24, // Number of slots per label. 24 is one each day 'dateformat-period' => 'j. M', // 4. Mars 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 - ), - 'month' => array( + ], + 'month' => [ 'name' => 'Month', 'slot' => 60 * 60 * 24, // Slots of one day 'fileslot' => 60 * 60 * 24 * 30, // 30 days of data in each file 'axislabelint' => 7, // Number of slots per label. 7 days => 1 week 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 'dateformat-intra' => 'j. M', // 4. Mars - ), - 'monthaligned' => array( + ], + 'monthaligned' => [ 'name' => 'AlignedMonth', 'slot' => 60 * 60 * 24, // Slots of one day 'fileslot' => null, // 30 days of data in each file @@ -82,109 +82,109 @@ $config = array( 'axislabelint' => 7, // Number of slots per label. 7 days => 1 week 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 'dateformat-intra' => 'j. M', // 4. Mars - ), - 'days180' => array( + ], + 'days180' => [ 'name' => '180 days', 'slot' => 60 * 60 * 24, // Slots of 1 day (24 hours) 'fileslot' => 60 * 60 * 24 * 180, // 80 days of data in each file 'axislabelint' => 30, // Number of slots per label. 7 days => 1 week 'dateformat-period' => 'j. M', // 4. Mars 'dateformat-intra' => 'j. M', // 4. Mars - ), - ), + ], + ], - 'statrules' => array( - 'sloratio' => array( + 'statrules' => [ + 'sloratio' => [ 'name' => 'SLO to SSO ratio', 'descr' => 'Comparison of the number of Single Log-Out compared to Single Sign-On.'. ' Graph shows how many logouts where initiated for each Single Sign-On.', 'type' => 'calculated', 'presenter' => 'statistics:Ratio', - 'ref' => array('slo', 'sso'), - 'fieldPresentation' => array( + 'ref' => ['slo', 'sso'], + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'ssomulti' => array( + ], + ], + 'ssomulti' => [ 'name' => 'Requests per session', 'descr' => 'Number of SSO request pairs exchanged between IdP and SP within the same IdP session.'. ' A high number indicates that the session at the SP is timing out faster than at the IdP.', 'type' => 'calculated', 'presenter' => 'statistics:Ratio', - 'ref' => array('sso', 'ssofirst'), - 'fieldPresentation' => array( + 'ref' => ['sso', 'ssofirst'], + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'sso' => array( + ], + ], + 'sso' => [ 'name' => 'SSO to service', 'descr' => 'The number of logins at a Service Provider.', 'action' => 'saml20-idp-SSO', 'col' => 6, // Service Provider EntityID - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'ssofirst' => array( + ], + ], + 'ssofirst' => [ 'name' => 'SSO-first to service', 'descr' => 'The number of logins at a Service Provider.', 'action' => 'saml20-idp-SSO-first', 'col' => 6, // Service Provider EntityID - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'slo' => array( + ], + ], + 'slo' => [ 'name' => 'SLO initiated from service', 'descr' => 'The number of initated Sinlge Logout from each of the service providers.', 'action' => 'saml20-idp-SLO', 'col' => 7, // Service Provider EntityID that initiated the logout. - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'consent' => array( + ], + ], + 'consent' => [ 'name' => 'Consent', 'descr' => 'Consent statistics. Everytime a user logs in to a service an entry is logged for'. ' one of three states: consent was found, consent was not found or consent storage was not available.', 'action' => 'consent', 'col' => 6, - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'consentresponse' => array( + ], + ], + 'consentresponse' => [ 'name' => 'Consent response', 'descr' => 'Consent response statistics. Everytime a user accepts consent,'. ' it is logged whether the user selected to remember the consent to next time.', 'action' => 'consentResponse', 'col' => 6, - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - 'slopages' => array( + ], + ], + 'slopages' => [ 'name' => 'SLO iframe pages', 'descr' => 'The varioust IFrame SLO pages a user visits', 'action' => 'slo-iframe', 'col' => 6, // Page the user visits. - ), - 'slofail' => array( + ], + 'slofail' => [ 'name' => 'Failed iframe IdP-init SLOs', 'descr' => 'The number of logout failures from various SPs', 'action' => 'slo-iframe-fail', 'col' => 6, // Service Provider EntityID that wasn't logged out. - 'fieldPresentation' => array( + 'fieldPresentation' => [ 'class' => 'statistics:Entity', 'config' => 'saml20-sp-remote', - ), - ), - ), -); + ], + ], + ], +]; diff --git a/modules/statistics/hooks/hook_frontpage.php b/modules/statistics/hooks/hook_frontpage.php index a97da1f2c..462a300bf 100644 --- a/modules/statistics/hooks/hook_frontpage.php +++ b/modules/statistics/hooks/hook_frontpage.php @@ -9,13 +9,13 @@ function statistics_hook_frontpage(&$links) assert(is_array($links)); assert(array_key_exists('links', $links)); - $links['config']['statistics'] = array( + $links['config']['statistics'] = [ 'href' => SimpleSAML\Module::getModuleURL('statistics/showstats.php'), 'text' => '{core:frontpage:link_statistics}', - ); - $links['config']['statisticsmeta'] = array( + ]; + $links['config']['statisticsmeta'] = [ 'href' => SimpleSAML\Module::getModuleURL('statistics/statmeta.php'), 'text' => '{core:frontpage:link_statistics_metadata}', - 'shorttext' => array('en' => 'Statistics metadata', 'no' => 'Statistikk metadata'), - ); + 'shorttext' => ['en' => 'Statistics metadata', 'no' => 'Statistikk metadata'], + ]; } diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index dbdba27e6..966012d63 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -97,10 +97,10 @@ class Aggregator $this->statconfig->getValue('datelength', 15), $this->statconfig->getValue('offsetspan', 44) ); - $datehandler = array( + $datehandler = [ 'default' => new DateHandler($this->offset), 'month' => new DateHandlerMonth($this->offset), - ); + ]; $notBefore = 0; $lastRead = 0; @@ -113,7 +113,7 @@ class Aggregator $lastlogline = 'sdfsdf'; $lastlineflip = false; - $results = array(); + $results = []; $i = 0; // Parse through log file, line by line @@ -215,7 +215,7 @@ class Aggregator if (is_int($colrule)) { return trim($content[$colrule]); } elseif (is_array($colrule)) { - $difcols = array(); + $difcols = []; foreach ($colrule as $cr) { $difcols[] = trim($content[$cr]); } @@ -227,11 +227,11 @@ class Aggregator private function cummulateData($previous, $newdata) { - $dataset = array(); + $dataset = []; foreach (func_get_args() as $item) { foreach ($item as $slot => $dataarray) { if (!array_key_exists($slot, $dataset)) { - $dataset[$slot] = array(); + $dataset[$slot] = []; } foreach ($dataarray as $key => $data) { if (!array_key_exists($key, $dataset[$slot])) { @@ -246,10 +246,10 @@ class Aggregator public function store($results) { - $datehandler = array( + $datehandler = [ 'default' => new DateHandler($this->offset), 'month' => new DateHandlerMonth($this->offset), - ); + ]; // Iterate the first level of results, which is per rule, as defined in the config. foreach ($results as $rulename => $timeresdata) { @@ -282,15 +282,15 @@ class Aggregator ); // Fill in missing entries and sort file results - $filledresult = array(); + $filledresult = []; for ($slot = $start; $slot < $end; $slot++) { if (array_key_exists($slot, $fileres)) { $filledresult[$slot] = $fileres[$slot]; } else { if ($lastfile == $fileno && $slot > $maxslot) { - $filledresult[$slot] = array('_' => null); + $filledresult[$slot] = ['_' => null]; } else { - $filledresult[$slot] = array('_' => 0); + $filledresult[$slot] = ['_' => 0]; } } } diff --git a/modules/statistics/lib/Graph/GoogleCharts.php b/modules/statistics/lib/Graph/GoogleCharts.php index 9e7e32377..129639de5 100644 --- a/modules/statistics/lib/Graph/GoogleCharts.php +++ b/modules/statistics/lib/Graph/GoogleCharts.php @@ -44,7 +44,7 @@ class GoogleCharts // t:10.0,58.0,95.0 private function encodedata($datasets) { - $setstr = array(); + $setstr = []; foreach ($datasets as $dataset) { $setstr[] = self::extEncode($dataset); } @@ -119,7 +119,7 @@ class GoogleCharts 'chs='.$this->x.'x'.$this->y. // Dateset values. - '&chd='.$this->encodedata(array($datasets)). + '&chd='.$this->encodedata([$datasets]). // chart type is linechart '&cht=p'. @@ -162,7 +162,7 @@ class GoogleCharts } $maxGridLines = 10; - $candidates = array(1, 2, 5, 10, 20, 25, 50, 100); + $candidates = [1, 2, 5, 10, 20, 25, 50, 100]; foreach ($candidates as $c) { if ($t / $c < $maxGridLines) { diff --git a/modules/statistics/lib/LogCleaner.php b/modules/statistics/lib/LogCleaner.php index ac172a28e..eafb50190 100644 --- a/modules/statistics/lib/LogCleaner.php +++ b/modules/statistics/lib/LogCleaner.php @@ -65,7 +65,7 @@ class LogCleaner $this->statconfig->getValue('offsetspan', 44) ); - $sessioncounter = array(); + $sessioncounter = []; $i = 0; // Parse through log file, line by line @@ -105,7 +105,7 @@ class LogCleaner } } - $histogram = array(); + $histogram = []; foreach ($sessioncounter as $trackid => $sc) { if (!isset($histogram[$sc])) { $histogram[$sc] = 0; @@ -114,7 +114,7 @@ class LogCleaner } ksort($histogram); - $todelete = array(); + $todelete = []; foreach ($sessioncounter as $trackid => $sc) { if ($sc > 200) { $todelete[] = $trackid; diff --git a/modules/statistics/lib/RatioDataset.php b/modules/statistics/lib/RatioDataset.php index 0abd90416..5449a3fd1 100644 --- a/modules/statistics/lib/RatioDataset.php +++ b/modules/statistics/lib/RatioDataset.php @@ -14,8 +14,8 @@ class RatioDataset extends StatDataset /** * Aggregate summary table from dataset. To be used in the table view. */ - $this->summary = array(); - $noofvalues = array(); + $this->summary = []; + $noofvalues = []; foreach ($this->results as $slot => $res) { foreach ($res as $key => $value) { if (array_key_exists($key, $this->summary)) { @@ -60,10 +60,10 @@ class RatioDataset extends StatDataset public function combine($result1, $result2) { - $combined = array(); + $combined = []; foreach ($result2 as $tick => $val) { - $combined[$tick] = array(); + $combined[$tick] = []; foreach ($val as $index => $num) { $combined[$tick][$index] = $this->divide( $this->ag($index, $result1[$tick]), diff --git a/modules/statistics/lib/Ruleset.php b/modules/statistics/lib/Ruleset.php index 5b7b85d94..9d8c67d05 100644 --- a/modules/statistics/lib/Ruleset.php +++ b/modules/statistics/lib/Ruleset.php @@ -36,7 +36,7 @@ class Ruleset throw new \Exception('Statisics output directory ['.$statdir.'] does not exists.'); } $filelist = scandir($statdir); - $this->available = array(); + $this->available = []; foreach ($filelist as $file) { if (preg_match('/([a-z0-9_]+)-([a-z0-9_]+)-([0-9]+)\.stat/', $file, $matches)) { if (array_key_exists($matches[1], $statrules)) { @@ -54,9 +54,9 @@ class Ruleset * Create array with information about available rules.. */ $this->availrules = array_keys($statrules); - $available_rules = array(); + $available_rules = []; foreach ($this->availrules as $key) { - $available_rules[$key] = array('name' => $statrules[$key]['name'], 'descr' => $statrules[$key]['descr']); + $available_rules[$key] = ['name' => $statrules[$key]['name'], 'descr' => $statrules[$key]['descr']]; } $this->availrulenames = $available_rules; } diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php index cc8fed149..70898bfbc 100644 --- a/modules/statistics/lib/StatDataset.php +++ b/modules/statistics/lib/StatDataset.php @@ -96,16 +96,16 @@ class StatDataset public function getDebugData() { - $debugdata = array(); + $debugdata = []; $slotsize = $this->timeresconfig->getValue('slot'); $dateformat_intra = $this->timeresconfig->getValue('dateformat-intra'); foreach ($this->results as $slot => &$res) { - $debugdata[$slot] = array( + $debugdata[$slot] = [ $this->datehandlerTick->prettyDateSlot($slot, $slotsize, $dateformat_intra), $res[$this->delimiter] - ); + ]; } return $debugdata; } @@ -113,7 +113,7 @@ class StatDataset public function aggregateSummary() { // aggregate summary table from dataset. To be used in the table view - $this->summary = array(); + $this->summary = []; foreach ($this->results as $slot => $res) { foreach ($res as $key => $value) { if (array_key_exists($key, $this->summary)) { @@ -130,7 +130,7 @@ class StatDataset public function getTopDelimiters() { // create a list of delimiter keys that has the highest total summary in this period - $topdelimiters = array(); + $topdelimiters = []; $maxdelimiters = 4; $i = 0; foreach ($this->summary as $key => $value) { @@ -146,7 +146,7 @@ class StatDataset public function availDelimiters() { - $availDelimiters = array(); + $availDelimiters = []; foreach ($this->summary as $key => $value) { $availDelimiters[$key] = 1; } @@ -155,7 +155,7 @@ class StatDataset public function getPieData() { - $piedata = array(); + $piedata = []; $sum = 0; $topdelimiters = $this->getTopDelimiters(); @@ -188,8 +188,8 @@ class StatDataset $dateformat_intra = $this->timeresconfig->getValue('dateformat-intra'); $axislabelint = $this->timeresconfig->getValue('axislabelint'); - $axis = array(); - $axispos = array(); + $axis = []; + $axispos = []; $xentries = count($this->results); $lastslot = 0; $i = 0; @@ -206,7 +206,7 @@ class StatDataset $axis[] = $this->datehandlerTick->prettyDateSlot($lastslot + 1, $slotsize, $dateformat_intra); - return array('axis' => $axis, 'axispos' => $axispos); + return ['axis' => $axis, 'axispos' => $axispos]; } /* @@ -215,7 +215,7 @@ class StatDataset public function getPercentValues() { $i = 0; - $dataset = array(); + $dataset = []; foreach ($this->results as $slot => $res) { if (array_key_exists($this->delimiter, $res)) { if ($res[$this->delimiter] === null) { @@ -254,7 +254,7 @@ class StatDataset return $presentationHandler->getPresentation(); } - return array(); + return []; } public function getDelimiterPresentationPie() @@ -262,7 +262,7 @@ class StatDataset $topdelimiters = $this->getTopDelimiters(); $delimiterPresentation = $this->getDelimiterPresentation(); - $pieaxis = array(); + $pieaxis = []; foreach ($topdelimiters as $key) { $keyName = $key; if (array_key_exists($key, $delimiterPresentation)) { @@ -277,7 +277,7 @@ class StatDataset public function loadData() { $statdir = $this->statconfig->getValue('statdir'); - $resarray = array(); + $resarray = []; $rules = \SimpleSAML\Utils\Arrays::arrayize($this->ruleid); foreach ($rules as $rule) { // Get file and extract results. diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Base.php b/modules/statistics/lib/Statistics/FieldPresentation/Base.php index 591892b79..bb2568f1d 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Base.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Base.php @@ -17,6 +17,6 @@ class Base public function getPresentation() { - return array('_' => 'Total'); + return ['_' => 'Total']; } } diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php index 15b4809cb..624d215b7 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php @@ -9,7 +9,7 @@ class Entity extends Base $mh = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $metadata = $mh->getList($this->config); - $translation = array('_' => 'All services'); + $translation = ['_' => 'All services']; foreach ($this->fields as $field) { if (array_key_exists($field, $metadata)) { if (array_key_exists('name', $metadata[$field])) { diff --git a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php index 469bec780..875557bc8 100644 --- a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php +++ b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php @@ -39,7 +39,7 @@ class BaseRule public function availableTimeRes() { $timeresConfigs = $this->statconfig->getValue('timeres'); - $available_times = array(); + $available_times = []; foreach ($timeresConfigs as $tres => $tresconfig) { if (array_key_exists($tres, $this->available)) { $available_times[$tres] = $tresconfig['name']; @@ -62,7 +62,7 @@ class BaseRule /* * Get list of avaiable times in current file (rule) */ - $available_times = array(); + $available_times = []; foreach ($this->available[$timeres] as $slot) { $available_times[$slot] = $datehandler->prettyHeader( $slot, @@ -115,7 +115,7 @@ class BaseRule if ($timeslotindex[$fileslot] < (count($timeslotindex) - 1)) { $available_times_next = $timeslots[$timeslotindex[$fileslot] + 1]; } - return array('prev' => $available_times_prev, 'next' => $available_times_next); + return ['prev' => $available_times_prev, 'next' => $available_times_next]; } public function getDataSet($preferTimeRes, $preferTime) diff --git a/modules/statistics/templates/statistics.tpl.php b/modules/statistics/templates/statistics.tpl.php index 243a101e5..2e111451f 100644 --- a/modules/statistics/templates/statistics.tpl.php +++ b/modules/statistics/templates/statistics.tpl.php @@ -1,7 +1,7 @@ <?php $this->data['header'] = 'SimpleSAMLphp Statistics'; -$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); +$this->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true]; $this->data['head'] = '<link rel="stylesheet" type="text/css" href="'. SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css").'" />'."\n"; @@ -167,7 +167,7 @@ if (!empty($this->data['results'])) { /** * Handle table view - - - - - - */ - $classint = array('odd', 'even'); + $classint = ['odd', 'even']; $i = 0; echo '<div id="table" class="tabset_content">'; diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php index ac5968824..a8a2f247b 100644 --- a/modules/statistics/www/showstats.php +++ b/modules/statistics/www/showstats.php @@ -85,12 +85,12 @@ $timeNavigation = $statrule->getTimeNavigation($timeres, $preferTime); $piedata = $dataset->getPieData(); -$datasets = array(); +$datasets = []; $datasets[] = $dataset->getPercentValues(); $axis = $dataset->getAxis(); -$maxes = array(); +$maxes = []; $maxes[] = $dataset->getMax(); @@ -148,17 +148,17 @@ $t->data['get_times_next'] = getBaseURL($t, 'get', 'time', $t->data['available_t $t->data['availdelimiters'] = $dataset->availDelimiters(); $t->data['delimiterPresentation'] = $dataset->getDelimiterPresentation(); -$t->data['jquery'] = array('core' => false, 'ui' => true, 'css' => true); +$t->data['jquery'] = ['core' => false, 'ui' => true, 'css' => true]; $t->show(); function getBaseURL($t, $type = 'get', $key = null, $value = null) { - $vars = array( + $vars = [ 'rule' => $t->data['selected_rule'], 'time' => $t->data['selected_time'], 'res' => $t->data['selected_timeres'], - ); + ]; if (isset($t->data['selected_delimiter'])) { $vars['d'] = $t->data['selected_delimiter']; } diff --git a/templates/includes/attributes.php b/templates/includes/attributes.php index 68230ce74..78b862f48 100644 --- a/templates/includes/attributes.php +++ b/templates/includes/attributes.php @@ -33,27 +33,27 @@ function present_assoc($attr) function present_eptid(\SimpleSAML\Locale\Translate $t, \SAML2\XML\saml\NameID $nameID) { - $eptid = array( - 'NameID' => array($nameID->value), - ); + $eptid = [ + 'NameID' => [$nameID->value], + ]; if (!empty($nameID->Format)) { - $eptid[$t->t('{status:subject_format}')] = array($nameID->Format); + $eptid[$t->t('{status:subject_format}')] = [$nameID->Format]; } if (!empty($nameID->NameQualifier)) { - $eptid['NameQualifier'] = array($nameID->NameQualifier); + $eptid['NameQualifier'] = [$nameID->NameQualifier]; } if (!empty($nameID->SPNameQualifier)) { - $eptid['SPNameQualifier'] = array($nameID->SPNameQualifier); + $eptid['SPNameQualifier'] = [$nameID->SPNameQualifier]; } if (!empty($nameID->SPProvidedID)) { - $eptid['SPProvidedID'] = array($nameID->SPProvidedID); + $eptid['SPProvidedID'] = [$nameID->SPProvidedID]; } return '<td class="attrvalue">'.present_assoc($eptid); } function present_attributes(\SimpleSAML\XHTML\Template $t, $attributes, $nameParent) { - $alternate = array('odd', 'even'); + $alternate = ['odd', 'even']; $i = 0; $parentStr = (strlen($nameParent) > 0) ? strtolower($nameParent).'_' : ''; diff --git a/templates/metadata.php b/templates/metadata.php index cda59b566..c851afea2 100644 --- a/templates/metadata.php +++ b/templates/metadata.php @@ -4,7 +4,7 @@ $this->includeAtTemplateBase('includes/header.php'); ?> <h2><?php echo $this->data['header']; ?></h2> <p><?php echo $this->t('metadata_intro'); ?></p> <?php if (isset($this->data['metaurl'])) { ?> - <p><?php echo($this->t('metadata_xmlurl', array('%METAURL%' => htmlspecialchars($this->data['metaurl'])))); ?></p> + <p><?php echo($this->t('metadata_xmlurl', ['%METAURL%' => htmlspecialchars($this->data['metaurl'])])); ?></p> <div class="input-group"> <pre id="metadataurl" class="input-left"><?php echo htmlspecialchars($this->data['metaurl']); ?></pre> <button data-clipboard-target="#metadataurl" id="btnurl" class="btnaddonright"> diff --git a/templates/post.php b/templates/post.php index 8995523dd..643f08e77 100644 --- a/templates/post.php +++ b/templates/post.php @@ -31,10 +31,10 @@ if (array_key_exists('post', $this->data)) { assert(array_key_exists('response', $this->data)); assert(array_key_exists('RelayStateName', $this->data)); assert(array_key_exists('RelayState', $this->data)); - $post = array( + $post = [ 'SAMLResponse' => $this->data['response'], $this->data['RelayStateName'] => $this->data['RelayState'], - ); + ]; } /** diff --git a/templates/status.php b/templates/status.php index 7732cbc90..6ddc51911 100644 --- a/templates/status.php +++ b/templates/status.php @@ -18,11 +18,11 @@ $this->includeAtTemplateBase('includes/attributes.php'); <?php if (isset($this->data['remaining'])) { - echo '<p>'.$this->t('{status:validfor}', array('%SECONDS%' => $this->data['remaining'])).'</p>'; + echo '<p>'.$this->t('{status:validfor}', ['%SECONDS%' => $this->data['remaining']]).'</p>'; } if (isset($this->data['sessionsize'])) { - echo '<p>'.$this->t('{status:sessionsize}', array('%SIZE%' => $this->data['sessionsize'])).'</p>'; + echo '<p>'.$this->t('{status:sessionsize}', ['%SIZE%' => $this->data['sessionsize']]).'</p>'; } ?> <h2><?php echo $this->t('{status:attributes_header}'); ?></h2> @@ -35,23 +35,23 @@ if ($nameid !== false) { /** @var \SAML2\XML\saml\NameID $nameid */ echo "<h2>".$this->t('{status:subject_header}')."</h2>"; if (is_null($nameid->value)) { - $list = array("NameID" => array($this->t('{status:subject_notset}'))); + $list = ["NameID" => [$this->t('{status:subject_notset}')]]; echo "<p>NameID: <span class=\"notset\">".$this->t('{status:subject_notset}')."</span></p>"; } else { - $list = array( - "NameId" => array($nameid->value), - ); + $list = [ + "NameId" => [$nameid->value], + ]; if (!is_null($nameid->Format)) { - $list[$this->t('{status:subject_format}')] = array($nameid->Format); + $list[$this->t('{status:subject_format}')] = [$nameid->Format]; } if (!is_null($nameid->NameQualifier)) { - $list['NameQualifier'] = array($nameid->NameQualifier); + $list['NameQualifier'] = [$nameid->NameQualifier]; } if (!is_null($nameid->SPNameQualifier)) { - $list['SPNameQualifier'] = array($nameid->SPNameQualifier); + $list['SPNameQualifier'] = [$nameid->SPNameQualifier]; } if (!is_null($nameid->SPProvidedID)) { - $list['SPProvidedID'] = array($nameid->SPProvidedID); + $list['SPProvidedID'] = [$nameid->SPProvidedID]; } } echo present_attributes($this, $list, ''); diff --git a/tests/BuiltInServer.php b/tests/BuiltInServer.php index 4f614f511..e98a4a61c 100644 --- a/tests/BuiltInServer.php +++ b/tests/BuiltInServer.php @@ -89,7 +89,7 @@ class BuiltInServer ); // execute the command and store the process ID - $output = array(); + $output = []; exec($command, $output); $this->pid = (int) $output[0]; @@ -170,32 +170,32 @@ class BuiltInServer * * @return array|string The response obtained from the built-in server. */ - public function get($query, $parameters, $curlopts = array()) + public function get($query, $parameters, $curlopts = []) { $ch = curl_init(); $url = 'http://'.$this->address.$query; $url .= (!empty($parameters)) ? '?'.http_build_query($parameters) : ''; - curl_setopt_array($ch, array( + curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 1, - )); + ]); curl_setopt_array($ch, $curlopts); $resp = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); list($header, $body) = explode("\r\n\r\n", $resp, 2); $raw_headers = explode("\r\n", $header); array_shift($raw_headers); - $headers = array(); + $headers = []; foreach ($raw_headers as $header) { list($name, $value) = explode(':', $header, 2); $headers[trim($name)] = trim($value); } curl_close($ch); - return array( + return [ 'code' => $code, 'headers' => $headers, 'body' => $body, - ); + ]; } } diff --git a/tests/Utils/ReduceSpillOverTest.php b/tests/Utils/ReduceSpillOverTest.php index 2f474576d..82f82da39 100644 --- a/tests/Utils/ReduceSpillOverTest.php +++ b/tests/Utils/ReduceSpillOverTest.php @@ -15,7 +15,7 @@ class ReduceSpillOverTest extends ClearStateTestCase public function testSetState() { $_SERVER['QUERY_STRING'] = 'a=b'; - \SimpleSAML\Configuration::loadFromArray(array('a' => 'b'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['a' => 'b'], '[ARRAY]', 'simplesaml'); $this->assertEquals('b', \SimpleSAML\Configuration::getInstance()->getString('a')); putenv('SIMPLESAMLPHP_CONFIG_DIR=' . __DIR__); } diff --git a/tests/Utils/StateClearer.php b/tests/Utils/StateClearer.php index db32db8e7..ee2b686bf 100644 --- a/tests/Utils/StateClearer.php +++ b/tests/Utils/StateClearer.php @@ -12,19 +12,19 @@ class StateClearer * Global state to restore between test runs * @var array */ - private $backups = array(); + private $backups = []; /** * Class that implement \SimpleSAML\Utils\ClearableState and should have clearInternalState called between tests * @var array */ - private $clearableState = array('SimpleSAML\Configuration'); + private $clearableState = ['SimpleSAML\Configuration']; /** * Environmental variables to unset * @var array */ - private $vars_to_unset = array('SIMPLESAMLPHP_CONFIG_DIR'); + private $vars_to_unset = ['SIMPLESAMLPHP_CONFIG_DIR']; public function backupGlobals() { @@ -36,7 +36,7 @@ class StateClearer $this->backups['$_GET'] = $_GET; $this->backups['$_POST'] = $_POST; $this->backups['$_SERVER'] = $_SERVER; - $this->backups['$_SESSION'] = isset($_SESSION) ? $_SESSION : array(); + $this->backups['$_SESSION'] = isset($_SESSION) ? $_SESSION : []; $this->backups['$_REQUEST'] = $_REQUEST; } diff --git a/tests/lib/SimpleSAML/Auth/SimpleTest.php b/tests/lib/SimpleSAML/Auth/SimpleTest.php index e0543b44b..7d667ab46 100644 --- a/tests/lib/SimpleSAML/Auth/SimpleTest.php +++ b/tests/lib/SimpleSAML/Auth/SimpleTest.php @@ -21,68 +21,68 @@ class SimpleTest extends \SimpleSAML\Test\Utils\ClearStateTestCase $_SERVER['REQUEST_URI'] = '/'; // test merging configuration option with passed URL - \SimpleSAML\Configuration::loadFromArray(array( - 'application' => array( + \SimpleSAML\Configuration::loadFromArray([ + 'application' => [ 'baseURL' => 'https://example.org' - ) - ), '[ARRAY]', 'simplesaml'); + ] + ], '[ARRAY]', 'simplesaml'); $s = new \SimpleSAML\Auth\Simple(''); - $this->assertEquals('https://example.org/', $method->invokeArgs($s, array(null))); + $this->assertEquals('https://example.org/', $method->invokeArgs($s, [null])); // test a full URL passed as parameter $this->assertEquals( 'https://example.org/foo/bar?a=b#fragment', $method->invokeArgs( $s, - array('http://some.overridden.host/foo/bar?a=b#fragment') + ['http://some.overridden.host/foo/bar?a=b#fragment'] ) ); // test a full, current URL with no parameters $_SERVER['REQUEST_URI'] = '/foo/bar?a=b#fragment'; - $this->assertEquals('https://example.org/foo/bar?a=b#fragment', $method->invokeArgs($s, array(null))); + $this->assertEquals('https://example.org/foo/bar?a=b#fragment', $method->invokeArgs($s, [null])); // test ports are overridden by configuration $_SERVER['SERVER_PORT'] = '1234'; - $this->assertEquals('https://example.org/foo/bar?a=b#fragment', $method->invokeArgs($s, array(null))); + $this->assertEquals('https://example.org/foo/bar?a=b#fragment', $method->invokeArgs($s, [null])); // test config option with ending with / and port - \SimpleSAML\Configuration::loadFromArray(array( - 'application' => array( + \SimpleSAML\Configuration::loadFromArray([ + 'application' => [ 'baseURL' => 'http://example.org:8080/' - ) - ), '[ARRAY]', 'simplesaml'); + ] + ], '[ARRAY]', 'simplesaml'); $s = new \SimpleSAML\Auth\Simple(''); - $this->assertEquals('http://example.org:8080/foo/bar?a=b#fragment', $method->invokeArgs($s, array(null))); + $this->assertEquals('http://example.org:8080/foo/bar?a=b#fragment', $method->invokeArgs($s, [null])); // test again with a relative URL as a parameter $this->assertEquals( 'http://example.org:8080/something?foo=bar#something', - $method->invokeArgs($s, array('/something?foo=bar#something')) + $method->invokeArgs($s, ['/something?foo=bar#something']) ); // now test with no configuration $_SERVER['SERVER_NAME'] = 'example.org'; - \SimpleSAML\Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); $s = new \SimpleSAML\Auth\Simple(''); - $this->assertEquals('http://example.org:1234/foo/bar?a=b#fragment', $method->invokeArgs($s, array(null))); + $this->assertEquals('http://example.org:1234/foo/bar?a=b#fragment', $method->invokeArgs($s, [null])); // no configuration, https and port $_SERVER['HTTPS'] = 'on'; - $this->assertEquals('https://example.org:1234/foo/bar?a=b#fragment', $method->invokeArgs($s, array(null))); + $this->assertEquals('https://example.org:1234/foo/bar?a=b#fragment', $method->invokeArgs($s, [null])); // no configuration and a relative URL as a parameter $this->assertEquals( 'https://example.org:1234/something?foo=bar#something', - $method->invokeArgs($s, array('/something?foo=bar#something')) + $method->invokeArgs($s, ['/something?foo=bar#something']) ); // finally, no configuration and full URL as a parameter $this->assertEquals( 'https://example.org/one/two/three?foo=bar#fragment', - $method->invokeArgs($s, array('https://example.org/one/two/three?foo=bar#fragment')) + $method->invokeArgs($s, ['https://example.org/one/two/three?foo=bar#fragment']) ); } } diff --git a/tests/lib/SimpleSAML/Auth/StateTest.php b/tests/lib/SimpleSAML/Auth/StateTest.php index b9bc2b5c4..210d7ddfc 100644 --- a/tests/lib/SimpleSAML/Auth/StateTest.php +++ b/tests/lib/SimpleSAML/Auth/StateTest.php @@ -13,14 +13,14 @@ class Auth_StateTest extends TestCase public function testGetPersistentAuthData() { - $mandatory = array( - 'Attributes' => array(), + $mandatory = [ + 'Attributes' => [], 'Expire' => 1234, 'LogoutState' => 'logoutState', 'AuthInstant' => 123456, 'RememberMe' => true, 'saml:sp:NameID' => 'nameID', - ); + ]; // check just mandatory parameters $state = $mandatory; @@ -42,10 +42,10 @@ class Auth_StateTest extends TestCase ); // check additional non-persistent parameters - $additional = array( + $additional = [ 'additional1' => 1, 'additional2' => 2, - ); + ]; $state = array_merge($mandatory, $additional); $expected = $mandatory; $this->assertEquals( @@ -55,7 +55,7 @@ class Auth_StateTest extends TestCase ); // check additional persistent parameters - $additional['PersistentAuthData'] = array('additional1'); + $additional['PersistentAuthData'] = ['additional1']; $state = array_merge($mandatory, $additional); $expected = $state; unset($expected['additional2']); diff --git a/tests/lib/SimpleSAML/Auth/TimeLimitedTokenTest.php b/tests/lib/SimpleSAML/Auth/TimeLimitedTokenTest.php index 782de37be..710d3c2d3 100644 --- a/tests/lib/SimpleSAML/Auth/TimeLimitedTokenTest.php +++ b/tests/lib/SimpleSAML/Auth/TimeLimitedTokenTest.php @@ -11,7 +11,7 @@ class TimeLimitedTokenTest extends \SimpleSAML\Test\Utils\ClearStateTestCase */ public function testMalformedToken() { - \SimpleSAML\Configuration::loadFromArray(array('secretsalt' => 'random'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['secretsalt' => 'random'], '[ARRAY]', 'simplesaml'); $token = new TimeLimitedToken(); $this->assertFalse($token->validate('malformed')); @@ -25,7 +25,7 @@ class TimeLimitedTokenTest extends \SimpleSAML\Test\Utils\ClearStateTestCase */ public function testValidToken() { - \SimpleSAML\Configuration::loadFromArray(array('secretsalt' => 'random'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['secretsalt' => 'random'], '[ARRAY]', 'simplesaml'); $token = new TimeLimitedToken(); $t = $token->generate(); @@ -38,7 +38,7 @@ class TimeLimitedTokenTest extends \SimpleSAML\Test\Utils\ClearStateTestCase */ public function testValidTokenWithData() { - \SimpleSAML\Configuration::loadFromArray(array('secretsalt' => 'random'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['secretsalt' => 'random'], '[ARRAY]', 'simplesaml'); $tokenWithData = new TimeLimitedToken(); $tokenWithData->addVerificationData('some more random data'); @@ -55,7 +55,7 @@ class TimeLimitedTokenTest extends \SimpleSAML\Test\Utils\ClearStateTestCase */ public function testExpiredToken() { - \SimpleSAML\Configuration::loadFromArray(array('secretsalt' => 'random'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['secretsalt' => 'random'], '[ARRAY]', 'simplesaml'); $token = new TimeLimitedToken(); $this->assertFalse($token->validate('7-c0803e76fff1df0ceb222dee80aa1d73f35d84dd')); @@ -67,7 +67,7 @@ class TimeLimitedTokenTest extends \SimpleSAML\Test\Utils\ClearStateTestCase */ public function testManipulatedToken() { - \SimpleSAML\Configuration::loadFromArray(array('secretsalt' => 'random'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['secretsalt' => 'random'], '[ARRAY]', 'simplesaml'); $token = new TimeLimitedToken(1); $t = $token->generate(); diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index 7df691741..9f7d4dcd3 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -22,7 +22,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testLoadDefaultInstance() { - Configuration::loadFromArray(array('key' => 'value'), '', 'dummy'); + Configuration::loadFromArray(['key' => 'value'], '', 'dummy'); Configuration::getInstance(); } @@ -72,7 +72,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testGetValueRequired() { - $c = Configuration::loadFromArray(array()); + $c = Configuration::loadFromArray([]); $c->getValue('missing', Configuration::REQUIRED_OPTION); } @@ -81,10 +81,10 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testHasValue() { - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'exists_true' => true, 'exists_null' => null, - )); + ]); $this->assertEquals($c->hasValue('missing'), false); $this->assertEquals($c->hasValue('exists_true'), true); $this->assertEquals($c->hasValue('exists_null'), true); @@ -95,18 +95,18 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testHasValueOneOf() { - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'exists_true' => true, 'exists_null' => null, - )); - $this->assertEquals($c->hasValueOneOf(array()), false); - $this->assertEquals($c->hasValueOneOf(array('missing')), false); - $this->assertEquals($c->hasValueOneOf(array('exists_true')), true); - $this->assertEquals($c->hasValueOneOf(array('exists_null')), true); + ]); + $this->assertEquals($c->hasValueOneOf([]), false); + $this->assertEquals($c->hasValueOneOf(['missing']), false); + $this->assertEquals($c->hasValueOneOf(['exists_true']), true); + $this->assertEquals($c->hasValueOneOf(['exists_null']), true); - $this->assertEquals($c->hasValueOneOf(array('missing1', 'missing2')), false); - $this->assertEquals($c->hasValueOneOf(array('exists_true', 'missing')), true); - $this->assertEquals($c->hasValueOneOf(array('missing', 'exists_true')), true); + $this->assertEquals($c->hasValueOneOf(['missing1', 'missing2']), false); + $this->assertEquals($c->hasValueOneOf(['exists_true', 'missing']), true); + $this->assertEquals($c->hasValueOneOf(['missing', 'exists_true']), true); } /** @@ -114,55 +114,55 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testGetBasePath() { - $c = Configuration::loadFromArray(array()); + $c = Configuration::loadFromArray([]); $this->assertEquals($c->getBasePath(), '/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'simplesaml/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'simplesaml/']); $this->assertEquals($c->getBasePath(), '/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '/simplesaml/')); + $c = Configuration::loadFromArray(['baseurlpath' => '/simplesaml/']); $this->assertEquals($c->getBasePath(), '/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'simplesaml')); + $c = Configuration::loadFromArray(['baseurlpath' => 'simplesaml']); $this->assertEquals($c->getBasePath(), '/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '/simplesaml')); + $c = Configuration::loadFromArray(['baseurlpath' => '/simplesaml']); $this->assertEquals($c->getBasePath(), '/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'path/to/simplesaml/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'path/to/simplesaml/']); $this->assertEquals($c->getBasePath(), '/path/to/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '/path/to/simplesaml/')); + $c = Configuration::loadFromArray(['baseurlpath' => '/path/to/simplesaml/']); $this->assertEquals($c->getBasePath(), '/path/to/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '/path/to/simplesaml')); + $c = Configuration::loadFromArray(['baseurlpath' => '/path/to/simplesaml']); $this->assertEquals($c->getBasePath(), '/path/to/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'https://example.org/ssp/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'https://example.org/ssp/']); $this->assertEquals($c->getBasePath(), '/ssp/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'https://example.org/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'https://example.org/']); $this->assertEquals($c->getBasePath(), '/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'http://example.org/ssp/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'http://example.org/ssp/']); $this->assertEquals($c->getBasePath(), '/ssp/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'http://example.org/ssp/simplesaml')); + $c = Configuration::loadFromArray(['baseurlpath' => 'http://example.org/ssp/simplesaml']); $this->assertEquals($c->getBasePath(), '/ssp/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'http://example.org/ssp/simplesaml/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'http://example.org/ssp/simplesaml/']); $this->assertEquals($c->getBasePath(), '/ssp/simplesaml/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '')); + $c = Configuration::loadFromArray(['baseurlpath' => '']); $this->assertEquals($c->getBasePath(), '/'); - $c = Configuration::loadFromArray(array('baseurlpath' => '/')); + $c = Configuration::loadFromArray(['baseurlpath' => '/']); $this->assertEquals($c->getBasePath(), '/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'https://example.org:8443')); + $c = Configuration::loadFromArray(['baseurlpath' => 'https://example.org:8443']); $this->assertEquals($c->getBasePath(), '/'); - $c = Configuration::loadFromArray(array('baseurlpath' => 'https://example.org:8443/')); + $c = Configuration::loadFromArray(['baseurlpath' => 'https://example.org:8443/']); $this->assertEquals($c->getBasePath(), '/'); } @@ -215,9 +215,9 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase ]); $this->assertEquals($c->getBaseDir(), '/basedir/'); - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'basedir' => '/basedir/', - )); + ]); $this->assertEquals($c->getBaseDir(), '/basedir/'); } @@ -365,11 +365,11 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase * Test \SimpleSAML\Configuration::getValueValidate() */ public function testGetValueValidate() { - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'opt' => 'b', - )); - $this->assertEquals($c->getValueValidate('missing_opt', array('a', 'b', 'c'), '--missing--'), '--missing--'); - $this->assertEquals($c->getValueValidate('opt', array('a', 'b', 'c')), 'b'); + ]); + $this->assertEquals($c->getValueValidate('missing_opt', ['a', 'b', 'c'], '--missing--'), '--missing--'); + $this->assertEquals($c->getValueValidate('opt', ['a', 'b', 'c']), 'b'); } /** @@ -381,7 +381,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase $c = Configuration::loadFromArray([ 'opt' => 'd', ]); - $c->getValueValidate('opt', array('a', 'b', 'c')); + $c->getValueValidate('opt', ['a', 'b', 'c']); } /** @@ -390,10 +390,10 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetArray() { $c = Configuration::loadFromArray([ - 'opt' => array('a', 'b', 'c'), + 'opt' => ['a', 'b', 'c'], ]); $this->assertEquals($c->getArray('missing_opt', '--missing--'), '--missing--'); - $this->assertEquals($c->getArray('opt'), array('a', 'b', 'c')); + $this->assertEquals($c->getArray('opt'), ['a', 'b', 'c']); } /** @@ -414,14 +414,14 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetArrayize() { $c = Configuration::loadFromArray([ - 'opt' => array('a', 'b', 'c'), + 'opt' => ['a', 'b', 'c'], 'opt_int' => 42, 'opt_str' => 'string', ]); $this->assertEquals($c->getArrayize('missing_opt', '--missing--'), '--missing--'); - $this->assertEquals($c->getArrayize('opt'), array('a', 'b', 'c')); - $this->assertEquals($c->getArrayize('opt_int'), array(42)); - $this->assertEquals($c->getArrayize('opt_str'), array('string')); + $this->assertEquals($c->getArrayize('opt'), ['a', 'b', 'c']); + $this->assertEquals($c->getArrayize('opt_int'), [42]); + $this->assertEquals($c->getArrayize('opt_str'), ['string']); } /** @@ -430,12 +430,12 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetArrayizeString() { $c = Configuration::loadFromArray([ - 'opt' => array('a', 'b', 'c'), + 'opt' => ['a', 'b', 'c'], 'opt_str' => 'string', ]); $this->assertEquals($c->getArrayizeString('missing_opt', '--missing--'), '--missing--'); - $this->assertEquals($c->getArrayizeString('opt'), array('a', 'b', 'c')); - $this->assertEquals($c->getArrayizeString('opt_str'), array('string')); + $this->assertEquals($c->getArrayizeString('opt'), ['a', 'b', 'c']); + $this->assertEquals($c->getArrayizeString('opt_str'), ['string']); } /** @@ -445,7 +445,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetArrayizeStringWrongValue() { $c = Configuration::loadFromArray([ - 'opt' => array('a', 'b', 42), + 'opt' => ['a', 'b', 42], ]); $c->getArrayizeString('opt'); } @@ -456,7 +456,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetConfigItem() { $c = Configuration::loadFromArray([ - 'opt' => array('a' => 42), + 'opt' => ['a' => 42], ]); $this->assertEquals($c->getConfigItem('missing_opt', '--missing--'), '--missing--'); $opt = $c->getConfigItem('opt'); @@ -482,15 +482,15 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetConfigList() { $c = Configuration::loadFromArray([ - 'opts' => array( - 'a' => array('opt1' => 'value1'), - 'b' => array('opt2' => 'value2'), - ), + 'opts' => [ + 'a' => ['opt1' => 'value1'], + 'b' => ['opt2' => 'value2'], + ], ]); $this->assertEquals($c->getConfigList('missing_opt', '--missing--'), '--missing--'); $opts = $c->getConfigList('opts'); $this->assertInternalType('array', $opts); - $this->assertEquals(array_keys($opts), array('a', 'b')); + $this->assertEquals(array_keys($opts), ['a', 'b']); $this->assertInstanceOf('SimpleSAML\Configuration', $opts['a']); $this->assertEquals($opts['a']->getValue('opt1'), 'value1'); $this->assertInstanceOf('SimpleSAML\Configuration', $opts['b']); @@ -517,10 +517,10 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetConfigListWrongArrayValues() { $c = Configuration::loadFromArray([ - 'opts' => array( + 'opts' => [ 'a', 'b', - ), + ], ]); $c->getConfigList('opts'); } @@ -535,7 +535,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase 'a' => true, 'b' => null, ]); - $this->assertEquals($c->getOptions(), array('a', 'b')); + $this->assertEquals($c->getOptions(), ['a', 'b']); } /** @@ -547,7 +547,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase 'a' => true, 'b' => null, ]); - $this->assertEquals($c->toArray(), array('a' => true, 'b' => null)); + $this->assertEquals($c->toArray(), ['a' => true, 'b' => null]); } @@ -563,132 +563,132 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase * basically AssertionConsumerService and ArtifactResolutionService. Since both are the same, we just run the * tests for AssertionConsumerService. */ - $acs_eps = array( + $acs_eps = [ // just a string with the location 'https://example.com/endpoint.php', // an array of strings with location of different endpoints - array( + [ 'https://www1.example.com/endpoint.php', 'https://www2.example.com/endpoint.php', - ), + ], // define location and binding - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), - ), + ], + ], // define the ResponseLocation too - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, 'ResponseLocation' => 'https://example.com/endpoint.php', - ), - ), + ], + ], // make sure indexes are NOT taken into account (they just identify endpoints) - array( - array( + [ + [ 'index' => 1, 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, - ), - array( + ], + [ 'index' => 2, 'Location' => 'https://www2.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), - ), + ], + ], // make sure isDefault has priority over indexes - array( - array( + [ + [ 'index' => 1, 'Location' => 'https://www2.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), - array( + ], + [ 'index' => 2, 'isDefault' => true, 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, - ), - ), + ], + ], // make sure endpoints with invalid bindings are ignored and those marked as NOT default are still used - array( - array( + [ + [ 'index' => 1, 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => 'invalid_binding', - ), - array( + ], + [ 'index' => 2, 'isDefault' => false, 'Location' => 'https://www2.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), - ), - ); - $acs_expected_eps = array( + ], + ], + ]; + $acs_expected_eps = [ // output should be completed with the default binding (HTTP-POST for ACS) - array( + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), + ], // we should just get the first endpoint with the default binding - array( + [ 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ), + ], // if we specify the binding, we should get it back - array( + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST - ), + ], // if we specify ResponseLocation, we should get it back too - array( + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, 'ResponseLocation' => 'https://example.com/endpoint.php', - ), + ], // indexes must NOT be taken into account, order is the only thing that matters here - array( + [ 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'index' => 1, - ), + ], // isDefault must have higher priority than indexes - array( + [ 'Location' => 'https://www1.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'isDefault' => true, 'index' => 2, - ), + ], // the first valid enpoint should be used even if it's marked as NOT default - array( + [ 'index' => 2, 'isDefault' => false, 'Location' => 'https://www2.example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_POST, - ) - ); + ] + ]; - $a = array( + $a = [ 'metadata-set' => 'saml20-sp-remote', 'ArtifactResolutionService' => 'https://example.com/ars', 'SingleSignOnService' => 'https://example.com/sso', - 'SingleLogoutService' => array( + 'SingleLogoutService' => [ 'Location' => 'https://example.com/slo', 'Binding' => 'valid_binding', // test unknown bindings if we don't specify a list of valid ones - ), - ); + ], + ]; - $valid_bindings = array( + $valid_bindings = [ \SAML2\Constants::BINDING_HTTP_POST, \SAML2\Constants::BINDING_HTTP_REDIRECT, \SAML2\Constants::BINDING_HOK_SSO, \SAML2\Constants::BINDING_HTTP_ARTIFACT. \SAML2\Constants::BINDING_SOAP, - ); + ]; // run all general tests with AssertionConsumerService endpoint type foreach ($acs_eps as $i => $ep) { @@ -704,26 +704,26 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase $a['metadata-set'] = 'shib13-idp-remote'; $c = Configuration::loadFromArray($a); $this->assertEquals( - array( + [ 'Location' => 'https://example.com/sso', 'Binding' => 'urn:mace:shibboleth:1.0:profiles:AuthnRequest', - ), + ], $c->getDefaultEndpoint('SingleSignOnService') ); $a['metadata-set'] = 'saml20-idp-remote'; $c = Configuration::loadFromArray($a); $this->assertEquals( - array( + [ 'Location' => 'https://example.com/ars', 'Binding' => \SAML2\Constants::BINDING_SOAP, - ), + ], $c->getDefaultEndpoint('ArtifactResolutionService') ); $this->assertEquals( - array( + [ 'Location' => 'https://example.com/slo', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, - ), + ], $c->getDefaultEndpoint('SingleLogoutService') ); @@ -732,21 +732,21 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase $a['AssertionConsumerService'] = 'https://example.com/endpoint.php'; $c = Configuration::loadFromArray($a); $this->assertEquals( - array( + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post', - ), + ], $c->getDefaultEndpoint('AssertionConsumerService') ); // test for no valid endpoints specified - $a['SingleLogoutService'] = array( - array( + $a['SingleLogoutService'] = [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => 'invalid_binding', 'isDefault' => true, - ), - ); + ], + ]; $c = Configuration::loadFromArray($a); try { $c->getDefaultEndpoint('SingleLogoutService', $valid_bindings); @@ -774,81 +774,81 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetEndpoints() { // test response location for old-style configurations - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'metadata-set' => 'saml20-idp-remote', 'SingleSignOnService' => 'https://example.com/endpoint.php', 'SingleSignOnServiceResponse' => 'https://example.com/response.php', - )); - $e = array( - array( + ]); + $e = [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'ResponseLocation' => 'https://example.com/response.php', - ) - ); + ] + ]; $this->assertEquals($e, $c->getEndpoints('SingleSignOnService')); // test for input failures // define a basic configuration array - $a = array( + $a = [ 'metadata-set' => 'saml20-idp-remote', 'SingleSignOnService' => null, - ); + ]; // define a set of tests - $tests = array( + $tests = [ // invalid endpoint definition 10, // invalid definition of endpoint inside the endpoints array - array( + [ 1234 - ), + ], // missing location - array( - array( + [ + [ 'foo' => 'bar', - ), - ), + ], + ], // invalid location - array( - array( + [ + [ 'Location' => 1234, - ) - ), + ] + ], // missing binding - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', - ), - ), + ], + ], // invalid binding - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => 1234, - ), - ), + ], + ], // invalid response location - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'ResponseLocation' => 1234, - ), - ), + ], + ], // invalid index - array( - array( + [ + [ 'Location' => 'https://example.com/endpoint.php', 'Binding' => \SAML2\Constants::BINDING_HTTP_REDIRECT, 'index' => 'string', - ), - ), - ); + ], + ], + ]; // define a set of exception messages to expect - $msgs = array( + $msgs = [ 'Expected array or string.', 'Expected a string or an array.', 'Missing Location.', @@ -857,7 +857,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase 'Binding must be a string.', 'ResponseLocation must be a string.', 'index must be an integer.', - ); + ]; // now run all the tests expecting the correct exception message foreach ($tests as $i => $test) { @@ -879,14 +879,14 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase { $c = Configuration::loadFromArray([ 'str_opt' => 'Hello World!', - 'str_array' => array( + 'str_array' => [ 'en' => 'Hello World!', 'no' => 'Hei Verden!', - ), + ], ]); $this->assertEquals($c->getLocalizedString('missing_opt', '--missing--'), '--missing--'); - $this->assertEquals($c->getLocalizedString('str_opt'), array('en' => 'Hello World!')); - $this->assertEquals($c->getLocalizedString('str_array'), array('en' => 'Hello World!', 'no' => 'Hei Verden!')); + $this->assertEquals($c->getLocalizedString('str_opt'), ['en' => 'Hello World!']); + $this->assertEquals($c->getLocalizedString('str_array'), ['en' => 'Hello World!', 'no' => 'Hei Verden!']); } /** @@ -908,7 +908,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetLocalizedStringNotStringKey() { $c = Configuration::loadFromArray([ - 'opt' => array(42 => 'text'), + 'opt' => [42 => 'text'], ]); $c->getLocalizedString('opt'); } @@ -920,7 +920,7 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase public function testGetLocalizedStringNotStringValue() { $c = Configuration::loadFromArray([ - 'opt' => array('en' => 42), + 'opt' => ['en' => 42], ]); $c->getLocalizedString('opt'); } @@ -955,9 +955,9 @@ class Test_Configuration extends SimpleSAML\Test\Utils\ClearStateTestCase */ public function testLoadInstanceFromArray() { - $c = array( + $c = [ 'key' => 'value' - ); + ]; // test loading a custom instance Configuration::loadFromArray($c, '', 'dummy'); $this->assertEquals('value', Configuration::getInstance('dummy')->getValue('key', null)); diff --git a/tests/lib/SimpleSAML/DatabaseTest.php b/tests/lib/SimpleSAML/DatabaseTest.php index d15498221..82f292c4d 100644 --- a/tests/lib/SimpleSAML/DatabaseTest.php +++ b/tests/lib/SimpleSAML/DatabaseTest.php @@ -50,14 +50,14 @@ class DatabaseTest extends TestCase */ public function setUp() { - $config = array( + $config = [ 'database.dsn' => 'sqlite::memory:', 'database.username' => null, 'database.password' => null, 'database.prefix' => 'phpunit_', 'database.persistent' => true, - 'database.slaves' => array(), - ); + 'database.slaves' => [], + ]; $this->config = new \SimpleSAML\Configuration($config, "test/SimpleSAML/DatabaseTest.php"); @@ -82,14 +82,14 @@ class DatabaseTest extends TestCase */ public function connectionFailure() { - $config = array( + $config = [ 'database.dsn' => 'mysql:host=localhost;dbname=saml', 'database.username' => 'notauser', 'database.password' => 'notausersinvalidpassword', 'database.prefix' => 'phpunit_', 'database.persistent' => true, - 'database.slaves' => array(), - ); + 'database.slaves' => [], + ]; $this->config = new \SimpleSAML\Configuration($config, "test/SimpleSAML/DatabaseTest.php"); SimpleSAML\Database::getInstance($this->config); @@ -105,22 +105,22 @@ class DatabaseTest extends TestCase */ public function instances() { - $config = array( + $config = [ 'database.dsn' => 'sqlite::memory:', 'database.username' => null, 'database.password' => null, 'database.prefix' => 'phpunit_', 'database.persistent' => true, - 'database.slaves' => array(), - ); - $config2 = array( + 'database.slaves' => [], + ]; + $config2 = [ 'database.dsn' => 'sqlite::memory:', 'database.username' => null, 'database.password' => null, 'database.prefix' => 'phpunit2_', 'database.persistent' => true, - 'database.slaves' => array(), - ); + 'database.slaves' => [], + ]; $config1 = new \SimpleSAML\Configuration($config, "test/SimpleSAML/DatabaseTest.php"); $config2 = new \SimpleSAML\Configuration($config2, "test/SimpleSAML/DatabaseTest.php"); @@ -132,9 +132,9 @@ class DatabaseTest extends TestCase $generateInstanceId = self::getMethod('generateInstanceId'); - $instance1 = $generateInstanceId->invokeArgs($db1, array($config1)); - $instance2 = $generateInstanceId->invokeArgs($db2, array($config2)); - $instance3 = $generateInstanceId->invokeArgs($db3, array($config3)); + $instance1 = $generateInstanceId->invokeArgs($db1, [$config1]); + $instance2 = $generateInstanceId->invokeArgs($db2, [$config2]); + $instance3 = $generateInstanceId->invokeArgs($db3, [$config3]); // Assert that $instance1 and $instance2 have different instance ids $this->assertNotEquals( @@ -177,30 +177,30 @@ class DatabaseTest extends TestCase $getSlave = self::getMethod('getSlave'); $master = spl_object_hash(PHPUnit_Framework_Assert::readAttribute($this->db, 'dbMaster')); - $slave = spl_object_hash($getSlave->invokeArgs($this->db, array())); + $slave = spl_object_hash($getSlave->invokeArgs($this->db, [])); $this->assertTrue(($master == $slave), "getSlave should have returned the master database object"); - $config = array( + $config = [ 'database.dsn' => 'sqlite::memory:', 'database.username' => null, 'database.password' => null, 'database.prefix' => 'phpunit_', 'database.persistent' => true, - 'database.slaves' => array( - array( + 'database.slaves' => [ + [ 'dsn' => 'sqlite::memory:', 'username' => null, 'password' => null, - ), - ), - ); + ], + ], + ]; $sspConfiguration = new \SimpleSAML\Configuration($config, "test/SimpleSAML/DatabaseTest.php"); $msdb = \SimpleSAML\Database::getInstance($sspConfiguration); $slaves = PHPUnit_Framework_Assert::readAttribute($msdb, 'dbSlaves'); - $gotSlave = spl_object_hash($getSlave->invokeArgs($msdb, array())); + $gotSlave = spl_object_hash($getSlave->invokeArgs($msdb, [])); $this->assertEquals( spl_object_hash($slaves[0]), @@ -248,11 +248,11 @@ class DatabaseTest extends TestCase $ssp_value = md5(rand(0, 10000)); $stmt = $this->db->write( "INSERT INTO $table (ssp_key, ssp_value) VALUES (:ssp_key, :ssp_value)", - array('ssp_key' => array($ssp_key, PDO::PARAM_INT), 'ssp_value' => $ssp_value) + ['ssp_key' => [$ssp_key, PDO::PARAM_INT], 'ssp_value' => $ssp_value] ); $this->assertEquals(1, $stmt, "Could not insert data into $table."); - $query2 = $this->db->read("SELECT * FROM $table WHERE ssp_key = :ssp_key", array('ssp_key' => $ssp_key)); + $query2 = $this->db->read("SELECT * FROM $table WHERE ssp_key = :ssp_key", ['ssp_key' => $ssp_key]); $data = $query2->fetch(); $this->assertEquals($data['ssp_value'], $ssp_value, "Inserted data doesn't match what is in the database"); } diff --git a/tests/lib/SimpleSAML/Locale/LanguageTest.php b/tests/lib/SimpleSAML/Locale/LanguageTest.php index 09c53d760..708d6b60c 100644 --- a/tests/lib/SimpleSAML/Locale/LanguageTest.php +++ b/tests/lib/SimpleSAML/Locale/LanguageTest.php @@ -14,15 +14,15 @@ class LanguageTest extends TestCase public function testGetDefaultLanguage() { // test default - $c = Configuration::loadFromArray(array()); + $c = Configuration::loadFromArray([]); $l = new Language($c); $this->assertEquals('en', $l->getDefaultLanguage()); // test defaults coming from configuration - $c = Configuration::loadFromArray(array( - 'language.available' => array('en', 'es', 'nn'), + $c = Configuration::loadFromArray([ + 'language.available' => ['en', 'es', 'nn'], 'language.default' => 'es', - )); + ]); $l = new Language($c); $this->assertEquals('es', $l->getDefaultLanguage()); } @@ -34,19 +34,19 @@ class LanguageTest extends TestCase public function testGetLanguageCookie() { // test it works when no cookie is set - Configuration::loadFromArray(array(), '', 'simplesaml'); + Configuration::loadFromArray([], '', 'simplesaml'); $this->assertNull(Language::getLanguageCookie()); // test that it works fine with defaults - Configuration::loadFromArray(array(), '', 'simplesaml'); + Configuration::loadFromArray([], '', 'simplesaml'); $_COOKIE['language'] = 'en'; $this->assertEquals('en', Language::getLanguageCookie()); // test that it works with non-defaults - Configuration::loadFromArray(array( - 'language.available' => array('en', 'es', 'nn'), + Configuration::loadFromArray([ + 'language.available' => ['en', 'es', 'nn'], 'language.cookie.name' => 'xyz' - ), '', 'simplesaml'); + ], '', 'simplesaml'); $_COOKIE['xyz'] = 'Es'; // test values are converted to lowercase too $this->assertEquals('es', Language::getLanguageCookie()); } @@ -58,10 +58,10 @@ class LanguageTest extends TestCase public function testGetLanguageListNoConfig() { // test default - $c = Configuration::loadFromArray(array(), '', 'simplesaml'); + $c = Configuration::loadFromArray([], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('en'); - $this->assertEquals(array('en' => true), $l->getLanguageList()); + $this->assertEquals(['en' => true], $l->getLanguageList()); } @@ -71,16 +71,16 @@ class LanguageTest extends TestCase public function testGetLanguageListCorrectConfig() { // test langs from from language_names - $c = Configuration::loadFromArray(array( - 'language.available' => array('en', 'nn', 'es'), - ), '', 'simplesaml'); + $c = Configuration::loadFromArray([ + 'language.available' => ['en', 'nn', 'es'], + ], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('es'); - $this->assertEquals(array( + $this->assertEquals([ 'en' => false, 'es' => true, 'nn' => false, - ), $l->getLanguageList()); + ], $l->getLanguageList()); } @@ -90,12 +90,12 @@ class LanguageTest extends TestCase public function testGetLanguageListIncorrectConfig() { // test non-existent langs - $c = Configuration::loadFromArray(array( - 'language.available' => array('foo', 'bar'), - ), '', 'simplesaml'); + $c = Configuration::loadFromArray([ + 'language.available' => ['foo', 'bar'], + ], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('foo'); - $this->assertEquals(array('en' => true), $l->getLanguageList()); + $this->assertEquals(['en' => true], $l->getLanguageList()); } @@ -105,14 +105,14 @@ class LanguageTest extends TestCase public function testGetLanguageParameterName() { // test for default configuration - $c = Configuration::loadFromArray(array(), '', 'simplesaml'); + $c = Configuration::loadFromArray([], '', 'simplesaml'); $l = new Language($c); $this->assertEquals('language', $l->getLanguageParameterName()); // test for valid configuration - $c = Configuration::loadFromArray(array( + $c = Configuration::loadFromArray([ 'language.parameter.name' => 'xyz' - ), '', 'simplesaml'); + ], '', 'simplesaml'); $l = new Language($c); $this->assertEquals('xyz', $l->getLanguageParameterName()); } @@ -124,24 +124,24 @@ class LanguageTest extends TestCase public function testIsLanguageRTL() { // test defaults - $c = Configuration::loadFromArray(array(), '', 'simplesaml'); + $c = Configuration::loadFromArray([], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('en'); $this->assertFalse($l->isLanguageRTL()); // test non-defaults, non-RTL - $c = Configuration::loadFromArray(array( - 'language.rtl' => array('foo', 'bar'), - ), '', 'simplesaml'); + $c = Configuration::loadFromArray([ + 'language.rtl' => ['foo', 'bar'], + ], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('en'); $this->assertFalse($l->isLanguageRTL()); // test non-defaults, RTL - $c = Configuration::loadFromArray(array( - 'language.available' => array('en', 'nn', 'es'), - 'language.rtl' => array('nn', 'es'), - ), '', 'simplesaml'); + $c = Configuration::loadFromArray([ + 'language.available' => ['en', 'nn', 'es'], + 'language.rtl' => ['nn', 'es'], + ], '', 'simplesaml'); $l = new Language($c); $l->setLanguage('es'); $this->assertTrue($l->isLanguageRTL()); @@ -154,11 +154,11 @@ class LanguageTest extends TestCase public function testSetLanguage() { // test with valid configuration, no cookies set - $c = Configuration::loadFromArray(array( - 'language.available' => array('en', 'nn', 'es'), + $c = Configuration::loadFromArray([ + 'language.available' => ['en', 'nn', 'es'], 'language.parameter.name' => 'xyz', 'language.parameter.setcookie' => false, - ), '', 'simplesaml'); + ], '', 'simplesaml'); $_GET['xyz'] = 'Es'; // test also that lang code is transformed to lower caps $l = new Language($c); $this->assertEquals('es', $l->getLanguage()); diff --git a/tests/lib/SimpleSAML/Locale/LocalizationTest.php b/tests/lib/SimpleSAML/Locale/LocalizationTest.php index c45eb0974..0d67caa0e 100644 --- a/tests/lib/SimpleSAML/Locale/LocalizationTest.php +++ b/tests/lib/SimpleSAML/Locale/LocalizationTest.php @@ -11,7 +11,7 @@ class LocalizationTest extends TestCase protected function setUp() { // Localization/Language code attempts to load a cookie, and looks in the config for a name of the cookie - Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); } @@ -22,7 +22,7 @@ class LocalizationTest extends TestCase { // The constructor should activate the default domain $c = Configuration::loadFromArray( - array('language.i18n.backend' => 'SimpleSAMLphp') + ['language.i18n.backend' => 'SimpleSAMLphp'] ); $l = new Localization($c); $this->assertTrue($l->isI18NBackendDefault()); @@ -35,7 +35,7 @@ class LocalizationTest extends TestCase public function testAddDomain() { $c = Configuration::loadFromArray( - array('language.i18n.backend' => 'gettext/gettext') + ['language.i18n.backend' => 'gettext/gettext'] ); $l = new Localization($c); $newDomain = 'test'; diff --git a/tests/lib/SimpleSAML/Locale/TranslateTest.php b/tests/lib/SimpleSAML/Locale/TranslateTest.php index 48d92377d..b1266df42 100644 --- a/tests/lib/SimpleSAML/Locale/TranslateTest.php +++ b/tests/lib/SimpleSAML/Locale/TranslateTest.php @@ -14,7 +14,7 @@ class TranslateTest extends TestCase public function testNoop() { // test default - $c = \SimpleSAML\Configuration::loadFromArray(array()); + $c = \SimpleSAML\Configuration::loadFromArray([]); $t = new Translate($c); $testString = 'Blablabla'; $this->assertEquals($testString, $t->noop($testString)); @@ -25,7 +25,7 @@ class TranslateTest extends TestCase */ public function testTFallback() { - $c = \SimpleSAML\Configuration::loadFromArray(array()); + $c = \SimpleSAML\Configuration::loadFromArray([]); $t = new Translate($c); $testString = 'Blablabla'; @@ -34,6 +34,6 @@ class TranslateTest extends TestCase $this->assertEquals($result, $t->t($testString)); // $fallbackdefault = false, should be a noop - $this->assertEquals($testString, $t->t($testString, array(), false)); + $this->assertEquals($testString, $t->t($testString, [], false)); } } diff --git a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php index 1a57bbab0..c06cb5467 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php @@ -18,17 +18,17 @@ class SAMLBuilderTest extends TestCase // test SP20 array parsing, no friendly name $set = 'saml20-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', 'urn:oid:0.9.2342.19200300.100.1.3', 'urn:oid:2.5.4.3', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -47,17 +47,17 @@ class SAMLBuilderTest extends TestCase // test SP20 array parsing, no friendly name $set = 'saml20-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', 'eduPersonOrgDN' => 'urn:oid:0.9.2342.19200300.100.1.3', 'cn' => 'urn:oid:2.5.4.3', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -78,17 +78,17 @@ class SAMLBuilderTest extends TestCase // test SP13 array parsing, no friendly name $set = 'shib13-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', 'urn:oid:0.9.2342.19200300.100.1.3', 'urn:oid:2.5.4.3', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -107,17 +107,17 @@ class SAMLBuilderTest extends TestCase // test SP20 array parsing, no friendly name $set = 'shib13-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', 'eduPersonOrgDN' => 'urn:oid:0.9.2342.19200300.100.1.3', 'cn' => 'urn:oid:2.5.4.3', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -145,15 +145,15 @@ class SAMLBuilderTest extends TestCase $entityId = 'https://entity.example.com/id'; $set = 'saml20-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -192,15 +192,15 @@ class SAMLBuilderTest extends TestCase $entityId = 'https://entity.example.com/id'; $set = 'saml20-sp-remote'; - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test SP'), + 'name' => ['en' => 'Test SP'], 'metadata-set' => $set, - 'attributes' => array( + 'attributes' => [ 'eduPersonTargetedID' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.10', 'eduPersonPrincipalName' => 'urn:oid:1.3.6.1.4.1.5923.1.1.1.6', - ), - ); + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -232,19 +232,19 @@ class SAMLBuilderTest extends TestCase $set = 'attributeauthority-remote'; // without protocolSupportEnumeration fallback to default: urn:oasis:names:tc:SAML:2.0:protocol - $metadata = array( + $metadata = [ 'entityid' => $entityId, - 'name' => array('en' => 'Test AA'), + 'name' => ['en' => 'Test AA'], 'metadata-set' => $set, 'AttributeService' => - array ( + [ 0 => - array ( + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:SOAP', 'Location' => 'https://entity.example.com:8443/idp/profile/SAML2/SOAP/AttributeQuery', - ), - ), - ); + ], + ], + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); @@ -257,10 +257,10 @@ class SAMLBuilderTest extends TestCase // explicit protocols $metadata['protocols'] = - array( + [ 0 => 'urn:oasis:names:tc:SAML:1.1:protocol', 1 => 'urn:oasis:names:tc:SAML:2.0:protocol', - ); + ]; $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $entityDescriptorXml = $samlBuilder->getEntityDescriptorText(); diff --git a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php index 0a8254598..cfed7b198 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLParserTest.php @@ -15,9 +15,9 @@ class SAMLParserTest extends TestCase */ public function testRegistrationInfo() { - $expected = array( + $expected = [ 'registrationAuthority' => 'https://incommon.org', - ); + ]; $document = \SAML2\DOMDocumentFactory::fromString( <<<XML @@ -47,9 +47,9 @@ XML */ public function testRegistrationInfoInheritance() { - $expected = array( + $expected = [ 'registrationAuthority' => 'https://incommon.org', - ); + ]; $document = \SAML2\DOMDocumentFactory::fromString( <<<XML @@ -125,8 +125,8 @@ XML $this->assertEquals("Example service", $metadata['name']['en']); $this->assertEquals("Dit is een voorbeeld voor de unittest.", $metadata['description']['nl']); - $expected_a = array("urn:mace:dir:attribute-def:eduPersonPrincipalName", "urn:mace:dir:attribute-def:mail", "urn:mace:dir:attribute-def:displayName"); - $expected_r = array("urn:mace:dir:attribute-def:eduPersonPrincipalName"); + $expected_a = ["urn:mace:dir:attribute-def:eduPersonPrincipalName", "urn:mace:dir:attribute-def:mail", "urn:mace:dir:attribute-def:displayName"]; + $expected_r = ["urn:mace:dir:attribute-def:eduPersonPrincipalName"]; $this->assertEquals($expected_a, $metadata['attributes']); $this->assertEquals($expected_r, $metadata['attributes.required']); diff --git a/tests/lib/SimpleSAML/ModuleTest.php b/tests/lib/SimpleSAML/ModuleTest.php index b706a4370..a0c72b5f5 100644 --- a/tests/lib/SimpleSAML/ModuleTest.php +++ b/tests/lib/SimpleSAML/ModuleTest.php @@ -35,19 +35,19 @@ class ModuleTest extends TestCase */ public function testGetModuleURL() { - \SimpleSAML\Configuration::loadFromArray(array( + \SimpleSAML\Configuration::loadFromArray([ 'baseurlpath' => 'https://example.com/simplesaml/' - ), '', 'simplesaml'); + ], '', 'simplesaml'); $this->assertEquals( 'https://example.com/simplesaml/module.php/module/script.php', Module::getModuleURL('module/script.php') ); $this->assertEquals( 'https://example.com/simplesaml/module.php/module/script.php?param1=value1¶m2=value2', - Module::getModuleURL('module/script.php', array( + Module::getModuleURL('module/script.php', [ 'param1' => 'value1', 'param2' => 'value2', - )) + ]) ); } diff --git a/tests/lib/SimpleSAML/Store/RedisTest.php b/tests/lib/SimpleSAML/Store/RedisTest.php index fbe770522..7774a5dd2 100644 --- a/tests/lib/SimpleSAML/Store/RedisTest.php +++ b/tests/lib/SimpleSAML/Store/RedisTest.php @@ -18,24 +18,24 @@ class RedisTest extends TestCase { protected function setUp() { - $this->config = array(); + $this->config = []; $this->mocked_redis = $this->getMockBuilder('Predis\Client') - ->setMethods(array('get', 'set', 'setex', 'del', 'disconnect')) + ->setMethods(['get', 'set', 'setex', 'del', 'disconnect']) ->disableOriginalConstructor() ->getMock(); $this->mocked_redis->method('get') - ->will($this->returnCallback(array($this, 'getMocked'))); + ->will($this->returnCallback([$this, 'getMocked'])); $this->mocked_redis->method('set') - ->will($this->returnCallback(array($this, 'setMocked'))); + ->will($this->returnCallback([$this, 'setMocked'])); $this->mocked_redis->method('setex') - ->will($this->returnCallback(array($this, 'setexMocked'))); + ->will($this->returnCallback([$this, 'setexMocked'])); $this->mocked_redis->method('del') - ->will($this->returnCallback(array($this, 'delMocked'))); + ->will($this->returnCallback([$this, 'delMocked'])); $nop = function () { return; @@ -75,10 +75,10 @@ class RedisTest extends TestCase */ public function testRedisInstance() { - $config = Configuration::loadFromArray(array( + $config = Configuration::loadFromArray([ 'store.type' => 'redis', 'store.redis.prefix' => 'phpunit_', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); diff --git a/tests/lib/SimpleSAML/Store/SQLTest.php b/tests/lib/SimpleSAML/Store/SQLTest.php index 1321726d3..cda9dc290 100644 --- a/tests/lib/SimpleSAML/Store/SQLTest.php +++ b/tests/lib/SimpleSAML/Store/SQLTest.php @@ -19,11 +19,11 @@ class SQLTest extends TestCase { protected function setUp() { - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'store.type' => 'sql', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); } /** diff --git a/tests/lib/SimpleSAML/StoreTest.php b/tests/lib/SimpleSAML/StoreTest.php index 61f0fe823..ebaa1c5fb 100644 --- a/tests/lib/SimpleSAML/StoreTest.php +++ b/tests/lib/SimpleSAML/StoreTest.php @@ -23,8 +23,8 @@ class StoreTest extends TestCase */ public function defaultStore() { - Configuration::loadFromArray(array( - ), '[ARRAY]', 'simplesaml'); + Configuration::loadFromArray([ + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); @@ -38,8 +38,8 @@ class StoreTest extends TestCase */ public function phpSessionStore() { - Configuration::loadFromArray(array( - ), '[ARRAY]', 'simplesaml'); + Configuration::loadFromArray([ + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); @@ -53,9 +53,9 @@ class StoreTest extends TestCase */ public function memcacheStore() { - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'store.type' => 'memcache', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); @@ -69,11 +69,11 @@ class StoreTest extends TestCase */ public function sqlStore() { - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'store.type' => 'sql', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); @@ -87,11 +87,11 @@ class StoreTest extends TestCase */ public function pathStore() { - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'store.type' => '\SimpleSAML\Store\SQL', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $store = Store::getInstance(); @@ -106,11 +106,11 @@ class StoreTest extends TestCase */ public function notFoundStoreException() { - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'store.type' => '\Test\SimpleSAML\Store\Dummy', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); Store::getInstance(); } diff --git a/tests/lib/SimpleSAML/Utils/ArraysTest.php b/tests/lib/SimpleSAML/Utils/ArraysTest.php index 5bed975d1..eb3d1b668 100644 --- a/tests/lib/SimpleSAML/Utils/ArraysTest.php +++ b/tests/lib/SimpleSAML/Utils/ArraysTest.php @@ -16,23 +16,23 @@ class ArraysTest extends TestCase public function testArrayize() { // check with empty array as input - $array = array(); + $array = []; $this->assertEquals($array, Arrays::arrayize($array)); // check non-empty array as input - $array = array('key' => 'value'); + $array = ['key' => 'value']; $this->assertEquals($array, Arrays::arrayize($array)); // check indexes are ignored when input is an array $this->assertArrayNotHasKey('invalid', Arrays::arrayize($array, 'invalid')); // check default index - $expected = array('string'); + $expected = ['string']; $this->assertEquals($expected, Arrays::arrayize($expected[0])); // check string index $index = 'key'; - $expected = array($index => 'string'); + $expected = [$index => 'string']; $this->assertEquals($expected, Arrays::arrayize($expected[$index], $index)); } @@ -47,33 +47,33 @@ class ArraysTest extends TestCase // check bad arrays $this->assertFalse( - Arrays::transpose(array('1', '2', '3')), + Arrays::transpose(['1', '2', '3']), 'Invalid two-dimensional array was accepted' ); $this->assertFalse( - Arrays::transpose(array('1' => 0, '2' => '0', '3' => array(0))), + Arrays::transpose(['1' => 0, '2' => '0', '3' => [0]]), 'Invalid elements on a two-dimensional array were accepted' ); // check array with numerical keys - $array = array( - 'key1' => array( + $array = [ + 'key1' => [ 'value1' - ), - 'key2' => array( + ], + 'key2' => [ 'value1', 'value2' - ) - ); - $transposed = array( - array( + ] + ]; + $transposed = [ + [ 'key1' => 'value1', 'key2' => 'value1' - ), - array( + ], + [ 'key2' => 'value2' - ) - ); + ] + ]; $this->assertEquals( $transposed, Arrays::transpose($array), @@ -81,24 +81,24 @@ class ArraysTest extends TestCase ); // check array with string keys - $array = array( - 'key1' => array( + $array = [ + 'key1' => [ 'subkey1' => 'value1' - ), - 'key2' => array( + ], + 'key2' => [ 'subkey1' => 'value1', 'subkey2' => 'value2' - ) - ); - $transposed = array( - 'subkey1' => array( + ] + ]; + $transposed = [ + 'subkey1' => [ 'key1' => 'value1', 'key2' => 'value1' - ), - 'subkey2' => array( + ], + 'subkey2' => [ 'key2' => 'value2' - ) - ); + ] + ]; $this->assertEquals( $transposed, Arrays::transpose($array), @@ -106,26 +106,26 @@ class ArraysTest extends TestCase ); // check array with no keys in common between sub arrays - $array = array( - 'key1' => array( + $array = [ + 'key1' => [ 'subkey1' => 'value1' - ), - 'key2' => array( + ], + 'key2' => [ 'subkey2' => 'value1', 'subkey3' => 'value2' - ) - ); - $transposed = array( - 'subkey1' => array( + ] + ]; + $transposed = [ + 'subkey1' => [ 'key1' => 'value1', - ), - 'subkey2' => array( + ], + 'subkey2' => [ 'key2' => 'value1' - ), - 'subkey3' => array( + ], + 'subkey3' => [ 'key2' => 'value2' - ) - ); + ] + ]; $this->assertEquals( $transposed, Arrays::transpose($array), diff --git a/tests/lib/SimpleSAML/Utils/AttributesTest.php b/tests/lib/SimpleSAML/Utils/AttributesTest.php index 0c1c8dba5..42685215a 100644 --- a/tests/lib/SimpleSAML/Utils/AttributesTest.php +++ b/tests/lib/SimpleSAML/Utils/AttributesTest.php @@ -35,7 +35,7 @@ class AttributesTest extends TestCase public function testGetExpectedAttributeInvalidAttributeName() { // check with invalid attribute name - $attributes = array(); + $attributes = []; $expected = false; $this->setExpectedException( 'InvalidArgumentException', @@ -51,9 +51,9 @@ class AttributesTest extends TestCase public function testGetExpectedAttributeNonNormalizedArray() { // check with non-normalized attributes array - $attributes = array( + $attributes = [ 'attribute' => 'value', - ); + ]; $expected = 'attribute'; $this->setExpectedException( 'InvalidArgumentException', @@ -69,9 +69,9 @@ class AttributesTest extends TestCase public function testGetExpectedAttributeMissingAttribute() { // check missing attribute - $attributes = array( - 'attribute' => array('value'), - ); + $attributes = [ + 'attribute' => ['value'], + ]; $expected = 'missing'; $this->setExpectedException( '\SimpleSAML\Error\Exception', @@ -87,9 +87,9 @@ class AttributesTest extends TestCase public function testGetExpectedAttributeEmptyAttribute() { // check empty attribute - $attributes = array( - 'attribute' => array(), - ); + $attributes = [ + 'attribute' => [], + ]; $expected = 'attribute'; $this->setExpectedException( '\SimpleSAML\Error\Exception', @@ -105,12 +105,12 @@ class AttributesTest extends TestCase public function testGetExpectedAttributeMultipleValues() { // check attribute with more than value, that being not allowed - $attributes = array( - 'attribute' => array( + $attributes = [ + 'attribute' => [ 'value1', 'value2', - ), - ); + ], + ]; $expected = 'attribute'; $this->setExpectedException( '\SimpleSAML\Error\Exception', @@ -127,17 +127,17 @@ class AttributesTest extends TestCase { // check one value $value = 'value'; - $attributes = array( - 'attribute' => array($value), - ); + $attributes = [ + 'attribute' => [$value], + ]; $expected = 'attribute'; $this->assertEquals($value, Attributes::getExpectedAttribute($attributes, $expected)); // check multiple (allowed) values $value = 'value'; - $attributes = array( - 'attribute' => array($value, 'value2', 'value3'), - ); + $attributes = [ + 'attribute' => [$value, 'value2', 'value3'], + ]; $expected = 'attribute'; $this->assertEquals($value, Attributes::getExpectedAttribute($attributes, $expected, true)); } @@ -160,7 +160,7 @@ class AttributesTest extends TestCase */ public function testNormalizeAttributesArrayBadKeys() { - Attributes::normalizeAttributesArray(array('attr1' => 'value1', 1 => 'value2')); + Attributes::normalizeAttributesArray(['attr1' => 'value1', 1 => 'value2']); } /** @@ -170,7 +170,7 @@ class AttributesTest extends TestCase */ public function testNormalizeAttributesArrayBadValues() { - Attributes::normalizeAttributesArray(array('attr1' => 'value1', 'attr2' => 0)); + Attributes::normalizeAttributesArray(['attr1' => 'value1', 'attr2' => 0]); } /** @@ -178,16 +178,16 @@ class AttributesTest extends TestCase */ public function testNormalizeAttributesArray() { - $attributes = array( + $attributes = [ 'key1' => 'value1', - 'key2' => array('value2', 'value3'), + 'key2' => ['value2', 'value3'], 'key3' => 'value1' - ); - $expected = array( - 'key1' => array('value1'), - 'key2' => array('value2', 'value3'), - 'key3' => array('value1') - ); + ]; + $expected = [ + 'key1' => ['value1'], + 'key2' => ['value2', 'value3'], + 'key3' => ['value1'] + ]; $this->assertEquals( $expected, Attributes::normalizeAttributesArray($attributes), @@ -203,13 +203,13 @@ class AttributesTest extends TestCase { // test for only the name $this->assertEquals( - array('default', 'name'), + ['default', 'name'], Attributes::getAttributeNamespace('name', 'default') ); // test for a given namespace and multiple '/' $this->assertEquals( - array('some/namespace', 'name'), + ['some/namespace', 'name'], Attributes::getAttributeNamespace('some/namespace/name', 'default') ); } diff --git a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php index 98ffb7f0b..710020244 100644 --- a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php +++ b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php @@ -24,9 +24,9 @@ class MetadataTest extends TestCase } // test missing type - $contact = array( + $contact = [ 'name' => 'John Doe' - ); + ]; try { Metadata::getContact($contact); } catch (\InvalidArgumentException $e) { @@ -34,9 +34,9 @@ class MetadataTest extends TestCase } // test invalid type - $contact = array( + $contact = [ 'contactType' => 'invalid' - ); + ]; try { Metadata::getContact($contact); } catch (\InvalidArgumentException $e) { @@ -45,9 +45,9 @@ class MetadataTest extends TestCase // test all valid contact types foreach (Metadata::$VALID_CONTACT_TYPES as $type) { - $contact = array( + $contact = [ 'contactType' => $type - ); + ]; $parsed = Metadata::getContact($contact); $this->assertArrayHasKey('contactType', $parsed); $this->assertArrayNotHasKey('givenName', $parsed); @@ -55,10 +55,10 @@ class MetadataTest extends TestCase } // test basic name parsing - $contact = array( + $contact = [ 'contactType' => 'technical', 'name' => 'John Doe' - ); + ]; $parsed = Metadata::getContact($contact); $this->assertArrayNotHasKey('name', $parsed); $this->assertArrayHasKey('givenName', $parsed); @@ -67,10 +67,10 @@ class MetadataTest extends TestCase $this->assertEquals('Doe', $parsed['surName']); // test comma-separated names - $contact = array( + $contact = [ 'contactType' => 'technical', 'name' => 'Doe, John' - ); + ]; $parsed = Metadata::getContact($contact); $this->assertArrayHasKey('givenName', $parsed); $this->assertArrayHasKey('surName', $parsed); @@ -78,10 +78,10 @@ class MetadataTest extends TestCase $this->assertEquals('Doe', $parsed['surName']); // test long names - $contact = array( + $contact = [ 'contactType' => 'technical', 'name' => 'John Fitzgerald Doe Smith' - ); + ]; $parsed = Metadata::getContact($contact); $this->assertArrayNotHasKey('name', $parsed); $this->assertArrayHasKey('givenName', $parsed); @@ -89,10 +89,10 @@ class MetadataTest extends TestCase $this->assertEquals('John Fitzgerald Doe Smith', $parsed['givenName']); // test comma-separated long names - $contact = array( + $contact = [ 'contactType' => 'technical', 'name' => 'Doe Smith, John Fitzgerald' - ); + ]; $parsed = Metadata::getContact($contact); $this->assertArrayNotHasKey('name', $parsed); $this->assertArrayHasKey('givenName', $parsed); @@ -101,10 +101,10 @@ class MetadataTest extends TestCase $this->assertEquals('Doe Smith', $parsed['surName']); // test givenName - $contact = array( + $contact = [ 'contactType' => 'technical', - ); - $invalid_types = array(0, array(0), 0.1, true, false); + ]; + $invalid_types = [0, [0], 0.1, true, false]; foreach ($invalid_types as $type) { $contact['givenName'] = $type; try { @@ -115,10 +115,10 @@ class MetadataTest extends TestCase } // test surName - $contact = array( + $contact = [ 'contactType' => 'technical', - ); - $invalid_types = array(0, array(0), 0.1, true, false); + ]; + $invalid_types = [0, [0], 0.1, true, false]; foreach ($invalid_types as $type) { $contact['surName'] = $type; try { @@ -129,10 +129,10 @@ class MetadataTest extends TestCase } // test company - $contact = array( + $contact = [ 'contactType' => 'technical', - ); - $invalid_types = array(0, array(0), 0.1, true, false); + ]; + $invalid_types = [0, [0], 0.1, true, false]; foreach ($invalid_types as $type) { $contact['company'] = $type; try { @@ -143,10 +143,10 @@ class MetadataTest extends TestCase } // test emailAddress - $contact = array( + $contact = [ 'contactType' => 'technical', - ); - $invalid_types = array(0, 0.1, true, false, array()); + ]; + $invalid_types = [0, 0.1, true, false, []]; foreach ($invalid_types as $type) { $contact['emailAddress'] = $type; try { @@ -158,7 +158,7 @@ class MetadataTest extends TestCase ); } } - $invalid_types = array(array("string", true), array("string", 0)); + $invalid_types = [["string", true], ["string", 0]]; foreach ($invalid_types as $type) { $contact['emailAddress'] = $type; try { @@ -170,7 +170,7 @@ class MetadataTest extends TestCase ); } } - $valid_types = array('email@example.com', array('email1@example.com', 'email2@example.com')); + $valid_types = ['email@example.com', ['email1@example.com', 'email2@example.com']]; foreach ($valid_types as $type) { $contact['emailAddress'] = $type; $parsed = Metadata::getContact($contact); @@ -178,10 +178,10 @@ class MetadataTest extends TestCase } // test telephoneNumber - $contact = array( + $contact = [ 'contactType' => 'technical', - ); - $invalid_types = array(0, 0.1, true, false, array()); + ]; + $invalid_types = [0, 0.1, true, false, []]; foreach ($invalid_types as $type) { $contact['telephoneNumber'] = $type; try { @@ -193,7 +193,7 @@ class MetadataTest extends TestCase ); } } - $invalid_types = array(array("string", true), array("string", 0)); + $invalid_types = [["string", true], ["string", 0]]; foreach ($invalid_types as $type) { $contact['telephoneNumber'] = $type; try { @@ -202,7 +202,7 @@ class MetadataTest extends TestCase $this->assertEquals('Telephone numbers must be a string and cannot be empty.', $e->getMessage()); } } - $valid_types = array('1234', array('1234', '5678')); + $valid_types = ['1234', ['1234', '5678']]; foreach ($valid_types as $type) { $contact['telephoneNumber'] = $type; $parsed = Metadata::getContact($contact); @@ -210,13 +210,13 @@ class MetadataTest extends TestCase } // test completeness - $contact = array(); + $contact = []; foreach (Metadata::$VALID_CONTACT_OPTIONS as $option) { $contact[$option] = 'string'; } $contact['contactType'] = 'technical'; $contact['name'] = 'to_be_removed'; - $contact['attributes'] = array('test' => 'testval'); + $contact['attributes'] = ['test' => 'testval']; $parsed = Metadata::getContact($contact); foreach (array_keys($parsed) as $key) { $this->assertEquals($parsed[$key], $contact[$key]); @@ -231,32 +231,32 @@ class MetadataTest extends TestCase public function testIsHiddenFromDiscovery() { // test for success - $metadata = array( - 'EntityAttributes' => array( - Metadata::$ENTITY_CATEGORY => array( + $metadata = [ + 'EntityAttributes' => [ + Metadata::$ENTITY_CATEGORY => [ Metadata::$HIDE_FROM_DISCOVERY, - ), - ), - ); + ], + ], + ]; $this->assertTrue(Metadata::isHiddenFromDiscovery($metadata)); // test for failures - $this->assertFalse(Metadata::isHiddenFromDiscovery(array('foo'))); - $this->assertFalse(Metadata::isHiddenFromDiscovery(array( + $this->assertFalse(Metadata::isHiddenFromDiscovery(['foo'])); + $this->assertFalse(Metadata::isHiddenFromDiscovery([ 'EntityAttributes' => 'bar', - ))); - $this->assertFalse(Metadata::isHiddenFromDiscovery(array( - 'EntityAttributes' => array(), - ))); - $this->assertFalse(Metadata::isHiddenFromDiscovery(array( - 'EntityAttributes' => array( + ])); + $this->assertFalse(Metadata::isHiddenFromDiscovery([ + 'EntityAttributes' => [], + ])); + $this->assertFalse(Metadata::isHiddenFromDiscovery([ + 'EntityAttributes' => [ Metadata::$ENTITY_CATEGORY => '', - ), - ))); - $this->assertFalse(Metadata::isHiddenFromDiscovery(array( - 'EntityAttributes' => array( - Metadata::$ENTITY_CATEGORY => array(), - ), - ))); + ], + ])); + $this->assertFalse(Metadata::isHiddenFromDiscovery([ + 'EntityAttributes' => [ + Metadata::$ENTITY_CATEGORY => [], + ], + ])); } } diff --git a/tests/lib/SimpleSAML/Utils/CryptoTest.php b/tests/lib/SimpleSAML/Utils/CryptoTest.php index 0ef6513e3..db0080f56 100644 --- a/tests/lib/SimpleSAML/Utils/CryptoTest.php +++ b/tests/lib/SimpleSAML/Utils/CryptoTest.php @@ -21,9 +21,9 @@ class CryptoTest extends TestCase $this->root = vfsStream::setup( self::ROOTDIRNAME, null, - array( - self::DEFAULTCERTDIR => array(), - ) + [ + self::DEFAULTCERTDIR => [], + ] ); $this->root_directory = vfsStream::url(self::ROOTDIRNAME); $this->certdir = $this->root_directory.DIRECTORY_SEPARATOR.self::DEFAULTCERTDIR; @@ -41,7 +41,7 @@ class CryptoTest extends TestCase $m = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesDecrypt'); $m->setAccessible(true); - $m->invokeArgs(null, array(array(), 'SECRET')); + $m->invokeArgs(null, [[], 'SECRET']); } @@ -57,7 +57,7 @@ class CryptoTest extends TestCase $m = new \ReflectionMethod('\SimpleSAML\Utils\Crypto', '_aesEncrypt'); $m->setAccessible(true); - $m->invokeArgs(null, array(array(), 'SECRET')); + $m->invokeArgs(null, [[], 'SECRET']); } @@ -79,7 +79,7 @@ class CryptoTest extends TestCase $plaintext = 'SUPER_SECRET_TEXT'; $ciphertext = 'uR2Yu0r4itInKx91D/l9y/08L5CIQyev9nAr27fh3Sshous4vbXRRcMcjqHDOrquD+2vqLyw7ygnbA9jA9TpB4hLZocvAWcTN8tyO82hiSY='; - $this->assertEquals($plaintext, $m->invokeArgs(null, array(base64_decode($ciphertext), $secret))); + $this->assertEquals($plaintext, $m->invokeArgs(null, [base64_decode($ciphertext), $secret])); } @@ -102,8 +102,8 @@ class CryptoTest extends TestCase $d->setAccessible(true); $original_plaintext = 'SUPER_SECRET_TEXT'; - $ciphertext = $e->invokeArgs(null, array($original_plaintext, $secret)); - $decrypted_plaintext = $d->invokeArgs(null, array($ciphertext, $secret)); + $ciphertext = $e->invokeArgs(null, [$original_plaintext, $secret]); + $decrypted_plaintext = $d->invokeArgs(null, [$ciphertext, $secret]); $this->assertEquals($original_plaintext, $decrypted_plaintext); } @@ -276,7 +276,7 @@ PHP; */ public function testLoadPrivateKeyRequiredMetadataMissing() { - $config = new Configuration(array(), 'test'); + $config = new Configuration([], 'test'); $required = true; Crypto::loadPrivateKey($config, $required); @@ -287,7 +287,7 @@ PHP; */ public function testLoadPrivateKeyNotRequiredMetadataMissing() { - $config = new Configuration(array(), 'test'); + $config = new Configuration([], 'test'); $required = false; $res = Crypto::loadPrivateKey($config, $required); @@ -302,7 +302,7 @@ PHP; */ public function testLoadPrivateKeyMissingFile() { - $config = new Configuration(array('privatekey' => 'nonexistant'), 'test'); + $config = new Configuration(['privatekey' => 'nonexistant'], 'test'); Crypto::loadPrivateKey($config, false, '', true); } @@ -314,13 +314,13 @@ PHP; { $filename = $this->certdir.DIRECTORY_SEPARATOR.'key'; $data = 'data'; - $config = new Configuration(array('privatekey' => $filename), 'test'); + $config = new Configuration(['privatekey' => $filename], 'test'); $full_path = true; file_put_contents($filename, $data); $res = Crypto::loadPrivateKey($config, false, '', $full_path); - $expected = array('PEM' => $data); + $expected = ['PEM' => $data]; $this->assertEquals($expected, $res); } @@ -334,10 +334,10 @@ PHP; $filename = $this->certdir.DIRECTORY_SEPARATOR.'key'; $data = 'data'; $config = new Configuration( - array( + [ 'privatekey' => $filename, 'privatekey_pass' => $password, - ), + ], 'test' ); $full_path = true; @@ -345,7 +345,7 @@ PHP; file_put_contents($filename, $data); $res = Crypto::loadPrivateKey($config, false, '', $full_path); - $expected = array('PEM' => $data, 'password' => $password); + $expected = ['PEM' => $data, 'password' => $password]; $this->assertEquals($expected, $res); } @@ -360,10 +360,10 @@ PHP; $filename = $this->certdir.DIRECTORY_SEPARATOR.'key'; $data = 'data'; $config = new Configuration( - array( + [ $prefix.'privatekey' => $filename, $prefix.'privatekey_pass' => $password, - ), + ], 'test' ); $full_path = true; @@ -371,7 +371,7 @@ PHP; file_put_contents($filename, $data); $res = Crypto::loadPrivateKey($config, false, $prefix, $full_path); - $expected = array('PEM' => $data, 'password' => $password); + $expected = ['PEM' => $data, 'password' => $password]; $this->assertEquals($expected, $res); } @@ -383,7 +383,7 @@ PHP; */ public function testLoadPublicKeyRequiredMetadataMissing() { - $config = new Configuration(array(), 'test'); + $config = new Configuration([], 'test'); $required = true; Crypto::loadPublicKey($config, $required); @@ -394,7 +394,7 @@ PHP; */ public function testLoadPublicKeyNotRequiredMetadataMissing() { - $config = new Configuration(array(), 'test'); + $config = new Configuration([], 'test'); $required = false; $res = Crypto::loadPublicKey($config, $required); @@ -408,10 +408,10 @@ PHP; public function testLoadPublicKeyFingerprintBasicString() { $fingerprint = 'fingerprint'; - $config = new Configuration(array('certFingerprint' => $fingerprint), 'test'); + $config = new Configuration(['certFingerprint' => $fingerprint], 'test'); $res = Crypto::loadPublicKey($config); - $expected = array('certFingerprint' => array($fingerprint)); + $expected = ['certFingerprint' => [$fingerprint]]; $this->assertEquals($expected, $res); } @@ -424,17 +424,17 @@ PHP; $fingerprint1 = 'fingerprint1'; $fingerprint2 = 'fingerprint2'; $config = new Configuration( - array( - 'certFingerprint' => array( + [ + 'certFingerprint' => [ $fingerprint1, $fingerprint2 - ), - ), + ], + ], 'test' ); $res = Crypto::loadPublicKey($config); - $expected = array('certFingerprint' => array($fingerprint1, $fingerprint2)); + $expected = ['certFingerprint' => [$fingerprint1, $fingerprint2]]; $this->assertEquals($expected, $res); } @@ -445,10 +445,10 @@ PHP; public function testLoadPublicKeyFingerprintLowercase() { $fingerprint = 'FINGERPRINT'; - $config = new Configuration(array('certFingerprint' => $fingerprint), 'test'); + $config = new Configuration(['certFingerprint' => $fingerprint], 'test'); $res = Crypto::loadPublicKey($config); - $expected = array('certFingerprint' => array(strtolower($fingerprint))); + $expected = ['certFingerprint' => [strtolower($fingerprint)]]; $this->assertEquals($expected, $res); } @@ -459,10 +459,10 @@ PHP; public function testLoadPublicKeyFingerprintRemoveColons() { $fingerprint = 'f:i:n:g:e:r:p:r:i:n:t'; - $config = new Configuration(array('certFingerprint' => $fingerprint), 'test'); + $config = new Configuration(['certFingerprint' => $fingerprint], 'test'); $res = Crypto::loadPublicKey($config); - $expected = array('certFingerprint' => array(str_replace(':', '', $fingerprint))); + $expected = ['certFingerprint' => [str_replace(':', '', $fingerprint)]]; $this->assertEquals($expected, $res); } @@ -473,15 +473,15 @@ PHP; public function testLoadPublicKeyNotX509Certificate() { $config = new Configuration( - array( - 'keys' => array( - array( + [ + 'keys' => [ + [ 'X509Certificate' => '', 'type' => 'NotX509Certificate', 'signing' => true - ), - ), - ), + ], + ], + ], 'test' ); @@ -496,15 +496,15 @@ PHP; public function testLoadPublicKeyNotSigning() { $config = new Configuration( - array( - 'keys' => array( - array( + [ + 'keys' => [ + [ 'X509Certificate' => '', 'type' => 'X509Certificate', 'signing' => false - ), - ), - ), + ], + ], + ], 'test' ); @@ -520,15 +520,15 @@ PHP; { $x509certificate = 'x509certificate'; $config = new Configuration( - array( - 'keys' => array( - array( + [ + 'keys' => [ + [ 'X509Certificate' => $x509certificate, 'type' => 'X509Certificate', 'signing' => true - ), - ), - ), + ], + ], + ], 'test' ); diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php index 917a16290..986a813b1 100644 --- a/tests/lib/SimpleSAML/Utils/HTTPTest.php +++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php @@ -38,7 +38,7 @@ class HTTPTest extends TestCase */ public function testAddURLParametersInvalidURL() { - HTTP::addURLParameters(array(), array()); + HTTP::addURLParameters([], []); } /** @@ -57,23 +57,23 @@ class HTTPTest extends TestCase public function testAddURLParameters() { $url = 'http://example.com/'; - $params = array( + $params = [ 'foo' => 'bar', 'bar' => 'foo', - ); + ]; $this->assertEquals($url.'?foo=bar&bar=foo', HTTP::addURLParameters($url, $params)); $url = 'http://example.com/?'; - $params = array( + $params = [ 'foo' => 'bar', 'bar' => 'foo', - ); + ]; $this->assertEquals($url.'foo=bar&bar=foo', HTTP::addURLParameters($url, $params)); $url = 'http://example.com/?foo=bar'; - $params = array( + $params = [ 'bar' => 'foo', - ); + ]; $this->assertEquals($url.'&bar=foo', HTTP::addURLParameters($url, $params)); } @@ -126,9 +126,9 @@ class HTTPTest extends TestCase { $original = $_SERVER; - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => '', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $_SERVER['SERVER_PORT'] = '80'; $this->assertEquals('localhost', HTTP::getSelfHost()); $_SERVER['SERVER_PORT'] = '3030'; @@ -144,9 +144,9 @@ class HTTPTest extends TestCase { $original = $_SERVER; - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => '', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); // standard port for HTTP $_SERVER['SERVER_PORT'] = '80'; @@ -175,9 +175,9 @@ class HTTPTest extends TestCase * Test a URL pointing to a script that's not part of the public interface. This allows us to test calls to * getSelfURL() from scripts outside of SimpleSAMLphp */ - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => 'http://example.com/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $url = 'https://example.com/app/script.php/some/path?foo=bar'; $this->setupEnvFromURL($url); $_SERVER['SCRIPT_FILENAME'] = '/var/www/app/script.php'; @@ -188,9 +188,9 @@ class HTTPTest extends TestCase $this->assertEquals('https://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a request URI that doesn't match the current script - $cfg = Configuration::loadFromArray(array( + $cfg = Configuration::loadFromArray([ 'baseurlpath' => 'https://example.org/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $baseDir = $cfg->getBaseDir(); $_SERVER['SCRIPT_FILENAME'] = $baseDir.'www/module.php'; $this->setupEnvFromURL('http://www.example.com/protected/resource.asp?foo=bar'); @@ -202,9 +202,9 @@ class HTTPTest extends TestCase $this->assertEquals('http://www.example.com', HTTP::getSelfURLHost()); // test a valid, full URL, based on a full URL in the configuration - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => 'https://example.com/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->setupEnvFromURL('http://www.example.org/module.php/module/file.php?foo=bar'); $this->assertEquals( 'https://example.com/simplesaml/module.php/module/file.php?foo=bar', @@ -216,9 +216,9 @@ class HTTPTest extends TestCase $this->assertEquals('https://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a valid, full URL, based on a full URL *without* a trailing slash in the configuration - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => 'https://example.com/simplesaml', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->assertEquals( 'https://example.com/simplesaml/module.php/module/file.php?foo=bar', HTTP::getSelfURL() @@ -229,9 +229,9 @@ class HTTPTest extends TestCase $this->assertEquals('https://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a valid, full URL, based on a full URL *without* a path in the configuration - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => 'https://example.com', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->assertEquals( 'https://example.com/module.php/module/file.php?foo=bar', HTTP::getSelfURL() @@ -242,9 +242,9 @@ class HTTPTest extends TestCase $this->assertEquals('https://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a valid, full URL, based on a relative path in the configuration - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => '/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->setupEnvFromURL('http://www.example.org/simplesaml/module.php/module/file.php?foo=bar'); $this->assertEquals( 'http://www.example.org/simplesaml/module.php/module/file.php?foo=bar', @@ -256,9 +256,9 @@ class HTTPTest extends TestCase $this->assertEquals('http://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a valid, full URL, based on a relative path in the configuration and a non standard port - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => '/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->setupEnvFromURL('http://example.org:8080/simplesaml/module.php/module/file.php?foo=bar'); $this->assertEquals( 'http://example.org:8080/simplesaml/module.php/module/file.php?foo=bar', @@ -270,9 +270,9 @@ class HTTPTest extends TestCase $this->assertEquals('http://'.HTTP::getSelfHostWithNonStandardPort(), HTTP::getSelfURLHost()); // test a valid, full URL, based on a relative path in the configuration, a non standard port and HTTPS - Configuration::loadFromArray(array( + Configuration::loadFromArray([ 'baseurlpath' => '/simplesaml/', - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $this->setupEnvFromURL('https://example.org:8080/simplesaml/module.php/module/file.php?foo=bar'); $this->assertEquals( 'https://example.org:8080/simplesaml/module.php/module/file.php?foo=bar', @@ -296,19 +296,19 @@ class HTTPTest extends TestCase { $original = $_SERVER; - Configuration::loadFromArray(array( - 'trusted.url.domains' => array('sp.example.com', 'app.example.com'), + Configuration::loadFromArray([ + 'trusted.url.domains' => ['sp.example.com', 'app.example.com'], 'trusted.url.regex' => false, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $_SERVER['REQUEST_URI'] = '/module.php'; - $allowed = array( + $allowed = [ 'https://sp.example.com/', 'http://sp.example.com/', 'https://app.example.com/', 'http://app.example.com/', - ); + ]; foreach ($allowed as $url) { $this->assertEquals(HTTP::checkURLAllowed($url), $url); } @@ -326,21 +326,21 @@ class HTTPTest extends TestCase { $original = $_SERVER; - Configuration::loadFromArray(array( - 'trusted.url.domains' => array('.*\.example\.com'), + Configuration::loadFromArray([ + 'trusted.url.domains' => ['.*\.example\.com'], 'trusted.url.regex' => true, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $_SERVER['REQUEST_URI'] = '/module.php'; - $allowed = array( + $allowed = [ 'https://sp.example.com/', 'http://sp.example.com/', 'https://app1.example.com/', 'http://app1.example.com/', 'https://app2.example.com/', 'http://app2.example.com/', - ); + ]; foreach ($allowed as $url) { $this->assertEquals(HTTP::checkURLAllowed($url), $url); } @@ -403,10 +403,10 @@ class HTTPTest extends TestCase { $original = $_SERVER; - Configuration::loadFromArray(array( - 'trusted.url.domains' => array('app\.example\.com'), + Configuration::loadFromArray([ + 'trusted.url.domains' => ['app\.example\.com'], 'trusted.url.regex' => true, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); $_SERVER['REQUEST_URI'] = '/module.php'; diff --git a/tests/lib/SimpleSAML/Utils/SystemTest.php b/tests/lib/SimpleSAML/Utils/SystemTest.php index e177a31a2..7363c34f6 100644 --- a/tests/lib/SimpleSAML/Utils/SystemTest.php +++ b/tests/lib/SimpleSAML/Utils/SystemTest.php @@ -21,9 +21,9 @@ class SystemTest extends TestCase $this->root = vfsStream::setup( self::ROOTDIRNAME, null, - array( - self::DEFAULTTEMPDIR => array(), - ) + [ + self::DEFAULTTEMPDIR => [], + ] ); $this->root_directory = vfsStream::url(self::ROOTDIRNAME); } @@ -233,9 +233,9 @@ class SystemTest extends TestCase private function setConfigurationTempDir($directory) { - $config = Configuration::loadFromArray(array( + $config = Configuration::loadFromArray([ 'tempdir' => $directory, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); return $config; } diff --git a/tests/lib/SimpleSAML/Utils/TimeTest.php b/tests/lib/SimpleSAML/Utils/TimeTest.php index ebe99b9c8..6973a2180 100644 --- a/tests/lib/SimpleSAML/Utils/TimeTest.php +++ b/tests/lib/SimpleSAML/Utils/TimeTest.php @@ -36,7 +36,7 @@ class TimeTest extends TestCase } // test guessing timezone from the OS - \SimpleSAML\Configuration::loadFromArray(array('timezone' => null), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['timezone' => null], '[ARRAY]', 'simplesaml'); @Time::initTimezone(); $this->assertEquals($os, @date_default_timezone_get()); @@ -46,7 +46,7 @@ class TimeTest extends TestCase $c->setValue(false); // test unknown timezone - \SimpleSAML\Configuration::loadFromArray(array('timezone' => 'INVALID'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['timezone' => 'INVALID'], '[ARRAY]', 'simplesaml'); try { @Time::initTimezone(); $this->fail('Failed to recognize an invalid timezone.'); @@ -55,12 +55,12 @@ class TimeTest extends TestCase } // test a valid timezone - \SimpleSAML\Configuration::loadFromArray(array('timezone' => $tz), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['timezone' => $tz], '[ARRAY]', 'simplesaml'); @Time::initTimezone(); $this->assertEquals($tz, @date_default_timezone_get()); // make sure initialization happens only once - \SimpleSAML\Configuration::loadFromArray(array('timezone' => 'Europe/Madrid'), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray(['timezone' => 'Europe/Madrid'], '[ARRAY]', 'simplesaml'); @Time::initTimezone(); $this->assertEquals($tz, @date_default_timezone_get()); } @@ -143,7 +143,7 @@ class TimeTest extends TestCase } try { // invalid timestamp - Time::parseDuration('', array()); + Time::parseDuration('', []); $this->fail("Did not fail with invalid timestamp parameter."); } catch (\InvalidArgumentException $e) { $this->assertEquals('Invalid input parameters', $e->getMessage()); diff --git a/tests/lib/SimpleSAML/Utils/XMLTest.php b/tests/lib/SimpleSAML/Utils/XMLTest.php index 84a01ac3c..fe3694d13 100644 --- a/tests/lib/SimpleSAML/Utils/XMLTest.php +++ b/tests/lib/SimpleSAML/Utils/XMLTest.php @@ -168,7 +168,7 @@ class XMLTest extends TestCase $dom->appendChild($element); $res = XML::getDOMChildren($dom, $name, $namespace_uri); - $expected = array($element); + $expected = [$element]; $this->assertEquals($expected, $res); } @@ -357,12 +357,12 @@ NOWDOC; */ public function testIsValidMetadata() { - Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); $schema = 'saml-schema-metadata-2.0.xsd'; $dom = $this->getMockBuilder('\DOMDocument') - ->setMethods(array('schemaValidate')) + ->setMethods(['schemaValidate']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/lib/SimpleSAML/XML/ErrorsTest.php b/tests/lib/SimpleSAML/XML/ErrorsTest.php index a6a46f19d..5710650a2 100644 --- a/tests/lib/SimpleSAML/XML/ErrorsTest.php +++ b/tests/lib/SimpleSAML/XML/ErrorsTest.php @@ -51,7 +51,7 @@ class ErrorsTest extends TestCase $error->column = 'col'; $error->message = ' msg '; - $errors = Errors::formatErrors(array($error, $error)); + $errors = Errors::formatErrors([$error, $error]); $this->assertEquals( "level=level,code=code,line=line,col=col,msg=msg\nlevel=level,code=code,line=line,col=col,msg=msg\n", diff --git a/tests/lib/SimpleSAML/XML/ParserTest.php b/tests/lib/SimpleSAML/XML/ParserTest.php index 336ae86f1..acd2bd9c9 100644 --- a/tests/lib/SimpleSAML/XML/ParserTest.php +++ b/tests/lib/SimpleSAML/XML/ParserTest.php @@ -96,10 +96,10 @@ XML; { $result = $this ->xml - ->getValueAlternatives(array( + ->getValueAlternatives([ '/Root/Other', '/Root/Value' - ), true) + ], true) ; $this->assertEquals( @@ -117,10 +117,10 @@ XML; { $result = $this ->xml - ->getValueAlternatives(array( + ->getValueAlternatives([ '/Root/Foo', '/Root/Bar' - ), false) + ], false) ; $this->assertEquals( @@ -139,10 +139,10 @@ XML; { $this ->xml - ->getValueAlternatives(array( + ->getValueAlternatives([ '/Root/Foo', '/Root/Bar' - ), true) + ], true) ; } } diff --git a/tests/lib/SimpleSAML/XML/Shib13/AuthnResponseTest.php b/tests/lib/SimpleSAML/XML/Shib13/AuthnResponseTest.php index b492337f6..c2e266929 100644 --- a/tests/lib/SimpleSAML/XML/Shib13/AuthnResponseTest.php +++ b/tests/lib/SimpleSAML/XML/Shib13/AuthnResponseTest.php @@ -112,10 +112,10 @@ XML; $result = $this->xml->getNameID(); $this->assertEquals( - array( + [ 'Value' => 'NameIdentifier', 'Format' => 'urn:mace:shibboleth:1.0:nameIdentifier', - ), + ], $result ); } diff --git a/tests/lib/SimpleSAML/XML/SignerTest.php b/tests/lib/SimpleSAML/XML/SignerTest.php index 65b0f81cc..fda19f8f2 100644 --- a/tests/lib/SimpleSAML/XML/SignerTest.php +++ b/tests/lib/SimpleSAML/XML/SignerTest.php @@ -105,13 +105,13 @@ NOWDOC; $this->root = vfsStream::setup( self::ROOTDIRNAME, null, - array( - self::DEFAULTCERTDIR => array( + [ + self::DEFAULTCERTDIR => [ self::PRIVATEKEY => $this->private_key, self::CERTIFICATE1 => $this->certificate1, self::CERTIFICATE2 => $this->certificate2, - ), - ) + ], + ] ); $this->root_directory = vfsStream::url(self::ROOTDIRNAME); @@ -120,19 +120,19 @@ NOWDOC; $this->certificate_file1 = $this->certdir.DIRECTORY_SEPARATOR.self::CERTIFICATE1; $this->certificate_file2 = $this->certdir.DIRECTORY_SEPARATOR.self::CERTIFICATE2; - $this->config = Configuration::loadFromArray(array( + $this->config = Configuration::loadFromArray([ 'certdir' => $this->certdir, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); } public function tearDown() { - $this->clearInstance($this->config, '\SimpleSAML\Configuration', array()); + $this->clearInstance($this->config, '\SimpleSAML\Configuration', []); } public function testSignerBasic() { - $res = new Signer(array()); + $res = new Signer([]); $this->assertNotNull($res); } @@ -146,7 +146,7 @@ NOWDOC; $doc = new \DOMDocument(); $insertInto = $doc->appendChild(new \DOMElement('insert')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->privatekey_file, null, true); $signer->sign($element, $insertInto); @@ -158,11 +158,11 @@ NOWDOC; private static function getCertificateValue($certificate) { - $replacements = array( + $replacements = [ "-----BEGIN CERTIFICATE-----", "-----END CERTIFICATE-----", "\n", - ); + ]; return str_replace($replacements, "", $certificate); } @@ -176,7 +176,7 @@ NOWDOC; $doc = new \DOMDocument(); $insertInto = $doc->appendChild(new \DOMElement('insert')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->privatekey_file, null, true); $signer->loadCertificate($this->certificate_file1, true); $signer->sign($element, $insertInto); @@ -198,7 +198,7 @@ NOWDOC; $doc = new \DOMDocument(); $insertInto = $doc->appendChild(new \DOMElement('insert')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->privatekey_file, null, true); $signer->loadCertificate($this->certificate_file1, true); $signer->addCertificate($this->certificate_file2, true); @@ -223,7 +223,7 @@ NOWDOC; $doc = new \DOMDocument(); $insertInto = $doc->appendChild(new \DOMElement('insert')); - $signer = new Signer(array()); + $signer = new Signer([]); $this->setExpectedException('\Exception'); $signer->sign($element, $insertInto); diff --git a/tests/lib/SimpleSAML/XML/ValidatorTest.php b/tests/lib/SimpleSAML/XML/ValidatorTest.php index 788788612..bc8a197a6 100644 --- a/tests/lib/SimpleSAML/XML/ValidatorTest.php +++ b/tests/lib/SimpleSAML/XML/ValidatorTest.php @@ -147,14 +147,14 @@ NOWDOC; $this->root = vfsStream::setup( self::ROOTDIRNAME, null, - array( - self::DEFAULTCERTDIR => array( + [ + self::DEFAULTCERTDIR => [ self::CA_PRIVATE_KEY => $this->ca_private_key, self::CA_CERTIFICATE => $this->ca_certificate, self::GOOD_PRIVATE_KEY => $this->good_private_key, self::GOOD_CERTIFICATE => $this->good_certificate, - ), - ) + ], + ] ); $this->root_directory = vfsStream::url(self::ROOTDIRNAME); @@ -164,14 +164,14 @@ NOWDOC; $this->good_private_key_file = $this->certdir.DIRECTORY_SEPARATOR.self::GOOD_PRIVATE_KEY; $this->good_certificate_file = $this->certdir.DIRECTORY_SEPARATOR.self::GOOD_CERTIFICATE; - $this->config = Configuration::loadFromArray(array( + $this->config = Configuration::loadFromArray([ 'certdir' => $this->certdir, - ), '[ARRAY]', 'simplesaml'); + ], '[ARRAY]', 'simplesaml'); } public function tearDown() { - $this->clearInstance($this->config, '\SimpleSAML\Configuration', array()); + $this->clearInstance($this->config, '\SimpleSAML\Configuration', []); } public function testValidatorMissingSignature() @@ -192,7 +192,7 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->loadCertificate($this->good_certificate_file, true); $signer->sign($node, $signature_parent); @@ -216,7 +216,7 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->loadCertificate($this->good_certificate_file, true); $signer->sign($node, $signature_parent); @@ -228,7 +228,7 @@ NOWDOC; $validator = new Validator( $doc, 'node', - array('certFingerprint' => array($fingerprint)) + ['certFingerprint' => [$fingerprint]] ); // Avoiding Validator::class because it's >= PHP 5.5 only @@ -244,13 +244,13 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->loadCertificate($this->good_certificate_file, true); $signer->sign($node, $signature_parent); $this->setExpectedException('\Exception'); - new Validator($doc, 'node', array('certFingerprint' => array())); + new Validator($doc, 'node', ['certFingerprint' => []]); } public function testValidateFingerprintSuccess() @@ -262,7 +262,7 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->loadCertificate($this->good_certificate_file, true); $signer->sign($node, $signature_parent); @@ -287,7 +287,7 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->loadCertificate($this->good_certificate_file, true); $signer->sign($node, $signature_parent); @@ -309,14 +309,14 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->sign($node, $signature_parent); $validator = new Validator( $doc, 'node', - array('PEM' => $this->good_certificate) + ['PEM' => $this->good_certificate] ); $result = $validator->isNodeValidated($node); @@ -334,14 +334,14 @@ NOWDOC; $signature_parent = $doc->appendChild(new \DOMElement('signature_parent')); - $signer = new Signer(array()); + $signer = new Signer([]); $signer->loadPrivateKey($this->good_private_key_file, null, true); $signer->sign($node1, $signature_parent); $validator = new Validator( $doc, 'node1', - array('PEM' => $this->good_certificate) + ['PEM' => $this->good_certificate] ); $result = $validator->isNodeValidated($node2); diff --git a/tests/modules/consent/lib/Auth/Process/ConsentTest.php b/tests/modules/consent/lib/Auth/Process/ConsentTest.php index c74696d7c..d6b4e8b71 100644 --- a/tests/modules/consent/lib/Auth/Process/ConsentTest.php +++ b/tests/modules/consent/lib/Auth/Process/ConsentTest.php @@ -15,7 +15,7 @@ class ConsentTest extends TestCase { public function setUp() { - $this->config = Configuration::loadFromArray(array('module.enable' => array('consent' => true)), '[ARRAY]', 'simplesaml'); + $this->config = Configuration::loadFromArray(['module.enable' => ['consent' => true]], '[ARRAY]', 'simplesaml'); \SimpleSAML_Configuration::setPreLoadedConfig($this->config, 'config.php'); } @@ -40,82 +40,82 @@ class ConsentTest extends TestCase public function testCheckDisable() { // test consent disable regex with match - $config = array(); + $config = []; // test consent disable with match on specific SP entityid - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => 'https://idp.example.org', 'metadata-set' => 'saml20-idp-local', - 'consent.disable' => array( + 'consent.disable' => [ 'https://valid.flatstring.example.that.does.not.match', - ), - 'SingleSignOnService' => array( - array( + ], + 'SingleSignOnService' => [ + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'Location' => 'https://idp.example.org/saml2/idp/SSOService.php', - ), - ), - ), - 'Destination' => array( + ], + ], + ], + 'Destination' => [ // valid entityid equal to the last one in the consent.disable array 'entityid' => 'https://sp.example.org/my-sp', 'metadata-set' => 'saml20-sp-remote', - 'consent.disable' => array( - array('type' => 'regex', 'pattern' => '/invalid/i'), + 'consent.disable' => [ + ['type' => 'regex', 'pattern' => '/invalid/i'], 'https://sp.example.org/my-sp', // accept the SP that has this specific entityid 'https://idp.example.org', - ), - ), + ], + ], 'UserID' => 'jdoe', - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - ), - ); + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); // the state should NOT have changed because NO consent should be necessary (match) $this->assertEquals($request, $result); // test consent disable with match on SP through regular expression - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => 'https://idp.example.org', 'metadata-set' => 'saml20-idp-local', - 'consent.disable' => array( - array(), // invalid consent option array should be ignored + 'consent.disable' => [ + [], // invalid consent option array should be ignored 1234, // bad option - array(''), // no type - array('type'=>'invalid'), // invalid consent option type should be ignored - array('type'=>'regex'), // regex consent option without pattern should be ignored - array('type'=>'regex', 'pattern'=>'/.*\.valid.regex\.that\.does\.not\.match.*/i'), + [''], // no type + ['type'=>'invalid'], // invalid consent option type should be ignored + ['type'=>'regex'], // regex consent option without pattern should be ignored + ['type'=>'regex', 'pattern'=>'/.*\.valid.regex\.that\.does\.not\.match.*/i'], // accept any SP that has an entityid that contains the string ".example.org" - array('type'=>'regex', 'pattern'=>'/.*\.example\.org\/.*/i'), - ), - 'SingleSignOnService' => array( - array( + ['type'=>'regex', 'pattern'=>'/.*\.example\.org\/.*/i'], + ], + 'SingleSignOnService' => [ + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'Location' => 'https://idp.example.org/saml2/idp/SSOService.php', - ), - ), - ), - 'Destination' => array( + ], + ], + ], + 'Destination' => [ 'entityid' => 'https://sp.example.org/my-sp', // sp contains the string ".example.org" 'metadata-set' => 'saml20-sp-remote', - ), + ], 'UserID' => 'jdoe', - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - ), - ); + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); // the state should NOT have changed because NO consent should be necessary (match) $this->assertEquals($request, $result); // test corner cases - $request['Source']['consent.disable'] = array( + $request['Source']['consent.disable'] = [ 'https://valid.flatstring.example.that.does.not.match', - array('foo' => 'bar'), - ); + ['foo' => 'bar'], + ]; $request['Destination']['consent.disable'] = 1; $result = $this->processFilter($config, $request); // the state should NOT have changed because NO consent should be necessary (match) @@ -124,16 +124,16 @@ class ConsentTest extends TestCase public function testAttributeHashIsConsistentWhenOrderOfValuesChange() { - $attributes1 = array( - 'attribute1' => array('val1', 'val2'), - 'attribute2' => array('val1', 'val2') - ); + $attributes1 = [ + 'attribute1' => ['val1', 'val2'], + 'attribute2' => ['val1', 'val2'] + ]; $attributeHash1 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes1, true); - $attributes2 = array( - 'attribute1' => array('val1', 'val2'), - 'attribute2' => array('val2', 'val1') - ); + $attributes2 = [ + 'attribute1' => ['val1', 'val2'], + 'attribute2' => ['val2', 'val1'] + ]; $attributeHash2 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes2, true); $this->assertEquals($attributeHash1, $attributeHash2, "Hash is not the same when the order of values changes"); @@ -141,16 +141,16 @@ class ConsentTest extends TestCase public function testAttributeHashIsConsistentWhenOrderOfAttributesChange() { - $attributes1 = array( - 'attribute2' => array('val1', 'val2'), - 'attribute1' => array('val1', 'val2') - ); + $attributes1 = [ + 'attribute2' => ['val1', 'val2'], + 'attribute1' => ['val1', 'val2'] + ]; $attributeHash1 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes1, true); - $attributes2 = array( - 'attribute1' => array('val1', 'val2'), - 'attribute2' => array('val1', 'val2') - ); + $attributes2 = [ + 'attribute1' => ['val1', 'val2'], + 'attribute2' => ['val1', 'val2'] + ]; $attributeHash2 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes2, true); $this->assertEquals( @@ -162,16 +162,16 @@ class ConsentTest extends TestCase public function testAttributeHashIsConsistentWithoutValuesWhenOrderOfAttributesChange() { - $attributes1 = array( - 'attribute2' => array('val1', 'val2'), - 'attribute1' => array('val1', 'val2') - ); + $attributes1 = [ + 'attribute2' => ['val1', 'val2'], + 'attribute1' => ['val1', 'val2'] + ]; $attributeHash1 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes1); - $attributes2 = array( - 'attribute1' => array('val1', 'val2'), - 'attribute2' => array('val1', 'val2') - ); + $attributes2 = [ + 'attribute1' => ['val1', 'val2'], + 'attribute2' => ['val1', 'val2'] + ]; $attributeHash2 = \SimpleSAML\Module\consent\Auth\Process\Consent::getAttributeHash($attributes2); $this->assertEquals( @@ -185,22 +185,22 @@ class ConsentTest extends TestCase { $reflection = new \ReflectionClass('\SimpleSAML\Module\consent\Auth\Process\Consent'); - foreach (array( + foreach ([ 'includeValues', 'checked', 'focus', 'hiddenAttributes', 'noconsentattributes', 'showNoConsentAboutService' - ) as $v) { + ] as $v) { $instanceVars[$v] = $reflection->getProperty($v); $instanceVars[$v]->setAccessible(true); } /* these just need to be different to the default values */ - $config = array( + $config = [ 'includeValues' => true, 'checked' => true, 'focus' => 'yes', - 'hiddenAttributes' => array('attribute1', 'attribute2'), - 'attributes.exclude' => array('attribute1', 'attribute2'), + 'hiddenAttributes' => ['attribute1', 'attribute2'], + 'attributes.exclude' => ['attribute1', 'attribute2'], 'showNoConsentAboutService' => false, - ); + ]; $testcase = $reflection->newInstance($config, null); @@ -211,7 +211,7 @@ class ConsentTest extends TestCase $this->assertEquals($instanceVars['noconsentattributes']->getValue($testcase), $config['attributes.exclude']); $this->assertEquals($instanceVars['showNoConsentAboutService']->getValue($testcase), $config['showNoConsentAboutService']); - $deprecated = $reflection->newInstance(array('noconsentattributes' => $config['attributes.exclude'],), null); + $deprecated = $reflection->newInstance(['noconsentattributes' => $config['attributes.exclude'],], null); $this->assertEquals($instanceVars['noconsentattributes']->getValue($deprecated), $config['attributes.exclude']); } diff --git a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php index e98a7c28c..c84fbc95e 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAddTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAddTest.php @@ -27,16 +27,16 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testBasic() { - $config = array( - 'test' => array('value1', 'value2'), - ); - $request = array( - 'Attributes' => array(), - ); + $config = [ + 'test' => ['value1', 'value2'], + ]; + $request = [ + 'Attributes' => [], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); - $this->assertEquals($attributes['test'], array('value1', 'value2')); + $this->assertEquals($attributes['test'], ['value1', 'value2']); } /** @@ -44,23 +44,23 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testExistingNotModified() { - $config = array( - 'test' => array('value1', 'value2'), - ); - $request = array( - 'Attributes' => array( - 'original1' => array('original_value1'), - 'original2' => array('original_value2'), - ), - ); + $config = [ + 'test' => ['value1', 'value2'], + ]; + $request = [ + 'Attributes' => [ + 'original1' => ['original_value1'], + 'original2' => ['original_value2'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); - $this->assertEquals($attributes['test'], array('value1', 'value2')); + $this->assertEquals($attributes['test'], ['value1', 'value2']); $this->assertArrayHasKey('original1', $attributes); - $this->assertEquals($attributes['original1'], array('original_value1')); + $this->assertEquals($attributes['original1'], ['original_value1']); $this->assertArrayHasKey('original2', $attributes); - $this->assertEquals($attributes['original2'], array('original_value2')); + $this->assertEquals($attributes['original2'], ['original_value2']); } /** @@ -68,16 +68,16 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testStringValue() { - $config = array( + $config = [ 'test' => 'value', - ); - $request = array( - 'Attributes' => array(), - ); + ]; + $request = [ + 'Attributes' => [], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); - $this->assertEquals($attributes['test'], array('value')); + $this->assertEquals($attributes['test'], ['value']); } /** @@ -85,19 +85,19 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testAddMultiple() { - $config = array( - 'test1' => array('value1'), - 'test2' => array('value2'), - ); - $request = array( - 'Attributes' => array(), - ); + $config = [ + 'test1' => ['value1'], + 'test2' => ['value2'], + ]; + $request = [ + 'Attributes' => [], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test1', $attributes); - $this->assertEquals($attributes['test1'], array('value1')); + $this->assertEquals($attributes['test1'], ['value1']); $this->assertArrayHasKey('test2', $attributes); - $this->assertEquals($attributes['test2'], array('value2')); + $this->assertEquals($attributes['test2'], ['value2']); } /** @@ -105,17 +105,17 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testAppend() { - $config = array( - 'test' => array('value2'), - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + $config = [ + 'test' => ['value2'], + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['test'], array('value1', 'value2')); + $this->assertEquals($attributes['test'], ['value1', 'value2']); } /** @@ -123,18 +123,18 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testReplace() { - $config = array( + $config = [ '%replace', - 'test' => array('value2'), - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + 'test' => ['value2'], + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['test'], array('value2')); + $this->assertEquals($attributes['test'], ['value2']); } /** @@ -144,15 +144,15 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testWrongFlag() { - $config = array( + $config = [ '%nonsense', - 'test' => array('value2'), - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + 'test' => ['value2'], + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; self::processFilter($config, $request); } @@ -163,15 +163,15 @@ class Test_Core_Auth_Process_AttributeAdd extends TestCase */ public function testWrongAttributeValue() { - $config = array( + $config = [ '%replace', - 'test' => array(true), - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + 'test' => [true], + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php index fa292a690..454215470 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeAlterTest.php @@ -27,22 +27,22 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', 'replacement' => 'right', - ); + ]; - $request = array( - 'Attributes' => array( - 'test' => array('somethingiswrong'), - ), - ); + $request = [ + 'Attributes' => [ + 'test' => ['somethingiswrong'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); - $this->assertEquals($attributes['test'], array('somethingisright')); + $this->assertEquals($attributes['test'], ['somethingisright']); } /** @@ -50,25 +50,25 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testWithTarget() { - $config = array( + $config = [ 'subject' => 'test', 'target' => 'test2', 'pattern' => '/wrong/', 'replacement' => 'right', - ); + ]; - $request = array( - 'Attributes' => array( - 'something' => array('somethingelse'), - 'test' => array('wrong'), - ), - ); + $request = [ + 'Attributes' => [ + 'something' => ['somethingelse'], + 'test' => ['wrong'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test2', $attributes); - $this->assertEquals($attributes['test'], array('wrong')); - $this->assertEquals($attributes['test2'], array('right')); + $this->assertEquals($attributes['test'], ['wrong']); + $this->assertEquals($attributes['test2'], ['right']); } /** @@ -76,24 +76,24 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testNomatch() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', 'replacement' => 'right', - ); + ]; - $request = array( - 'Attributes' => array( - 'something' => array('somevalue'), - 'somethingelse' => array('someothervalue'), - ), - ); + $request = [ + 'Attributes' => [ + 'something' => ['somevalue'], + 'somethingelse' => ['someothervalue'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertEquals($attributes, - array('something' => array('somevalue'), - 'somethingelse' => array('someothervalue'))); + ['something' => ['somevalue'], + 'somethingelse' => ['someothervalue']]); } /** @@ -101,20 +101,20 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testReplaceMatch() { - $config = array( + $config = [ 'subject' => 'source', 'pattern' => '/wrong/', 'replacement' => 'right', '%replace', - ); - $request = array( - 'Attributes' => array( - 'source' => array('wrongthing'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'source' => ['wrongthing'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['source'], array('right')); + $this->assertEquals($attributes['source'], ['right']); } /** @@ -122,22 +122,22 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testReplaceMatchWithTarget() { - $config = array( + $config = [ 'subject' => 'source', 'pattern' => '/wrong/', 'replacement' => 'right', 'target' => 'test', '%replace', - ); - $request = array( - 'Attributes' => array( - 'source' => array('wrong'), - 'test' => array('wrong'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'source' => ['wrong'], + 'test' => ['wrong'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['test'], array('right')); + $this->assertEquals($attributes['test'], ['right']); } /** @@ -145,22 +145,22 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testReplaceNoMatch() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/doink/', 'replacement' => 'wrong', 'target' => 'test', '%replace', - ); - $request = array( - 'Attributes' => array( - 'source' => array('wrong'), - 'test' => array('right'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'source' => ['wrong'], + 'test' => ['right'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['test'], array('right')); + $this->assertEquals($attributes['test'], ['right']); } /** @@ -170,21 +170,21 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testRemoveMatch() { - $config = array( + $config = [ 'subject' => 'eduPersonAffiliation', 'pattern' => '/^emper/', '%remove', - ); - $request = array( - 'Attributes' => array( - 'displayName' => array('emperor kuzco'), - 'eduPersonAffiliation' => array('member', 'emperor', 'staff'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'displayName' => ['emperor kuzco'], + 'eduPersonAffiliation' => ['member', 'emperor', 'staff'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['displayName'], array('emperor kuzco')); - $this->assertEquals($attributes['eduPersonAffiliation'], array(0 => 'member', 2 => 'staff')); + $this->assertEquals($attributes['displayName'], ['emperor kuzco']); + $this->assertEquals($attributes['eduPersonAffiliation'], [0 => 'member', 2 => 'staff']); } /** @@ -192,17 +192,17 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testRemoveMatchAll() { - $config = array( + $config = [ 'subject' => 'eduPersonAffiliation', 'pattern' => '/^emper/', '%remove', - ); - $request = array( - 'Attributes' => array( - 'displayName' => array('emperor kuzco'), - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'displayName' => ['emperor kuzco'], + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('eduPersonAffiliation', $attributes); @@ -215,16 +215,16 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testWrongConfig() { - $config = array( + $config = [ 'subject' => 'eduPersonAffiliation', 'pattern' => '/^emper/', '%dwiw', - ); - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; self::processFilter($config, $request); } @@ -235,14 +235,14 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testIncompleteConfig() { - $config = array( + $config = [ 'subject' => 'eduPersonAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; self::processFilter($config, $request); } @@ -253,16 +253,16 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testIncompleteConfig2() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', - ); + ]; - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; self::processFilter($config, $request); } @@ -273,18 +273,18 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testIncompleteConfig3() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', '%replace', '%remove', - ); + ]; - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; self::processFilter($config, $request); } @@ -295,18 +295,18 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testIncompleteConfig4() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', 'target' => 'test2', '%remove', - ); + ]; - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; self::processFilter($config, $request); } @@ -318,17 +318,17 @@ class Test_Core_Auth_Process_AttributeAlter extends TestCase */ public function testIncompleteConfig5() { - $config = array( + $config = [ 'subject' => 'test', 'pattern' => '/wrong/', 'replacement' => null, - ); + ]; - $request = array( - 'Attributes' => array( - 'eduPersonAffiliation' => array('emperess', 'emperor'), - ), - ); - self::processFilter($config, $request); + $request = [ + 'Attributes' => [ + 'eduPersonAffiliation' => ['emperess', 'emperor'], + ], + ]; + $result = self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php index dc2b7637c..cedd94322 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeCopyTest.php @@ -27,17 +27,17 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'test' => 'testnew', - ); - $request = array( - 'Attributes' => array('test' => array('AAP')), - ); + ]; + $request = [ + 'Attributes' => ['test' => ['AAP']], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); $this->assertArrayHasKey('testnew', $attributes); - $this->assertEquals($attributes['testnew'], array('AAP')); + $this->assertEquals($attributes['testnew'], ['AAP']); } /** @@ -45,19 +45,19 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testArray() { - $config = array( - 'test' => array('new1','new2'), - ); - $request = array( - 'Attributes' => array('test' => array('AAP')), - ); + $config = [ + 'test' => ['new1','new2'], + ]; + $request = [ + 'Attributes' => ['test' => ['AAP']], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('test', $attributes); $this->assertArrayHasKey('new1', $attributes); $this->assertArrayHasKey('new2', $attributes); - $this->assertEquals($attributes['new1'], array('AAP')); - $this->assertEquals($attributes['new2'], array('AAP')); + $this->assertEquals($attributes['new1'], ['AAP']); + $this->assertEquals($attributes['new2'], ['AAP']); } /** @@ -65,24 +65,24 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testExistingNotModified() { - $config = array( + $config = [ 'test' => 'testnew', - ); - $request = array( - 'Attributes' => array( - 'test' => array('AAP'), - 'original1' => array('original_value1'), - 'original2' => array('original_value2'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'test' => ['AAP'], + 'original1' => ['original_value1'], + 'original2' => ['original_value2'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('testnew', $attributes); - $this->assertEquals($attributes['test'], array('AAP')); + $this->assertEquals($attributes['test'], ['AAP']); $this->assertArrayHasKey('original1', $attributes); - $this->assertEquals($attributes['original1'], array('original_value1')); + $this->assertEquals($attributes['original1'], ['original_value1']); $this->assertArrayHasKey('original2', $attributes); - $this->assertEquals($attributes['original2'], array('original_value2')); + $this->assertEquals($attributes['original2'], ['original_value2']); } /** @@ -90,19 +90,19 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testCopyMultiple() { - $config = array( + $config = [ 'test1' => 'new1', 'test2' => 'new2', - ); - $request = array( - 'Attributes' => array('test1' => array('val1'), 'test2' => array('val2.1','val2.2')), - ); + ]; + $request = [ + 'Attributes' => ['test1' => ['val1'], 'test2' => ['val2.1','val2.2']], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('new1', $attributes); - $this->assertEquals($attributes['new1'], array('val1')); + $this->assertEquals($attributes['new1'], ['val1']); $this->assertArrayHasKey('new2', $attributes); - $this->assertEquals($attributes['new2'], array('val2.1','val2.2')); + $this->assertEquals($attributes['new2'], ['val2.1','val2.2']); } /** @@ -110,18 +110,18 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testCopyClash() { - $config = array( + $config = [ 'test' => 'new1', - ); - $request = array( - 'Attributes' => array( - 'test' => array('testvalue1'), - 'new1' => array('newvalue1'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'test' => ['testvalue1'], + 'new1' => ['newvalue1'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['new1'], array('testvalue1')); + $this->assertEquals($attributes['new1'], ['testvalue1']); } /** @@ -131,14 +131,14 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testWrongAttributeName() { - $config = array( - array('value2'), - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + $config = [ + ['value2'], + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; self::processFilter($config, $request); } @@ -149,14 +149,14 @@ class Test_Core_Auth_Process_AttributeCopy extends TestCase */ public function testWrongAttributeValue() { - $config = array( + $config = [ 'test' => 100, - ); - $request = array( - 'Attributes' => array( - 'test' => array('value1'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'test' => ['value1'], + ], + ]; self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php index 0986313d2..9bc2260ce 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeLimitTest.php @@ -26,23 +26,23 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testIdPAttrs() { - $config = array( + $config = [ 'cn', 'mail' - ); - - $request = array( - 'Attributes' => array( - 'eduPersonTargetedID' => array('eptid@example.org'), - 'eduPersonAffiliation' => array('member'), - 'cn' => array('user name'), - 'mail' => array('user@example.org'), - ), - 'Destination' => array( - ), - 'Source' => array( - 'attributes' => array('cn','mail'), - ), - ); + ]; + + $request = [ + 'Attributes' => [ + 'eduPersonTargetedID' => ['eptid@example.org'], + 'eduPersonAffiliation' => ['member'], + 'cn' => ['user name'], + 'mail' => ['user@example.org'], + ], + 'Destination' => [ + ], + 'Source' => [ + 'attributes' => ['cn','mail'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; @@ -52,10 +52,10 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertArrayNotHasKey('eduPersonAffiliation', $attributes); $this->assertCount(2, $attributes); - $config = array( + $config = [ 'cn', 'default' => TRUE, - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; @@ -73,22 +73,22 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testNULLMetadataAttrs() { - $config = array( + $config = [ 'cn', 'mail' - ); - - $request = array( - 'Attributes' => array( - 'eduPersonTargetedID' => array('eptid@example.org'), - 'eduPersonAffiliation' => array('member'), - 'cn' => array('user name'), - 'mail' => array('user@example.org'), - ), - 'Destination' => array( - ), - 'Source' => array( - ), - ); + ]; + + $request = [ + 'Attributes' => [ + 'eduPersonTargetedID' => ['eptid@example.org'], + 'eduPersonAffiliation' => ['member'], + 'cn' => ['user name'], + 'mail' => ['user@example.org'], + ], + 'Destination' => [ + ], + 'Source' => [ + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; @@ -98,10 +98,10 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertArrayNotHasKey('eduPersonAffiliation', $attributes); $this->assertCount(2, $attributes); - $config = array( + $config = [ 'cn', 'default' => TRUE, - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; @@ -111,8 +111,8 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase $this->assertArrayNotHasKey('eduPersonAffiliation', $attributes); $this->assertCount(1, $attributes); - $config = array( - ); + $config = [ + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; @@ -131,19 +131,19 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public static function setUpBeforeClass() { - self::$request = array( - 'Attributes' => array( - 'eduPersonTargetedID' => array('eptid@example.org'), - 'eduPersonAffiliation' => array('member'), - 'cn' => array('common name'), - 'mail' => array('user@example.org'), - ), - 'Destination' => array( - 'attributes' => array('cn','mail'), - ), - 'Source' => array( - ), - ); + self::$request = [ + 'Attributes' => [ + 'eduPersonTargetedID' => ['eptid@example.org'], + 'eduPersonAffiliation' => ['member'], + 'cn' => ['common name'], + 'mail' => ['user@example.org'], + ], + 'Destination' => [ + 'attributes' => ['cn','mail'], + ], + 'Source' => [ + ], + ]; } /** @@ -151,9 +151,9 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'cn', 'mail' - ); + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; @@ -167,9 +167,9 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testDefaultWithMetadata() { - $config = array( + $config = [ 'default' => TRUE, - ); + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; @@ -183,10 +183,10 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testDefaultWithAttrs() { - $config = array( + $config = [ 'default' => TRUE, 'eduPersonTargetedID', 'eduPersonAffiliation', - ); + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; @@ -204,9 +204,9 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testInvalidConfig() { - $config = array( + $config = [ 'invalidArg' => TRUE, - ); + ]; self::processFilter($config, self::$request); } @@ -218,9 +218,9 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testInvalidAttributeName() { - $config = array( + $config = [ null - ); + ]; self::processFilter($config, self::$request); } @@ -231,36 +231,36 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testMatchAttributeValues() { - $config = array( - 'eduPersonAffiliation' => array('member') - ); + $config = [ + 'eduPersonAffiliation' => ['member'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); - $config = array( - 'eduPersonAffiliation' => array('member','staff') - ); + $config = [ + 'eduPersonAffiliation' => ['member','staff'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); - $config = array( - 'eduPersonAffiliation' => array('student') - ); + $config = [ + 'eduPersonAffiliation' => ['student'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); - $config = array( - 'eduPersonAffiliation' => array('student','staff') - ); + $config = [ + 'eduPersonAffiliation' => ['student','staff'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); @@ -269,10 +269,10 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testBadOptionsNotTreatedAsValidValues() { // Ensure really misconfigured ignoreCase and regex options are not interpretted as valid valus - $config = array( - 'eduPersonAffiliation' => array('ignoreCase' => 'member', 'nomatch'), - 'mail' => array('regex' => 'user@example.org', 'nomatch') - ); + $config = [ + 'eduPersonAffiliation' => ['ignoreCase' => 'member', 'nomatch'], + 'mail' => ['regex' => 'user@example.org', 'nomatch'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); @@ -283,16 +283,16 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase * php and matched against an attribute value of '1' */ public function testThatIgnoreCaseOptionNotMatchBooleanAsStringValue() { - $config = array( - 'someAttribute' => array('ignoreCase' => true, 'someValue') - ); + $config = [ + 'someAttribute' => ['ignoreCase' => true, 'someValue'] + ]; - $request = array( - 'Attributes' => array( - 'someAttribute' => array('1'), //boolean true as a string + $request = [ + 'Attributes' => [ + 'someAttribute' => ['1'], //boolean true as a string - ), - ); + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); @@ -303,36 +303,36 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testMatchAttributeValuesIgnoreCase() { - $config = array( - 'eduPersonAffiliation' => array('ignoreCase' => true, 'meMber') - ); + $config = [ + 'eduPersonAffiliation' => ['ignoreCase' => true, 'meMber'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); - $config = array( - 'eduPersonAffiliation' => array('ignoreCase' => true, 'membeR','sTaff') - ); + $config = [ + 'eduPersonAffiliation' => ['ignoreCase' => true, 'membeR','sTaff'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); - $config = array( - 'eduPersonAffiliation' => array('ignoreCase' => true, 'Student') - ); + $config = [ + 'eduPersonAffiliation' => ['ignoreCase' => true, 'Student'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); - $config = array( - 'eduPersonAffiliation' => array('ignoreCase' => true, 'studeNt','sTaff') - ); + $config = [ + 'eduPersonAffiliation' => ['ignoreCase' => true, 'studeNt','sTaff'] + ]; $result = self::processFilter($config, self::$request); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); @@ -344,93 +344,93 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase public function testMatchAttributeValuesRegex() { // SSP Logger requires a configuration to be set. - \SimpleSAML\Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); $state = self::$request; - $state['Attributes']['eduPersonEntitlement'] = array( + $state['Attributes']['eduPersonEntitlement'] = [ 'urn:mace:example.terena.org:tcs:personal-user', 'urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100', '1' //boolean true as a string - ); + ]; - $config = array( - 'eduPersonEntitlement' => array( + $config = [ + 'eduPersonEntitlement' => [ 'regex' => true, '/^urn:x-surfnet:surf/' - ) - ); + ] + ]; $result = self::processFilter($config, $state); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonEntitlement', $attributes); $this->assertEquals( - array('urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'), + ['urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'], $attributes['eduPersonEntitlement'] ); // Matching multiple lines shouldn't duplicate the attribute - $config = array( - 'eduPersonEntitlement' => array( + $config = [ + 'eduPersonEntitlement' => [ 'regex' => true, '/urn:x-surfnet:surf/', '/urn:x-surfnet/' - ) - ); + ] + ]; $result = self::processFilter($config, $state); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonEntitlement', $attributes); $this->assertEquals( - array('urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'), + ['urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'], $attributes['eduPersonEntitlement'] ); // Invalid and no-match regex expressions should not stop a valid regex from matching - $config = array( - 'eduPersonEntitlement' => array( + $config = [ + 'eduPersonEntitlement' => [ 'regex' => true, '/urn:mace:example.terena.org:tcs:no-match/', '$invalidRegex[', '/^URN:x-surf.*SURF.*n$/i' - ) - ); + ] + ]; $result = self::processFilter($config, $state); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonEntitlement', $attributes); $this->assertEquals( - array('urn:x-surfnet:surfdomeinen.nl:role:dnsadmin'), + ['urn:x-surfnet:surfdomeinen.nl:role:dnsadmin'], $attributes['eduPersonEntitlement'] ); // No matches should remove attribute - $config = array( - 'eduPersonEntitlement' => array( + $config = [ + 'eduPersonEntitlement' => [ 'regex' => true, '/urn:x-no-match/' - ) - ); + ] + ]; $result = self::processFilter($config, $state); $attributes = $result['Attributes']; $this->assertCount(0, $attributes); // A regex that matches an input value multiple times should work. - $config = array( - 'eduPersonEntitlement' => array( + $config = [ + 'eduPersonEntitlement' => [ 'regex' => true, '/surf/' - ) - ); + ] + ]; $result = self::processFilter($config, $state); $attributes = $result['Attributes']; $this->assertCount(1, $attributes); $this->assertArrayHasKey('eduPersonEntitlement', $attributes); $this->assertEquals( - array('urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'), + ['urn:x-surfnet:surfdomeinen.nl:role:dnsadmin', 'urn:x-surfnet:surf.nl:surfdrive:quota:100'], $attributes['eduPersonEntitlement'] ); } @@ -445,23 +445,23 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testMatchAttributeValuesNotArray() { - $config = array( - ); - - $request = array( - 'Attributes' => array( - 'eduPersonTargetedID' => array('eptid@example.org'), - 'eduPersonAffiliation' => array('member'), - 'cn' => array('user name'), - 'mail' => array('user@example.org'), - 'discardme' => array('somethingiswrong'), - ), - 'Destination' => array( - 'attributes' => array('eduPersonAffiliation' => 'student'), - ), - 'Source' => array( - ), - ); + $config = [ + ]; + + $request = [ + 'Attributes' => [ + 'eduPersonTargetedID' => ['eptid@example.org'], + 'eduPersonAffiliation' => ['member'], + 'cn' => ['user name'], + 'mail' => ['user@example.org'], + 'discardme' => ['somethingiswrong'], + ], + 'Destination' => [ + 'attributes' => ['eduPersonAffiliation' => 'student'], + ], + 'Source' => [ + ], + ]; self::processFilter($config, $request); @@ -472,24 +472,24 @@ class Test_Core_Auth_Process_AttributeLimitTest extends TestCase */ public function testNoIntersection() { - $config = array( + $config = [ 'default' => TRUE, - ); - - $request = array( - 'Attributes' => array( - 'eduPersonTargetedID' => array('eptid@example.org'), - 'eduPersonAffiliation' => array('member'), - 'cn' => array('user name'), - 'mail' => array('user@example.org'), - 'discardme' => array('somethingiswrong'), - ), - 'Destination' => array( - 'attributes' => array('urn:oid:1.2.840.113549.1.9.1'), - ), - 'Source' => array( - ), - ); + ]; + + $request = [ + 'Attributes' => [ + 'eduPersonTargetedID' => ['eptid@example.org'], + 'eduPersonAffiliation' => ['member'], + 'cn' => ['user name'], + 'mail' => ['user@example.org'], + 'discardme' => ['somethingiswrong'], + ], + 'Destination' => [ + 'attributes' => ['urn:oid:1.2.840.113549.1.9.1'], + ], + 'Source' => [ + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; diff --git a/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php b/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php index 62f1e8586..9821cf275 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeRealmTest.php @@ -27,16 +27,16 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testBasic() { - $config = array( - ); - $request = array( - 'Attributes' => array(), + $config = [ + ]; + $request = [ + 'Attributes' => [], 'UserID' => 'user2@example.org', - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('realm', $attributes); - $this->assertEquals($attributes['realm'], array('example.org')); + $this->assertEquals($attributes['realm'], ['example.org']); } /** @@ -46,11 +46,11 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testNoUserID() { - $config = array( - ); - $request = array( - 'Attributes' => array(), - ); + $config = [ + ]; + $request = [ + 'Attributes' => [], + ]; self::processFilter($config, $request); } @@ -59,21 +59,21 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testAttributeNameConfig() { - $config = array( + $config = [ 'attributename' => 'schacHomeOrganization', - ); - $request = array( - 'Attributes' => array( + ]; + $request = [ + 'Attributes' => [ 'displayName' => 'Joe User', 'schacGender' => 9, - ), + ], 'UserID' => 'user2@example.org', - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('schacHomeOrganization', $attributes); $this->assertArrayHasKey('displayName', $attributes); - $this->assertEquals($attributes['schacHomeOrganization'], array('example.org')); + $this->assertEquals($attributes['schacHomeOrganization'], ['example.org']); } /** @@ -81,21 +81,21 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testTargetAttributeOverwritten() { - $config = array( + $config = [ 'attributename' => 'schacHomeOrganization', - ); - $request = array( - 'Attributes' => array( + ]; + $request = [ + 'Attributes' => [ 'displayName' => 'Joe User', 'schacGender' => 9, 'schacHomeOrganization' => 'example.com', - ), + ], 'UserID' => 'user2@example.org', - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('schacHomeOrganization', $attributes); - $this->assertEquals($attributes['schacHomeOrganization'], array('example.org')); + $this->assertEquals($attributes['schacHomeOrganization'], ['example.org']); } /** @@ -103,13 +103,13 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testNoAtisNoOp() { - $config = array(); - $request = array( - 'Attributes' => array( + $config = []; + $request = [ + 'Attributes' => [ 'displayName' => 'Joe User', - ), + ], 'UserID' => 'user2', - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('realm', $attributes); @@ -120,13 +120,13 @@ class Test_Core_Auth_Process_AttributeRealm extends TestCase */ public function testMultiAtisNoOp() { - $config = array(); - $request = array( - 'Attributes' => array( + $config = []; + $request = [ + 'Attributes' => [ 'displayName' => 'Joe User', - ), + ], 'UserID' => 'user2@home@example.org', - ); + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('realm', $attributes); diff --git a/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php b/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php index a6d601f06..23904bd67 100644 --- a/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php +++ b/tests/modules/core/lib/Auth/Process/AttributeValueMapTest.php @@ -34,26 +34,26 @@ class AttributeValueMapTest extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'sourceattribute' => 'memberOf', 'targetattribute' => 'eduPersonAffiliation', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', 'otherGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('memberOf', $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); } @@ -65,27 +65,27 @@ class AttributeValueMapTest extends TestCase */ public function testNoDuplicates() { - $config = array( + $config = [ 'sourceattribute' => 'memberOf', 'targetattribute' => 'eduPersonAffiliation', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', 'otherGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup', 'otherGroup'), - 'eduPersonAffiliation' => array('member', 'someValue'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup', 'otherGroup'], + 'eduPersonAffiliation' => ['member', 'someValue'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('memberOf', $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member', 'someValue')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member', 'someValue']); } @@ -97,28 +97,28 @@ class AttributeValueMapTest extends TestCase */ public function testReplace() { - $config = array( + $config = [ 'sourceattribute' => 'memberOf', 'targetattribute' => 'eduPersonAffiliation', '%replace', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', 'otherGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - 'eduPersonAffiliation' => array('someValue'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + 'eduPersonAffiliation' => ['someValue'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayNotHasKey('memberOf', $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['member']); } @@ -130,28 +130,28 @@ class AttributeValueMapTest extends TestCase */ public function testKeep() { - $config = array( + $config = [ 'sourceattribute' => 'memberOf', 'targetattribute' => 'eduPersonAffiliation', '%keep', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', 'otherGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - 'eduPersonAffiliation' => array('someValue'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + 'eduPersonAffiliation' => ['someValue'], + ], + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('memberOf', $attributes); $this->assertArrayHasKey('eduPersonAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonAffiliation'], array('someValue','member')); + $this->assertEquals($attributes['eduPersonAffiliation'], ['someValue','member']); } @@ -163,21 +163,21 @@ class AttributeValueMapTest extends TestCase */ public function testUnknownFlag() { - $config = array( + $config = [ '%test', 'targetattribute' => 'affiliation', 'sourceattribute' => 'memberOf', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + ], + ]; $result = self::processFilter($config, $request); $this->assertArrayHasKey('affiliation', $result['Attributes']); $this->assertArrayNotHasKey('memberOf', $result['Attributes']); @@ -195,19 +195,19 @@ class AttributeValueMapTest extends TestCase */ public function testMissingSourceAttribute() { - $config = array( + $config = [ 'targetattribute' => 'affiliation', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + ], + ]; self::processFilter($config, $request); } @@ -222,19 +222,19 @@ class AttributeValueMapTest extends TestCase */ public function testMissingTargetAttribute() { - $config = array( + $config = [ 'sourceattribute' => 'memberOf', - 'values' => array( - 'member' => array( + 'values' => [ + 'member' => [ 'theGroup', - ), - ), - ); - $request = array( - 'Attributes' => array( - 'memberOf' => array('theGroup'), - ), - ); + ], + ], + ]; + $request = [ + 'Attributes' => [ + 'memberOf' => ['theGroup'], + ], + ]; self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php index 0c04b777b..ebf43b9c5 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalitySingleTest.php @@ -29,9 +29,9 @@ class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_Te protected function setUp() { - \SimpleSAML\Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); $this->http = $this->getMockBuilder('SimpleSAML\Utils\HTTPAdapter') - ->setMethods(array('redirectTrustedURL')) + ->setMethods(['redirectTrustedURL']) ->getMock(); } @@ -40,17 +40,17 @@ class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_Te */ public function testSingleValuedUnchanged() { - $config = array( - 'singleValued' => array('eduPersonPrincipalName') - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com'), - ), - ); + $config = [ + 'singleValued' => ['eduPersonPrincipalName'] + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('eduPersonPrincipalName' => array('joe@example.com')); + $expectedData = ['eduPersonPrincipalName' => ['joe@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -59,33 +59,33 @@ class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_Te */ public function testFirstValue() { - $config = array( - 'firstValue' => array('eduPersonPrincipalName') - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com', 'bob@example.net'), - ), - ); + $config = [ + 'firstValue' => ['eduPersonPrincipalName'] + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com', 'bob@example.net'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('eduPersonPrincipalName' => array('joe@example.com')); + $expectedData = ['eduPersonPrincipalName' => ['joe@example.com']]; $this->assertEquals($expectedData, $attributes, "Only first value should be returned"); } public function testFirstValueUnchanged() { - $config = array( - 'firstValue' => array('eduPersonPrincipalName') - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com'), - ), - ); + $config = [ + 'firstValue' => ['eduPersonPrincipalName'] + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('eduPersonPrincipalName' => array('joe@example.com')); + $expectedData = ['eduPersonPrincipalName' => ['joe@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -94,35 +94,35 @@ class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_Te */ public function testFlatten() { - $config = array( - 'flatten' => array('eduPersonPrincipalName'), + $config = [ + 'flatten' => ['eduPersonPrincipalName'], 'flattenWith' => '|', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com', 'bob@example.net'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com', 'bob@example.net'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('eduPersonPrincipalName' => array('joe@example.com|bob@example.net')); + $expectedData = ['eduPersonPrincipalName' => ['joe@example.com|bob@example.net']]; $this->assertEquals($expectedData, $attributes, "Flattened string should be returned"); } public function testFlattenUnchanged() { - $config = array( - 'flatten' => array('eduPersonPrincipalName'), + $config = [ + 'flatten' => ['eduPersonPrincipalName'], 'flattenWith' => '|', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com'), - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('eduPersonPrincipalName' => array('joe@example.com')); + $expectedData = ['eduPersonPrincipalName' => ['joe@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -131,14 +131,14 @@ class Test_Core_Auth_Process_CardinalitySingleTest extends \PHPUnit_Framework_Te */ public function testAbort() { - $config = array( - 'singleValued' => array('eduPersonPrincipalName'), - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('joe@example.com', 'bob@example.net'), - ), - ); + $config = [ + 'singleValued' => ['eduPersonPrincipalName'], + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['joe@example.com', 'bob@example.net'], + ], + ]; $this->http->expects($this->once()) ->method('redirectTrustedURL'); diff --git a/tests/modules/core/lib/Auth/Process/CardinalityTest.php b/tests/modules/core/lib/Auth/Process/CardinalityTest.php index 8d9475444..da6e2e30d 100644 --- a/tests/modules/core/lib/Auth/Process/CardinalityTest.php +++ b/tests/modules/core/lib/Auth/Process/CardinalityTest.php @@ -30,9 +30,9 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase protected function setUp() { - \SimpleSAML\Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + \SimpleSAML\Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); $this->http = $this->getMockBuilder('SimpleSAML\Utils\HTTPAdapter') - ->setMethods(array('redirectTrustedURL')) + ->setMethods(['redirectTrustedURL']) ->getMock(); } @@ -41,17 +41,17 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMinNoMax() { - $config = array( - 'mail' => array('min' => 1), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => 1], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('mail' => array('joe@example.com', 'bob@example.com')); + $expectedData = ['mail' => ['joe@example.com', 'bob@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -60,17 +60,17 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMaxNoMin() { - $config = array( - 'mail' => array('max' => 2), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['max' => 2], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('mail' => array('joe@example.com', 'bob@example.com')); + $expectedData = ['mail' => ['joe@example.com', 'bob@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -79,17 +79,17 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMaxMin() { - $config = array( - 'mail' => array('min' => 1, 'max' => 2), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => 1, 'max' => 2], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $attributes = $result['Attributes']; - $expectedData = array('mail' => array('joe@example.com', 'bob@example.com')); + $expectedData = ['mail' => ['joe@example.com', 'bob@example.com']]; $this->assertEquals($expectedData, $attributes, "Assertion values should not have changed"); } @@ -98,14 +98,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMaxOutOfBounds() { - $config = array( - 'mail' => array('max' => 2), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com', 'fred@example.com'), - ), - ); + $config = [ + 'mail' => ['max' => 2], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com', 'fred@example.com'], + ], + ]; $this->http->expects($this->once()) ->method('redirectTrustedURL'); @@ -118,14 +118,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMinOutOfBounds() { - $config = array( - 'mail' => array('min' => 3), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => 3], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $this->http->expects($this->once()) ->method('redirectTrustedURL'); @@ -138,12 +138,12 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMissingAttribute() { - $config = array( - 'mail' => array('min' => 1), - ); - $request = array( - 'Attributes' => array( ), - ); + $config = [ + 'mail' => ['min' => 1], + ]; + $request = [ + 'Attributes' => [], + ]; $this->http->expects($this->once()) ->method('redirectTrustedURL'); @@ -162,14 +162,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMinInvalid() { - $config = array( - 'mail' => array('min' => false), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => false], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $this->processFilter($config, $request); } @@ -180,14 +180,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMinNegative() { - $config = array( - 'mail' => array('min' => -1), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => -1], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $this->processFilter($config, $request); } @@ -198,14 +198,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMaxInvalid() { - $config = array( - 'mail' => array('max' => false), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['max' => false], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $this->processFilter($config, $request); } @@ -216,14 +216,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testMinGreaterThanMax() { - $config = array( - 'mail' => array('min' => 2, 'max' => 1), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + 'mail' => ['min' => 2, 'max' => 1], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; $this->processFilter($config, $request); } @@ -234,14 +234,14 @@ class Test_Core_Auth_Process_CardinalityTest extends \PHPUnit_Framework_TestCase */ public function testInvalidAttributeName() { - $config = array( - array('min' => 2, 'max' => 1), - ); - $request = array( - 'Attributes' => array( - 'mail' => array('joe@example.com', 'bob@example.com'), - ), - ); + $config = [ + ['min' => 2, 'max' => 1], + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['joe@example.com', 'bob@example.com'], + ], + ]; self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/Process/PHPTest.php b/tests/modules/core/lib/Auth/Process/PHPTest.php index e4af7e57c..67bf33b70 100644 --- a/tests/modules/core/lib/Auth/Process/PHPTest.php +++ b/tests/modules/core/lib/Auth/Process/PHPTest.php @@ -28,7 +28,7 @@ class Test_Core_Auth_Process_PHP extends TestCase */ public function testInvalidConfiguration() { - $config = array(); + $config = []; $this->setExpectedException( "\SimpleSAML\Error\Exception", "core:PHP: missing mandatory configuration option 'code'." @@ -42,17 +42,17 @@ class Test_Core_Auth_Process_PHP extends TestCase */ public function testCodeDefined() { - $config = array( + $config = [ 'code' => ' $attributes["key"] = array("value"); ', - ); - $request = array('Attributes' => array()); - $expected = array( - 'Attributes' => array( - 'key' => array('value'), - ), - ); + ]; + $request = ['Attributes' => []]; + $expected = [ + 'Attributes' => [ + 'key' => ['value'], + ], + ]; $this->assertEquals($expected, $this->processFilter($config, $request)); } @@ -62,25 +62,25 @@ class Test_Core_Auth_Process_PHP extends TestCase */ public function testPreserveIncomingAttributes() { - $config = array( + $config = [ 'code' => ' $attributes["orig2"] = array("value0"); ', - ); - $request = array( - 'Attributes' => array( - 'orig1' => array('value1', 'value2'), - 'orig2' => array('value3'), - 'orig3' => array('value4') - ) - ); - $expected = array( - 'Attributes' => array( - 'orig1' => array('value1', 'value2'), - 'orig2' => array('value0'), - 'orig3' => array('value4') - ), - ); + ]; + $request = [ + 'Attributes' => [ + 'orig1' => ['value1', 'value2'], + 'orig2' => ['value3'], + 'orig3' => ['value4'] + ] + ]; + $expected = [ + 'Attributes' => [ + 'orig1' => ['value1', 'value2'], + 'orig2' => ['value0'], + 'orig3' => ['value4'] + ], + ]; $this->assertEquals($expected, $this->processFilter($config, $request)); } @@ -91,19 +91,19 @@ class Test_Core_Auth_Process_PHP extends TestCase */ public function testThrowExceptionFromFilter() { - $config = array( + $config = [ 'code' => ' if (empty($attributes["uid"])) { throw new Exception("Missing uid attribute."); } $attributes["uid"][0] = strtoupper($attributes["uid"][0]); ', - ); - $request = array( - 'Attributes' => array( - 'orig1' => array('value1', 'value2'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'orig1' => ['value1', 'value2'], + ] + ]; $this->setExpectedException( "Exception", diff --git a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php index 843492678..6bc4d276f 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeAttributeTest.php @@ -27,21 +27,21 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - 'eduPersonAffiliation' => array('member'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + 'eduPersonAffiliation' => ['member'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('eduPersonScopedAffiliation', $attributes); - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('member@example.com')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['member@example.com']); } /* @@ -49,21 +49,21 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testNoOverwrite() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - 'eduPersonAffiliation' => array('member'), - 'eduPersonScopedAffiliation' => array('library-walk-in@example.edu'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + 'eduPersonAffiliation' => ['member'], + 'eduPersonScopedAffiliation' => ['library-walk-in@example.edu'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('library-walk-in@example.edu', 'member@example.com')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['library-walk-in@example.edu', 'member@example.com']); } /* @@ -71,21 +71,21 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testNoDuplication() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - 'eduPersonAffiliation' => array('member'), - 'eduPersonScopedAffiliation' => array('member@example.com'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + 'eduPersonAffiliation' => ['member'], + 'eduPersonScopedAffiliation' => ['member@example.com'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('member@example.com')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['member@example.com']); } @@ -94,18 +94,18 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testNoSourceAttribute() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'mail' => array('j.doe@example.edu', 'john@example.org'), - 'eduPersonAffiliation' => array('member'), - 'eduPersonScopedAffiliation' => array('library-walk-in@example.edu'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['j.doe@example.edu', 'john@example.org'], + 'eduPersonAffiliation' => ['member'], + 'eduPersonScopedAffiliation' => ['library-walk-in@example.edu'], + ] + ]; $result = self::processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); } @@ -115,18 +115,18 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testNoScopeAttribute() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'mail' => array('j.doe@example.edu', 'john@example.org'), - 'eduPersonScopedAffiliation' => array('library-walk-in@example.edu'), - 'eduPersonPrincipalName' => array('jdoe@example.com'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['j.doe@example.edu', 'john@example.org'], + 'eduPersonScopedAffiliation' => ['library-walk-in@example.edu'], + 'eduPersonPrincipalName' => ['jdoe@example.com'], + ] + ]; $result = self::processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); } @@ -136,20 +136,20 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testMultiAt() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('john@doe@example.com'), - 'eduPersonAffiliation' => array('member'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['john@doe@example.com'], + 'eduPersonAffiliation' => ['member'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('member@doe@example.com')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['member@doe@example.com']); } /* @@ -157,20 +157,20 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testMultivaluedSource() { - $config = array( + $config = [ 'scopeAttribute' => 'eduPersonPrincipalName', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - 'eduPersonAffiliation' => array('member','staff','faculty'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + 'eduPersonAffiliation' => ['member','staff','faculty'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('member@example.com','staff@example.com','faculty@example.com')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['member@example.com','staff@example.com','faculty@example.com']); } /* @@ -178,20 +178,20 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testNoAt() { - $config = array( + $config = [ 'scopeAttribute' => 'schacHomeOrganization', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', - ); - $request = array( - 'Attributes' => array( - 'schacHomeOrganization' => array('example.org'), - 'eduPersonAffiliation' => array('student'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'schacHomeOrganization' => ['example.org'], + 'eduPersonAffiliation' => ['student'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('student@example.org')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['student@example.org']); } /* @@ -199,21 +199,21 @@ class Test_Core_Auth_Process_ScopeAttribute extends TestCase */ public function testOnlyIfEmpty() { - $config = array( + $config = [ 'scopeAttribute' => 'schacHomeOrganization', 'sourceAttribute' => 'eduPersonAffiliation', 'targetAttribute' => 'eduPersonScopedAffiliation', 'onlyIfEmpty' => true, - ); - $request = array( - 'Attributes' => array( - 'schacHomeOrganization' => array('example.org'), - 'eduPersonAffiliation' => array('student'), - 'eduPersonScopedAffiliation' => array('staff@example.org', 'member@example.org'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'schacHomeOrganization' => ['example.org'], + 'eduPersonAffiliation' => ['student'], + 'eduPersonScopedAffiliation' => ['staff@example.org', 'member@example.org'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['eduPersonScopedAffiliation'], array('staff@example.org', 'member@example.org')); + $this->assertEquals($attributes['eduPersonScopedAffiliation'], ['staff@example.org', 'member@example.org']); } } diff --git a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php index 1d24c38e9..0e5aace08 100644 --- a/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php +++ b/tests/modules/core/lib/Auth/Process/ScopeFromAttributeTest.php @@ -27,19 +27,19 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ public function testBasic() { - $config = array( + $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; $this->assertArrayHasKey('scope', $attributes); - $this->assertEquals($attributes['scope'], array('example.com')); + $this->assertEquals($attributes['scope'], ['example.com']); } /* @@ -47,19 +47,19 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ public function testNoOverwrite() { - $config = array( + $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - 'scope' => array('example.edu') - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + 'scope' => ['example.edu'] + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['scope'], array('example.edu')); + $this->assertEquals($attributes['scope'], ['example.edu']); } /* @@ -67,16 +67,16 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ public function testNoSourceAttribute() { - $config = array( + $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', - ); - $request = array( - 'Attributes' => array( - 'mail' => array('j.doe@example.edu', 'john@example.org'), - 'scope' => array('example.edu') - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'mail' => ['j.doe@example.edu', 'john@example.org'], + 'scope' => ['example.edu'] + ] + ]; $result = self::processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); } @@ -86,18 +86,18 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ public function testMultiAt() { - $config = array( + $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('john@doe@example.com'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['john@doe@example.com'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; - $this->assertEquals($attributes['scope'], array('example.com')); + $this->assertEquals($attributes['scope'], ['example.com']); } /* @@ -105,15 +105,15 @@ class Test_Core_Auth_Process_ScopeFromAttribute extends TestCase */ public function testNoAt() { - $config = array( + $config = [ 'sourceAttribute' => 'eduPersonPrincipalName', 'targetAttribute' => 'scope', - ); - $request = array( - 'Attributes' => array( - 'eduPersonPrincipalName' => array('johndoe'), - ) - ); + ]; + $request = [ + 'Attributes' => [ + 'eduPersonPrincipalName' => ['johndoe'], + ] + ]; $result = self::processFilter($config, $request); $attributes = $result['Attributes']; diff --git a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php index 15c6b764d..51f5c6b1d 100644 --- a/tests/modules/core/lib/Auth/Process/TargetedIDTest.php +++ b/tests/modules/core/lib/Auth/Process/TargetedIDTest.php @@ -29,7 +29,7 @@ class Test_Core_Auth_Process_TargetedID extends TestCase // $config = array( // ); // $request = array( -// 'Attributes' => array(), +// 'Attributes' => [], // 'UserID' => 'user2@example.org', // ); // $result = self::processFilter($config, $request); @@ -168,11 +168,10 @@ class Test_Core_Auth_Process_TargetedID extends TestCase */ public function testNoUserID() { - $config = array( - ); - $request = array( - 'Attributes' => array(), - ); + $config = []; + $request = [ + 'Attributes' => [], + ]; self::processFilter($config, $request); } @@ -183,14 +182,14 @@ class Test_Core_Auth_Process_TargetedID extends TestCase */ public function testAttributeNotExists() { - $config = array( + $config = [ 'attributename' => 'uid', - ); - $request = array( - 'Attributes' => array( + ]; + $request = [ + 'Attributes' => [ 'displayName' => 'Jack Student', - ), - ); + ], + ]; self::processFilter($config, $request); } @@ -201,14 +200,14 @@ class Test_Core_Auth_Process_TargetedID extends TestCase */ public function testConfigInvalidAttributeName() { - $config = array( + $config = [ 'attributename' => 5, - ); - $request = array( - 'Attributes' => array( + ]; + $request = [ + 'Attributes' => [ 'displayName' => 'Jack Student', - ), - ); + ], + ]; self::processFilter($config, $request); } @@ -219,14 +218,14 @@ class Test_Core_Auth_Process_TargetedID extends TestCase */ public function testConfigInvalidNameId() { - $config = array( + $config = [ 'nameId' => 'persistent', - ); - $request = array( - 'Attributes' => array( + ]; + $request = [ + 'Attributes' => [ 'displayName' => 'Jack Student', - ), - ); + ], + ]; self::processFilter($config, $request); } } diff --git a/tests/modules/core/lib/Auth/UserPassBaseTest.php b/tests/modules/core/lib/Auth/UserPassBaseTest.php index d70616800..e3e1d25d7 100644 --- a/tests/modules/core/lib/Auth/UserPassBaseTest.php +++ b/tests/modules/core/lib/Auth/UserPassBaseTest.php @@ -4,15 +4,15 @@ class UserPassBaseTest extends \PHPUnit_Framework_TestCase { public function testAuthenticateECPCallsLoginAndSetsAttributes() { - $state = array(); - $attributes = array('attrib' => 'val'); + $state = []; + $attributes = ['attrib' => 'val']; $username = $state['core:auth:username'] = 'username'; $password = $state['core:auth:password'] = 'password'; $stub = $this->getMockBuilder('\SimpleSAML\Module\core\Auth\UserPassBase') ->disableOriginalConstructor() - ->setMethods(array('login')) + ->setMethods(['login']) ->getMockForAbstractClass(); $stub->expects($this->once()) @@ -27,8 +27,8 @@ class UserPassBaseTest extends \PHPUnit_Framework_TestCase public function testAuthenticateECPCallsLoginWithForcedUsername() { - $state = array(); - $attributes = array(); + $state = []; + $attributes = []; $forcedUsername = 'forcedUsername'; @@ -37,7 +37,7 @@ class UserPassBaseTest extends \PHPUnit_Framework_TestCase $stub = $this->getMockBuilder('\SimpleSAML\Module\core\Auth\UserPassBase') ->disableOriginalConstructor() - ->setMethods(array('login')) + ->setMethods(['login']) ->getMockForAbstractClass(); $stub->expects($this->once()) diff --git a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php index 3ee9098b8..90816896b 100644 --- a/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php +++ b/tests/modules/core/lib/Auth/UserPassOrgBaseTest.php @@ -8,13 +8,13 @@ class UserPassOrgBaseTest extends \PHPUnit_Framework_TestCase { public function testRememberOrganizationEnabled() { - $config = array( + $config = [ 'ldap:LDAPMulti', 'remember.organization.enabled' => true, 'remember.organization.checked' => false, - 'my-org' => array( + 'my-org' => [ 'description' => 'My organization', // The rest of the options are the same as those available for // the LDAP authentication source. @@ -22,14 +22,14 @@ class UserPassOrgBaseTest extends \PHPUnit_Framework_TestCase 'dnpattern' => 'uid=%username%,ou=employees,dc=example,dc=org', // Whether SSL/TLS should be used when contacting the LDAP server. 'enable_tls' => false, - ) - ); + ] + ]; // When PHP 5.4 support is dropped, replace with: // $mockUserPassOrgBase = $this->getMockBuilder(\SimpleSAML\Module\core\Auth\UserPassOrgBase::class) - $mockUserPassOrgBase = $this->getMockBuilder(get_parent_class(new \SimpleSAML\Module\ldap\Auth\Source\LDAPMulti(array('AuthId' => 'my-org'), array()))) - ->setConstructorArgs(array(array('AuthId' => 'my-org'), &$config)) - ->setMethods(array()) + $mockUserPassOrgBase = $this->getMockBuilder(get_parent_class(new \SimpleSAML\Module\ldap\Auth\Source\LDAPMulti(['AuthId' => 'my-org'], []))) + ->setConstructorArgs([['AuthId' => 'my-org'], &$config]) + ->setMethods([]) ->getMockForAbstractClass(); $this->assertTrue($mockUserPassOrgBase->getRememberOrganizationEnabled()); diff --git a/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php b/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php index 11f6efed6..b7c502e4e 100644 --- a/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php +++ b/tests/modules/ldap/lib/Auth/Process/BaseFilterTest.php @@ -15,11 +15,11 @@ class BaseFilter_Test extends TestCase $this->assertEquals( "array ( 'ldap.hostname' => 'ldap://172.17.101.32', 'ldap.port' => 389, 'ldap.password' => '********', )", - $method->invokeArgs($stub, array(array( + $method->invokeArgs($stub, [[ 'ldap.hostname' => 'ldap://172.17.101.32', 'ldap.port' => 389, 'ldap.password' => 'password', - ))) + ]]) ); } } diff --git a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php index 1915c9c0e..20e9400b6 100644 --- a/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php +++ b/tests/modules/saml/lib/Auth/Process/FilterScopesTest.php @@ -34,51 +34,51 @@ class FilterScopesTest extends TestCase public function testValidScopes() { // test declared scopes - $config = array(); - $request = array( - 'Source' => array( - 'SingleSignOnService' => array( - array( + $config = []; + $request = [ + 'Source' => [ + 'SingleSignOnService' => [ + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'Location' => 'https://example.org/saml2/idp/SSOService.php', - ), - ), - 'scope' => array( + ], + ], + 'scope' => [ 'example.com', 'example.net', - ), - ), - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.com'), - ), - ); + ], + ], + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.com'], + ], + ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); // test multiple values - $request['Attributes'] = array( - 'eduPersonPrincipalName' => array( + $request['Attributes'] = [ + 'eduPersonPrincipalName' => [ 'jdoe@example.com', 'jdoe@example.net', - ), - ); + ], + ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); // test implicit scope - $request['Attributes'] = array( - 'eduPersonPrincipalName' => array('jdoe@example.org'), - ); + $request['Attributes'] = [ + 'eduPersonPrincipalName' => ['jdoe@example.org'], + ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); // test alternative attributes - $config['attributes'] = array( + $config['attributes'] = [ 'mail', - ); - $request['Attributes'] = array( - 'mail' => array('john.doe@example.org'), - ); + ]; + $request['Attributes'] = [ + 'mail' => ['john.doe@example.org'], + ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); @@ -95,43 +95,43 @@ class FilterScopesTest extends TestCase public function testInvalidScopes() { // test scope not matching anything, empty attribute - $config = array(); - $request = array( - 'Source' => array( - 'SingleSignOnService' => array( - array( + $config = []; + $request = [ + 'Source' => [ + 'SingleSignOnService' => [ + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'Location' => 'https://example.org/saml2/idp/SSOService.php', - ), - ), - 'scope' => array( + ], + ], + 'scope' => [ 'example.com', 'example.net', - ), - ), - 'Attributes' => array( - 'eduPersonPrincipalName' => array('jdoe@example.edu'), - ), - ); + ], + ], + 'Attributes' => [ + 'eduPersonPrincipalName' => ['jdoe@example.edu'], + ], + ]; $result = $this->processFilter($config, $request); - $this->assertEquals(array(), $result['Attributes']); + $this->assertEquals([], $result['Attributes']); // test some scopes allowed and some others not $request['Attributes']['eduPersonPrincipalName'][] = 'jdoe@example.com'; $result = $this->processFilter($config, $request); $this->assertEquals( - array( - 'eduPersonPrincipalName' => array( + [ + 'eduPersonPrincipalName' => [ 'jdoe@example.com', - ), - ), + ], + ], $result['Attributes'] ); // test attribute missing scope - $request['Attributes'] = array( - 'eduPersonPrincipalName' => array('jdoe'), - ); + $request['Attributes'] = [ + 'eduPersonPrincipalName' => ['jdoe'], + ]; $result = $this->processFilter($config, $request); $this->assertEquals($request['Attributes'], $result['Attributes']); } diff --git a/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php b/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php index 84799db9e..fbcf3796c 100644 --- a/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php +++ b/tests/modules/saml/lib/Auth/Process/NameIDAttributeTest.php @@ -31,7 +31,7 @@ class NameIDAttributeTest extends TestCase */ public function testMinimalConfig() { - $config = array(); + $config = []; $nameId = new \SAML2\XML\saml\NameID(); $nameId->value = 'eugene@oombaas'; @@ -40,15 +40,15 @@ class NameIDAttributeTest extends TestCase $spId = 'eugeneSP'; $idpId = 'eugeneIdP'; - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => $spId, - ), - 'Destination' => array( + ], + 'Destination' => [ 'entityid' => $idpId, - ), + ], 'saml:sp:NameID' => $nameId, - ); + ]; $result = $this->processFilter($config, $request); $this->assertEquals("{$spId}!{$idpId}!{$nameId->value}", $result['Attributes']['nameid'][0]); } @@ -59,7 +59,7 @@ class NameIDAttributeTest extends TestCase public function testCustomAttributeName() { $attributeName = 'eugeneNameIDAttribute'; - $config = array('attribute' => $attributeName); + $config = ['attribute' => $attributeName]; $nameId = new \SAML2\XML\saml\NameID(); $nameId->value = 'eugene@oombaas'; @@ -68,15 +68,15 @@ class NameIDAttributeTest extends TestCase $spId = 'eugeneSP'; $idpId = 'eugeneIdP'; - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => $spId, - ), - 'Destination' => array( + ], + 'Destination' => [ 'entityid' => $idpId, - ), + ], 'saml:sp:NameID' => $nameId, - ); + ]; $result = $this->processFilter($config, $request); $this->assertTrue(isset($result['Attributes'][$attributeName])); $this->assertEquals("{$spId}!{$idpId}!{$nameId->value}", $result['Attributes'][$attributeName][0]); @@ -87,7 +87,7 @@ class NameIDAttributeTest extends TestCase */ public function testFormat() { - $config = array('format' => '%V'); + $config = ['format' => '%V']; $nameId = new \SAML2\XML\saml\NameID(); $nameId->value = 'eugene@oombaas'; @@ -96,15 +96,15 @@ class NameIDAttributeTest extends TestCase $spId = 'eugeneSP'; $idpId = 'eugeneIdP'; - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => $spId, - ), - 'Destination' => array( + ], + 'Destination' => [ 'entityid' => $idpId, - ), + ], 'saml:sp:NameID' => $nameId, - ); + ]; $result = $this->processFilter($config, $request); $this->assertEquals("{$nameId->value}", $result['Attributes']['nameid'][0]); } @@ -116,7 +116,7 @@ class NameIDAttributeTest extends TestCase public function testCustomAttributeNameAndFormat() { $attributeName = 'eugeneNameIDAttribute'; - $config = array('attribute' => $attributeName, 'format' => '%V'); + $config = ['attribute' => $attributeName, 'format' => '%V']; $nameId = new \SAML2\XML\saml\NameID(); $nameId->value = 'eugene@oombaas'; @@ -125,15 +125,15 @@ class NameIDAttributeTest extends TestCase $spId = 'eugeneSP'; $idpId = 'eugeneIdP'; - $request = array( - 'Source' => array( + $request = [ + 'Source' => [ 'entityid' => $spId, - ), - 'Destination' => array( + ], + 'Destination' => [ 'entityid' => $idpId, - ), + ], 'saml:sp:NameID' => $nameId, - ); + ]; $result = $this->processFilter($config, $request); $this->assertTrue(isset($result['Attributes'][$attributeName])); $this->assertEquals("{$nameId->value}", $result['Attributes'][$attributeName][0]); diff --git a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php index 502babca7..f3634818d 100644 --- a/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php +++ b/tests/modules/saml/lib/Auth/Source/Auth_Source_SP_Test.php @@ -55,11 +55,11 @@ class SP_Tester extends \SimpleSAML\Module\saml\Auth\Source\SP { // Exit test. Continuing would mean running into a assert(FALSE) throw new ExitTestException( - array( + [ 'state' => $state, 'binding' => $binding, 'ar' => $ar, - ) + ] ); } } @@ -91,17 +91,17 @@ class SP_Test extends TestCase protected function setUp() { - $this->idpConfigArray = array( + $this->idpConfigArray = [ 'metadata-set' => 'saml20-idp-remote', 'entityid' => 'https://engine.surfconext.nl/authentication/idp/metadata', - 'SingleSignOnService' => array( - array( + 'SingleSignOnService' => [ + [ 'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect', 'Location' => 'https://engine.surfconext.nl/authentication/idp/single-sign-on', - ), - ), - 'keys' => array( - array( + ], + ], + 'keys' => [ + [ 'encryption' => false, 'signing' => true, 'type' => 'X509Certificate', @@ -121,11 +121,11 @@ class SP_Test extends TestCase 'ZkQO8EsscJPPy/Zp4uHAnADWACkOUHiCbcKiUUFu66dX0Wr/v53Gekz487GgVRs8HEeT9MU1reBKRgdENR8PNg4rbQfLc'. '3YQKLWK7yWnn/RenjDpuCiePj8N8/80tGgrNgK/6fzM3zI18sSywnXLswxqDb/J+jgVxnQ6MrsTf1urM8MnfcxG/82oHI'. 'wfMh/sXPCZpo+DTLkhQxctJ3M=', - ), - ), - ); + ], + ], + ]; - $this->config = Configuration::loadFromArray(array(), '[ARRAY]', 'simplesaml'); + $this->config = Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); } @@ -137,10 +137,10 @@ class SP_Test extends TestCase * * @return \SAML2\AuthnRequest The AuthnRequest generated. */ - private function createAuthnRequest($state = array()) + private function createAuthnRequest($state = []) { - $info = array('AuthId' => 'default-sp'); - $config = array(); + $info = ['AuthId' => 'default-sp']; + $config = []; $as = new SP_Tester($info, $config); /** @var \SAML2\AuthnRequest $ar */ @@ -187,9 +187,9 @@ class SP_Test extends TestCase */ public function testNameID() { - $state = array( - 'saml:NameID' => array('Value' => 'user@example.org', 'Format' => \SAML2\Constants::NAMEID_UNSPECIFIED) - ); + $state = [ + 'saml:NameID' => ['Value' => 'user@example.org', 'Format' => \SAML2\Constants::NAMEID_UNSPECIFIED] + ]; /** @var \SAML2\AuthnRequest $ar */ $ar = $this->createAuthnRequest($state); @@ -219,9 +219,9 @@ class SP_Test extends TestCase */ public function testAuthnContextClassRef() { - $state = array( + $state = [ 'saml:AuthnContextClassRef' => 'http://example.com/myAuthnContextClassRef' - ); + ]; /** @var \SAML2\AuthnRequest $ar */ $ar = $this->createAuthnRequest($state); @@ -248,9 +248,9 @@ class SP_Test extends TestCase */ public function testForcedAuthn() { - $state = array( + $state = [ 'ForceAuthn' => true - ); + ]; /** @var \SAML2\AuthnRequest $ar */ $ar = $this->createAuthnRequest($state); diff --git a/tests/modules/saml/lib/IdP/SAML2Test.php b/tests/modules/saml/lib/IdP/SAML2Test.php index 76efcedb2..1dce810fa 100644 --- a/tests/modules/saml/lib/IdP/SAML2Test.php +++ b/tests/modules/saml/lib/IdP/SAML2Test.php @@ -6,7 +6,7 @@ class SAML2Test extends \PHPUnit_Framework_TestCase { $username = $_SERVER['PHP_AUTH_USER'] = 'username'; $password = $_SERVER['PHP_AUTH_PW'] = 'password'; - $state = array(); + $state = []; \SimpleSAML\Module\saml\IdP\SAML2::processSOAPAuthnRequest($state); @@ -20,7 +20,7 @@ class SAML2Test extends \PHPUnit_Framework_TestCase $_SERVER['PHP_AUTH_PW'] = 'password'; unset($_SERVER['PHP_AUTH_USER']); - $state = array(); + $state = []; \SimpleSAML\Module\saml\IdP\SAML2::processSOAPAuthnRequest($state); } @@ -31,7 +31,7 @@ class SAML2Test extends \PHPUnit_Framework_TestCase $_SERVER['PHP_AUTH_USER'] = 'username'; unset($_SERVER['PHP_AUTH_PW']); - $state = array(); + $state = []; \SimpleSAML\Module\saml\IdP\SAML2::processSOAPAuthnRequest($state); } diff --git a/tests/www/IndexTest.php b/tests/www/IndexTest.php index be7d06012..7d3bcedd0 100644 --- a/tests/www/IndexTest.php +++ b/tests/www/IndexTest.php @@ -72,12 +72,12 @@ class IndexTest extends TestCase } // test most basic redirection - $this->updateConfig(array( + $this->updateConfig([ 'baseurlpath' => 'http://example.org/simplesaml/' - )); - $resp = $this->server->get('/index.php', array(), array( + ]); + $resp = $this->server->get('/index.php', [], [ CURLOPT_FOLLOWLOCATION => 0, - )); + ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( 'http://example.org/simplesaml/module.php/core/frontpage_welcome.php', @@ -85,12 +85,12 @@ class IndexTest extends TestCase ); // test non-default path and https - $this->updateConfig(array( + $this->updateConfig([ 'baseurlpath' => 'https://example.org/' - )); - $resp = $this->server->get('/index.php', array(), array( + ]); + $resp = $this->server->get('/index.php', [], [ CURLOPT_FOLLOWLOCATION => 0, - )); + ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( 'https://example.org/module.php/core/frontpage_welcome.php', @@ -98,12 +98,12 @@ class IndexTest extends TestCase ); // test URL guessing - $this->updateConfig(array( + $this->updateConfig([ 'baseurlpath' => '/simplesaml/' - )); - $resp = $this->server->get('/index.php', array(), array( + ]); + $resp = $this->server->get('/index.php', [], [ CURLOPT_FOLLOWLOCATION => 0, - )); + ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( 'http://'.$this->server_addr.'/simplesaml/module.php/core/frontpage_welcome.php', diff --git a/tests/www/TemplateTest.php b/tests/www/TemplateTest.php index dda326a62..06dfe1080 100644 --- a/tests/www/TemplateTest.php +++ b/tests/www/TemplateTest.php @@ -27,7 +27,7 @@ class TemplateTest extends TestCase $basedir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'templates'; // Base templates - $files = array_diff(scandir($basedir), array('.', '..')); + $files = array_diff(scandir($basedir), ['.', '..']); foreach ($files as $file) { if (preg_match('/.twig$/', $file)) { $t = new Template($config, $file); @@ -46,7 +46,7 @@ class TemplateTest extends TestCase foreach (Module::getModules() as $module) { $basedir = Module::getModuleDir($module).DIRECTORY_SEPARATOR.'templates'; if (file_exists($basedir)) { - $files = array_diff(scandir($basedir), array('.', '..')); + $files = array_diff(scandir($basedir), ['.', '..']); foreach ($files as $file) { if (preg_match('/.twig$/', $file)) { $t = new Template($config, $module.':'.$file); diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php index fa93ab5d8..2948ef12d 100644 --- a/www/admin/hostnames.php +++ b/www/admin/hostnames.php @@ -9,21 +9,21 @@ $session = \SimpleSAML\Session::getSessionFromRequest(); // Check if valid local session exists.. \SimpleSAML\Utils\Auth::requireAdmin(); -$attributes = array(); - -$attributes['HTTP_HOST'] = array($_SERVER['HTTP_HOST']); -$attributes['HTTPS'] = isset($_SERVER['HTTPS']) ? array($_SERVER['HTTPS']) : array(); -$attributes['SERVER_PROTOCOL'] = array($_SERVER['SERVER_PROTOCOL']); -$attributes['SERVER_PORT'] = array($_SERVER['SERVER_PORT']); - -$attributes['getBaseURL()'] = array(\SimpleSAML\Utils\HTTP::getBaseURL()); -$attributes['getSelfHost()'] = array(\SimpleSAML\Utils\HTTP::getSelfHost()); -$attributes['getSelfHostWithNonStandardPort()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithNonStandardPort()); -$attributes['selfURLhost()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLHost()); -$attributes['selfURLNoQuery()'] = array(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()); -$attributes['getSelfHostWithPath()'] = array(\SimpleSAML\Utils\HTTP::getSelfHostWithPath()); -$attributes['getFirstPathElement()'] = array(\SimpleSAML\Utils\HTTP::getFirstPathElement()); -$attributes['selfURL()'] = array(\SimpleSAML\Utils\HTTP::getSelfURL()); +$attributes = []; + +$attributes['HTTP_HOST'] = [$_SERVER['HTTP_HOST']]; +$attributes['HTTPS'] = isset($_SERVER['HTTPS']) ? [$_SERVER['HTTPS']] : []; +$attributes['SERVER_PROTOCOL'] = [$_SERVER['SERVER_PROTOCOL']]; +$attributes['SERVER_PORT'] = [$_SERVER['SERVER_PORT']]; + +$attributes['getBaseURL()'] = [\SimpleSAML\Utils\HTTP::getBaseURL()]; +$attributes['getSelfHost()'] = [\SimpleSAML\Utils\HTTP::getSelfHost()]; +$attributes['getSelfHostWithNonStandardPort()'] = [\SimpleSAML\Utils\HTTP::getSelfHostWithNonStandardPort()]; +$attributes['selfURLhost()'] = [\SimpleSAML\Utils\HTTP::getSelfURLHost()]; +$attributes['selfURLNoQuery()'] = [\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()]; +$attributes['getSelfHostWithPath()'] = [\SimpleSAML\Utils\HTTP::getSelfHostWithPath()]; +$attributes['getFirstPathElement()'] = [\SimpleSAML\Utils\HTTP::getFirstPathElement()]; +$attributes['selfURL()'] = [\SimpleSAML\Utils\HTTP::getSelfURL()]; $template = new \SimpleSAML\XHTML\Template($config, 'hostnames.php'); diff --git a/www/admin/index.php b/www/admin/index.php index ca17976f2..41e9c200a 100644 --- a/www/admin/index.php +++ b/www/admin/index.php @@ -9,12 +9,12 @@ $session = \SimpleSAML\Session::getSessionFromRequest(); // Check if valid local session exists.. \SimpleSAML\Utils\Auth::requireAdmin(); -$adminpages = array( +$adminpages = [ 'hostnames.php' => 'Diagnostics on hostname, port and protocol', 'phpinfo.php' => 'PHP info', '../module.php/sanitycheck/index.php' => 'Sanity check of your SimpleSAMLphp setup', 'sandbox.php' => 'Sandbox for testing changes to layout and css', -); +]; $logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php index db3114fb4..e88dff061 100644 --- a/www/admin/metadata-converter.php +++ b/www/admin/metadata-converter.php @@ -19,12 +19,12 @@ if (!empty($xmldata)) { // get all metadata for the entities foreach ($entities as &$entity) { - $entity = array( + $entity = [ 'shib13-sp-remote' => $entity->getMetadata1xSP(), 'shib13-idp-remote' => $entity->getMetadata1xIdP(), 'saml20-sp-remote' => $entity->getMetadata20SP(), 'saml20-idp-remote' => $entity->getMetadata20IdP(), - ); + ]; } // transpose from $entities[entityid][type] to $output[type][entityid] @@ -49,7 +49,7 @@ if (!empty($xmldata)) { } } else { $xmldata = ''; - $output = array(); + $output = []; } $template = new \SimpleSAML\XHTML\Template($config, 'metadata-converter.php', 'admin'); diff --git a/www/authmemcookie.php b/www/authmemcookie.php index 032c05f4c..9825c62f5 100644 --- a/www/authmemcookie.php +++ b/www/authmemcookie.php @@ -40,7 +40,7 @@ try { // generate the authentication information $attributes = $s->getAttributes(); - $authData = array(); + $authData = []; // username $usernameAttr = $amc->getUsernameAttr(); @@ -63,7 +63,7 @@ try { } $authData['Groups'] = $attributes[$groupsAttr]; } else { - $authData['Groups'] = array(); + $authData['Groups'] = []; } $authData['RemoteIP'] = $_SERVER['REMOTE_ADDR']; diff --git a/www/errorreport.php b/www/errorreport.php index 303c97877..0193e4767 100644 --- a/www/errorreport.php +++ b/www/errorreport.php @@ -26,7 +26,7 @@ try { } if ($data === null) { - $data = array( + $data = [ 'exceptionMsg' => 'not set', 'exceptionTrace' => 'not set', 'reportId' => $reportId, @@ -34,7 +34,7 @@ if ($data === null) { 'url' => 'not set', 'version' => $config->getVersion(), 'referer' => 'not set', - ); + ]; if (isset($session)) { $data['trackId'] = $session->getTrackID(); diff --git a/www/module.php b/www/module.php index d8a72013d..c53d595f6 100644 --- a/www/module.php +++ b/www/module.php @@ -13,10 +13,10 @@ require_once('_include.php'); // index pages - file names to attempt when accessing directories -$indexFiles = array('index.php', 'index.html', 'index.htm', 'index.txt'); +$indexFiles = ['index.php', 'index.html', 'index.htm', 'index.txt']; // MIME types - key is file extension, value is MIME type -$mimeTypes = array( +$mimeTypes = [ 'bmp' => 'image/x-ms-bmp', 'css' => 'text/css', 'gif' => 'image/gif', @@ -37,7 +37,7 @@ $mimeTypes = array( 'txt' => 'text/plain', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', -); +]; if (empty($_SERVER['PATH_INFO'])) { throw new \SimpleSAML\Error\NotFound('No PATH_INFO to module.php'); diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index 77f9e20f0..a1779bf09 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -26,18 +26,18 @@ try { $_GET['idpentityid'] : $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'saml20-idp-hosted'); - $availableCerts = array(); + $availableCerts = []; - $keys = array(); + $keys = []; $certInfo = Crypto::loadPublicKey($idpmeta, false, 'new_'); if ($certInfo !== null) { $availableCerts['new_idp.crt'] = $certInfo; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => true, 'X509Certificate' => $certInfo['certData'], - ); + ]; $hasNewCert = true; } else { $hasNewCert = false; @@ -45,29 +45,29 @@ try { $certInfo = Crypto::loadPublicKey($idpmeta, true); $availableCerts['idp.crt'] = $certInfo; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => ($hasNewCert ? false : true), 'X509Certificate' => $certInfo['certData'], - ); + ]; if ($idpmeta->hasValue('https.certificate')) { $httpsCert = Crypto::loadPublicKey($idpmeta, true, 'https.'); assert(isset($httpsCert['certData'])); $availableCerts['https.crt'] = $httpsCert; - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => false, 'X509Certificate' => $httpsCert['certData'], - ); + ]; } - $metaArray = array( + $metaArray = [ 'metadata-set' => 'saml20-idp-remote', 'entityid' => $idpentityid, - ); + ]; $ssob = $metadata->getGenerated('SingleSignOnServiceBinding', 'saml20-idp-hosted'); $slob = $metadata->getGenerated('SingleLogoutServiceBinding', 'saml20-idp-hosted'); @@ -76,30 +76,30 @@ try { if (is_array($ssob)) { foreach ($ssob as $binding) { - $metaArray['SingleSignOnService'][] = array( + $metaArray['SingleSignOnService'][] = [ 'Binding' => $binding, 'Location' => $ssol, - ); + ]; } } else { - $metaArray['SingleSignOnService'][] = array( + $metaArray['SingleSignOnService'][] = [ 'Binding' => $ssob, 'Location' => $ssol, - ); + ]; } if (is_array($slob)) { foreach ($slob as $binding) { - $metaArray['SingleLogoutService'][] = array( + $metaArray['SingleLogoutService'][] = [ 'Binding' => $binding, 'Location' => $slol, - ); + ]; } } else { - $metaArray['SingleLogoutService'][] = array( + $metaArray['SingleLogoutService'][] = [ 'Binding' => $slob, 'Location' => $slol, - ); + ]; } if (count($keys) === 1) { @@ -110,28 +110,28 @@ try { if ($idpmeta->getBoolean('saml20.sendartifact', false)) { // Artifact sending enabled - $metaArray['ArtifactResolutionService'][] = array( + $metaArray['ArtifactResolutionService'][] = [ 'index' => 0, 'Location' => HTTP::getBaseURL().'saml2/idp/ArtifactResolutionService.php', 'Binding' => Constants::BINDING_SOAP, - ); + ]; } if ($idpmeta->getBoolean('saml20.hok.assertion', false)) { // Prepend HoK SSO Service endpoint. - array_unshift($metaArray['SingleSignOnService'], array( + array_unshift($metaArray['SingleSignOnService'], [ 'hoksso:ProtocolBinding' => Constants::BINDING_HTTP_REDIRECT, 'Binding' => Constants::BINDING_HOK_SSO, 'Location' => HTTP::getBaseURL().'saml2/idp/SSOService.php' - )); + ]); } if ($idpmeta->getBoolean('saml20.ecp', false)) { - $metaArray['SingleSignOnService'][] = array( + $metaArray['SingleSignOnService'][] = [ 'index' => 0, 'Binding' => Constants::BINDING_SOAP, 'Location' => HTTP::getBaseURL().'saml2/idp/SSOService.php', - ); + ]; } $metaArray['NameIDFormat'] = $idpmeta->getString( @@ -218,7 +218,7 @@ try { $t->data['clipboard.js'] = true; $t->data['available_certs'] = $availableCerts; - $certdata = array(); + $certdata = []; foreach (array_keys($availableCerts) as $availableCert) { $certdata[$availableCert]['name'] = $availableCert; $certdata[$availableCert]['url'] = SimpleSAML\Module::getModuleURL('saml/idp/certs.php').'/'.$availableCert; diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php index edb474eed..b971e138f 100644 --- a/www/shib13/idp/metadata.php +++ b/www/shib13/idp/metadata.php @@ -20,30 +20,30 @@ try { $_GET['idpentityid'] : $metadata->getMetaDataCurrentEntityID('shib13-idp-hosted'); $idpmeta = $metadata->getMetaDataConfig($idpentityid, 'shib13-idp-hosted'); - $keys = array(); + $keys = []; $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, false, 'new_'); if ($certInfo !== null) { - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => false, 'X509Certificate' => $certInfo['certData'], - ); + ]; } $certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($idpmeta, true); - $keys[] = array( + $keys[] = [ 'type' => 'X509Certificate', 'signing' => true, 'encryption' => false, 'X509Certificate' => $certInfo['certData'], - ); + ]; - $metaArray = array( + $metaArray = [ 'metadata-set' => 'shib13-idp-remote', 'entityid' => $idpentityid, 'SingleSignOnService' => $metadata->getGenerated('SingleSignOnService', 'shib13-idp-hosted'), - ); + ]; if (count($keys) === 1) { $metaArray['certData'] = $keys[0]['X509Certificate']; @@ -71,11 +71,11 @@ try { $metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP11($metaArray); $metaBuilder->addOrganizationInfo($metaArray); - $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array( + $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact([ 'emailAddress' => $config->getString('technicalcontact_email', null), 'name' => $config->getString('technicalcontact_name', null), 'contactType' => 'technical', - ))); + ])); $metaxml = $metaBuilder->getEntityDescriptorText(); // sign the metadata if enabled @@ -91,7 +91,7 @@ try { $t->data['headerString'] = \SimpleSAML\Locale\Translate::noop('metadata_shib13-idp'); $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::addURLParameters( \SimpleSAML\Utils\HTTP::getSelfURLNoQuery(), - array('output' => 'xml') + ['output' => 'xml'] ); $t->data['metadata'] = htmlspecialchars($metaxml); $t->data['metadataflat'] = htmlspecialchars($metaflat); -- GitLab