Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
4ba90617
Commit
4ba90617
authored
5 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fix Psalm-issues in Memcache.php
parent
d8dff112
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Memcache.php
+15
-11
15 additions, 11 deletions
lib/SimpleSAML/Memcache.php
with
15 additions
and
11 deletions
lib/SimpleSAML/Memcache.php
+
15
−
11
View file @
4ba90617
...
...
@@ -2,6 +2,8 @@
namespace
SimpleSAML
;
use
Memcache
as
_Memcache
;
use
Memcached
as
_Memcached
;
use
SimpleSAML\Utils
;
/**
...
...
@@ -26,7 +28,7 @@ class Memcache
/**
* Cache of the memcache servers we are using.
*
* @var \Memcache[]|null
* @var \Memcache[]|
\Memcached[]|
null
*/
private
static
$serverGroups
=
null
;
...
...
@@ -212,7 +214,7 @@ class Memcache
* The timeout for contacting this server, in seconds.
* The default value is 3 seconds.
*
* @param \Memcache $memcache The Memcache object we should add this server to.
* @param \Memcache
|\Memcached
$memcache The Memcache object we should add this server to.
* @param array $server An associative array with the configuration options for the server to add.
* @return void
*
...
...
@@ -290,7 +292,7 @@ class Memcache
}
// add this server to the Memcache object
if
(
self
::
$extension
===
'\m
emcached
'
)
{
if
(
$memcache
instanceof
\M
emcached
)
{
$memcache
->
addServer
(
$hostname
,
$port
);
}
else
{
$memcache
->
addServer
(
$hostname
,
$port
,
true
,
$weight
,
$timeout
,
$timeout
,
true
);
...
...
@@ -304,24 +306,25 @@ class Memcache
*
* @param array $group Array of servers which should be created as a group.
*
* @return \Memcache A Memcache object of the servers in the group
* @return \Memcache
|\Memcached
A Memcache object of the servers in the group
*
* @throws \Exception If the servers configuration is invalid.
*/
private
static
function
loadMemcacheServerGroup
(
array
$group
)
{
$class
=
class_exists
(
'\Memcache'
)
?
'\Memcache'
:
(
class_exists
(
'\Memcached'
)
?
'\Memcached'
:
false
);
if
(
!
$class
)
{
if
(
class_exists
(
_Memcache
::
class
))
{
$memcache
=
new
_Memcache
();
self
::
$extension
=
strtolower
(
_Memcache
::
class
);
}
elseif
(
class_exists
(
_Memcached
::
class
))
{
$memcache
=
new
_Memcached
();
self
::
$extension
=
strtolower
(
_Memcached
::
class
);
}
else
{
throw
new
\Exception
(
'Missing Memcached implementation. You must install either the Memcache or Memcached extension.'
);
}
elseif
(
strtolower
(
$class
)
===
'\memcache'
)
{
Logger
::
warning
(
"The use of PHP-extension memcache is deprecated. Please migrate to the memcached extension."
);
}
self
::
$extension
=
strtolower
(
$class
);
// create the \Memcache object
$memcache
=
new
$class
();
// iterate over all the servers in the group and add them to the Memcache object
foreach
(
$group
as
$index
=>
$server
)
{
...
...
@@ -346,6 +349,7 @@ class Memcache
self
::
addMemcacheServer
(
$memcache
,
$server
);
}
/** @var \Memcache|\Memcached */
return
$memcache
;
}
...
...
@@ -354,7 +358,7 @@ class Memcache
* This function gets a list of all configured memcache servers. This list is initialized based
* on the content of 'memcache_store.servers' in the configuration.
*
* @return \Memcache[] Array with Memcache objects.
* @return \Memcache[]
|\Memcached[]
Array with Memcache objects.
*
* @throws \Exception If the servers configuration is invalid.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment