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
0
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
866df1b6
Commit
866df1b6
authored
5 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fully typehint lib/Store/*.php
parent
6d0b22e4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/SimpleSAML/Store/Memcache.php
+3
-11
3 additions, 11 deletions
lib/SimpleSAML/Store/Memcache.php
lib/SimpleSAML/Store/Redis.php
+3
-11
3 additions, 11 deletions
lib/SimpleSAML/Store/Redis.php
lib/SimpleSAML/Store/SQL.php
+9
-24
9 additions, 24 deletions
lib/SimpleSAML/Store/SQL.php
with
15 additions
and
46 deletions
lib/SimpleSAML/Store/Memcache.php
+
3
−
11
View file @
866df1b6
...
@@ -40,11 +40,8 @@ class Memcache extends Store
...
@@ -40,11 +40,8 @@ class Memcache extends Store
* @param string $key The key.
* @param string $key The key.
* @return mixed|null The value.
* @return mixed|null The value.
*/
*/
public
function
get
(
$type
,
$key
)
public
function
get
(
string
$type
,
string
$key
)
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
return
\SimpleSAML\Memcache
::
get
(
$this
->
prefix
.
'.'
.
$type
.
'.'
.
$key
);
return
\SimpleSAML\Memcache
::
get
(
$this
->
prefix
.
'.'
.
$type
.
'.'
.
$key
);
}
}
...
@@ -58,10 +55,8 @@ class Memcache extends Store
...
@@ -58,10 +55,8 @@ class Memcache extends Store
* @param int|null $expire The expiration time (unix timestamp), or NULL if it never expires.
* @param int|null $expire The expiration time (unix timestamp), or NULL if it never expires.
* @return void
* @return void
*/
*/
public
function
set
(
$type
,
$key
,
$value
,
$expire
=
null
)
public
function
set
(
string
$type
,
string
$key
,
$value
,
?int
$expire
=
null
)
:
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
if
(
$expire
===
null
)
{
if
(
$expire
===
null
)
{
...
@@ -79,11 +74,8 @@ class Memcache extends Store
...
@@ -79,11 +74,8 @@ class Memcache extends Store
* @param string $key The key.
* @param string $key The key.
* @return void
* @return void
*/
*/
public
function
delete
(
$type
,
$key
)
public
function
delete
(
string
$type
,
string
$key
):
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
\SimpleSAML\Memcache
::
delete
(
$this
->
prefix
.
'.'
.
$type
.
'.'
.
$key
);
\SimpleSAML\Memcache
::
delete
(
$this
->
prefix
.
'.'
.
$type
.
'.'
.
$key
);
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Store/Redis.php
+
3
−
11
View file @
866df1b6
...
@@ -77,11 +77,8 @@ class Redis extends Store
...
@@ -77,11 +77,8 @@ class Redis extends Store
*
*
* @return mixed|null The value associated with that key, or null if there's no such key.
* @return mixed|null The value associated with that key, or null if there's no such key.
*/
*/
public
function
get
(
$type
,
$key
)
public
function
get
(
string
$type
,
string
$key
)
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
$result
=
$this
->
redis
->
get
(
"
{
$type
}
.
{
$key
}
"
);
$result
=
$this
->
redis
->
get
(
"
{
$type
}
.
{
$key
}
"
);
if
(
$result
===
false
||
$result
===
null
)
{
if
(
$result
===
false
||
$result
===
null
)
{
...
@@ -101,10 +98,8 @@ class Redis extends Store
...
@@ -101,10 +98,8 @@ class Redis extends Store
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
* @return void
* @return void
*/
*/
public
function
set
(
$type
,
$key
,
$value
,
$expire
=
null
)
public
function
set
(
string
$type
,
string
$key
,
$value
,
?int
$expire
=
null
)
:
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
$serialized
=
serialize
(
$value
);
$serialized
=
serialize
(
$value
);
...
@@ -125,11 +120,8 @@ class Redis extends Store
...
@@ -125,11 +120,8 @@ class Redis extends Store
* @param string $key The key to delete.
* @param string $key The key to delete.
* @return void
* @return void
*/
*/
public
function
delete
(
$type
,
$key
)
public
function
delete
(
string
$type
,
string
$key
):
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
$this
->
redis
->
del
(
"
{
$type
}
.
{
$key
}
"
);
$this
->
redis
->
del
(
"
{
$type
}
.
{
$key
}
"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/SimpleSAML/Store/SQL.php
+
9
−
24
View file @
866df1b6
...
@@ -84,7 +84,7 @@ class SQL extends Store
...
@@ -84,7 +84,7 @@ class SQL extends Store
* Initialize the table-version table.
* Initialize the table-version table.
* @return void
* @return void
*/
*/
private
function
initTableVersionTable
()
private
function
initTableVersionTable
()
:
void
{
{
$this
->
tableVersions
=
[];
$this
->
tableVersions
=
[];
...
@@ -108,7 +108,7 @@ class SQL extends Store
...
@@ -108,7 +108,7 @@ class SQL extends Store
* Initialize key-value table.
* Initialize key-value table.
* @return void
* @return void
*/
*/
private
function
initKVTable
()
private
function
initKVTable
()
:
void
{
{
$current_version
=
$this
->
getTableVersion
(
'kvstore'
);
$current_version
=
$this
->
getTableVersion
(
'kvstore'
);
...
@@ -188,10 +188,8 @@ class SQL extends Store
...
@@ -188,10 +188,8 @@ class SQL extends Store
*
*
* @return int The table version, or 0 if the table doesn't exist.
* @return int The table version, or 0 if the table doesn't exist.
*/
*/
public
function
getTableVersion
(
$name
)
public
function
getTableVersion
(
string
$name
)
:
int
{
{
Assert
::
string
(
$name
);
if
(
!
isset
(
$this
->
tableVersions
[
$name
]))
{
if
(
!
isset
(
$this
->
tableVersions
[
$name
]))
{
return
0
;
return
0
;
}
}
...
@@ -207,11 +205,8 @@ class SQL extends Store
...
@@ -207,11 +205,8 @@ class SQL extends Store
* @param int $version Table version.
* @param int $version Table version.
* @return void
* @return void
*/
*/
public
function
setTableVersion
(
$name
,
$version
)
public
function
setTableVersion
(
string
$name
,
int
$version
)
:
void
{
{
Assert
::
string
(
$name
);
Assert
::
integer
(
$version
);
$this
->
insertOrUpdate
(
$this
->
insertOrUpdate
(
$this
->
prefix
.
'_tableVersion'
,
$this
->
prefix
.
'_tableVersion'
,
[
'_name'
],
[
'_name'
],
...
@@ -231,10 +226,8 @@ class SQL extends Store
...
@@ -231,10 +226,8 @@ class SQL extends Store
* @param array $data Associative array with columns.
* @param array $data Associative array with columns.
* @return void
* @return void
*/
*/
public
function
insertOrUpdate
(
$table
,
array
$keys
,
array
$data
)
public
function
insertOrUpdate
(
string
$table
,
array
$keys
,
array
$data
)
:
void
{
{
Assert
::
string
(
$table
);
$colNames
=
'('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
;
$colNames
=
'('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
;
$values
=
'VALUES(:'
.
implode
(
', :'
,
array_keys
(
$data
))
.
')'
;
$values
=
'VALUES(:'
.
implode
(
', :'
,
array_keys
(
$data
))
.
')'
;
...
@@ -289,7 +282,7 @@ class SQL extends Store
...
@@ -289,7 +282,7 @@ class SQL extends Store
* Clean the key-value table of expired entries.
* Clean the key-value table of expired entries.
* @return void
* @return void
*/
*/
private
function
cleanKVStore
()
private
function
cleanKVStore
()
:
void
{
{
Logger
::
debug
(
'store.sql: Cleaning key-value store.'
);
Logger
::
debug
(
'store.sql: Cleaning key-value store.'
);
...
@@ -309,11 +302,8 @@ class SQL extends Store
...
@@ -309,11 +302,8 @@ class SQL extends Store
*
*
* @return mixed|null The value associated with that key, or null if there's no such key.
* @return mixed|null The value associated with that key, or null if there's no such key.
*/
*/
public
function
get
(
$type
,
$key
)
public
function
get
(
string
$type
,
string
$key
)
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
if
(
strlen
(
$key
)
>
50
)
{
if
(
strlen
(
$key
)
>
50
)
{
$key
=
sha1
(
$key
);
$key
=
sha1
(
$key
);
}
}
...
@@ -353,10 +343,8 @@ class SQL extends Store
...
@@ -353,10 +343,8 @@ class SQL extends Store
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
* @param int|null $expire The expiration time (unix timestamp), or null if it never expires.
* @return void
* @return void
*/
*/
public
function
set
(
$type
,
$key
,
$value
,
$expire
=
null
)
public
function
set
(
string
$type
,
string
$key
,
$value
,
?int
$expire
=
null
)
:
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
Assert
::
nullOrGreaterThan
(
$expire
,
2592000
);
if
(
rand
(
0
,
1000
)
<
10
)
{
if
(
rand
(
0
,
1000
)
<
10
)
{
...
@@ -392,11 +380,8 @@ class SQL extends Store
...
@@ -392,11 +380,8 @@ class SQL extends Store
* @param string $key The key to delete.
* @param string $key The key to delete.
* @return void
* @return void
*/
*/
public
function
delete
(
$type
,
$key
)
public
function
delete
(
string
$type
,
string
$key
):
void
{
{
Assert
::
string
(
$type
);
Assert
::
string
(
$key
);
if
(
strlen
(
$key
)
>
50
)
{
if
(
strlen
(
$key
)
>
50
)
{
$key
=
sha1
(
$key
);
$key
=
sha1
(
$key
);
}
}
...
...
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