Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
900100c2
Commit
900100c2
authored
Nov 20, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1258 from cebe/self-static
Changed usage of self to static to allow extendibility
parents
182dfb39
e775c82d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
42 deletions
+42
-42
User.php
apps/basic/models/User.php
+2
-2
Widget.php
extensions/jui/Widget.php
+1
-1
BaseYii.php
framework/yii/BaseYii.php
+32
-32
BaseInflector.php
framework/yii/helpers/BaseInflector.php
+3
-3
Response.php
framework/yii/web/Response.php
+1
-1
TestCase.php
tests/unit/TestCase.php
+3
-3
No files found.
apps/basic/models/User.php
View file @
900100c2
...
...
@@ -26,14 +26,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
public
static
function
findIdentity
(
$id
)
{
return
isset
(
self
::
$users
[
$id
])
?
new
s
elf
(
self
::
$users
[
$id
])
:
null
;
return
isset
(
self
::
$users
[
$id
])
?
new
s
tatic
(
self
::
$users
[
$id
])
:
null
;
}
public
static
function
findByUsername
(
$username
)
{
foreach
(
self
::
$users
as
$user
)
{
if
(
strcasecmp
(
$user
[
'username'
],
$username
)
===
0
)
{
return
new
s
elf
(
$user
);
return
new
s
tatic
(
$user
);
}
}
return
null
;
...
...
extensions/jui/Widget.php
View file @
900100c2
...
...
@@ -66,7 +66,7 @@ class Widget extends \yii\base\Widget
/** @var \yii\web\AssetBundle $assetBundle */
$assetBundle
::
register
(
$view
);
/** @var \yii\web\AssetBundle $themeAsset */
$themeAsset
=
s
elf
::
$theme
;
$themeAsset
=
s
tatic
::
$theme
;
$themeAsset
::
register
(
$view
);
$id
=
$this
->
options
[
'id'
];
...
...
framework/yii/BaseYii.php
View file @
900100c2
...
...
@@ -147,11 +147,11 @@ class BaseYii
$pos
=
strpos
(
$alias
,
'/'
);
$root
=
$pos
===
false
?
$alias
:
substr
(
$alias
,
0
,
$pos
);
if
(
isset
(
s
elf
::
$aliases
[
$root
]))
{
if
(
is_string
(
s
elf
::
$aliases
[
$root
]))
{
return
$pos
===
false
?
s
elf
::
$aliases
[
$root
]
:
self
::
$aliases
[
$root
]
.
substr
(
$alias
,
$pos
);
if
(
isset
(
s
tatic
::
$aliases
[
$root
]))
{
if
(
is_string
(
s
tatic
::
$aliases
[
$root
]))
{
return
$pos
===
false
?
s
tatic
::
$aliases
[
$root
]
:
static
::
$aliases
[
$root
]
.
substr
(
$alias
,
$pos
);
}
else
{
foreach
(
s
elf
::
$aliases
[
$root
]
as
$name
=>
$path
)
{
foreach
(
s
tatic
::
$aliases
[
$root
]
as
$name
=>
$path
)
{
if
(
strpos
(
$alias
.
'/'
,
$name
.
'/'
)
===
0
)
{
return
$path
.
substr
(
$alias
,
strlen
(
$name
));
}
...
...
@@ -178,11 +178,11 @@ class BaseYii
$pos
=
strpos
(
$alias
,
'/'
);
$root
=
$pos
===
false
?
$alias
:
substr
(
$alias
,
0
,
$pos
);
if
(
isset
(
s
elf
::
$aliases
[
$root
]))
{
if
(
is_string
(
s
elf
::
$aliases
[
$root
]))
{
if
(
isset
(
s
tatic
::
$aliases
[
$root
]))
{
if
(
is_string
(
s
tatic
::
$aliases
[
$root
]))
{
return
$root
;
}
else
{
foreach
(
s
elf
::
$aliases
[
$root
]
as
$name
=>
$path
)
{
foreach
(
s
tatic
::
$aliases
[
$root
]
as
$name
=>
$path
)
{
if
(
strpos
(
$alias
.
'/'
,
$name
.
'/'
)
===
0
)
{
return
$name
;
}
...
...
@@ -229,30 +229,30 @@ class BaseYii
$root
=
$pos
===
false
?
$alias
:
substr
(
$alias
,
0
,
$pos
);
if
(
$path
!==
null
)
{
$path
=
strncmp
(
$path
,
'@'
,
1
)
?
rtrim
(
$path
,
'\\/'
)
:
static
::
getAlias
(
$path
);
if
(
!
isset
(
s
elf
::
$aliases
[
$root
]))
{
if
(
!
isset
(
s
tatic
::
$aliases
[
$root
]))
{
if
(
$pos
===
false
)
{
s
elf
::
$aliases
[
$root
]
=
$path
;
s
tatic
::
$aliases
[
$root
]
=
$path
;
}
else
{
s
elf
::
$aliases
[
$root
]
=
[
$alias
=>
$path
];
s
tatic
::
$aliases
[
$root
]
=
[
$alias
=>
$path
];
}
}
elseif
(
is_string
(
s
elf
::
$aliases
[
$root
]))
{
}
elseif
(
is_string
(
s
tatic
::
$aliases
[
$root
]))
{
if
(
$pos
===
false
)
{
s
elf
::
$aliases
[
$root
]
=
$path
;
s
tatic
::
$aliases
[
$root
]
=
$path
;
}
else
{
s
elf
::
$aliases
[
$root
]
=
[
s
tatic
::
$aliases
[
$root
]
=
[
$alias
=>
$path
,
$root
=>
s
elf
::
$aliases
[
$root
],
$root
=>
s
tatic
::
$aliases
[
$root
],
];
}
}
else
{
s
elf
::
$aliases
[
$root
][
$alias
]
=
$path
;
krsort
(
s
elf
::
$aliases
[
$root
]);
s
tatic
::
$aliases
[
$root
][
$alias
]
=
$path
;
krsort
(
s
tatic
::
$aliases
[
$root
]);
}
}
elseif
(
isset
(
s
elf
::
$aliases
[
$root
]))
{
if
(
is_array
(
s
elf
::
$aliases
[
$root
]))
{
unset
(
s
elf
::
$aliases
[
$root
][
$alias
]);
}
elseif
(
isset
(
s
tatic
::
$aliases
[
$root
]))
{
if
(
is_array
(
s
tatic
::
$aliases
[
$root
]))
{
unset
(
s
tatic
::
$aliases
[
$root
][
$alias
]);
}
elseif
(
$pos
===
false
)
{
unset
(
s
elf
::
$aliases
[
$root
]);
unset
(
s
tatic
::
$aliases
[
$root
]);
}
}
}
...
...
@@ -278,8 +278,8 @@ class BaseYii
*/
public
static
function
autoload
(
$className
)
{
if
(
isset
(
s
elf
::
$classMap
[
$className
]))
{
$classFile
=
s
elf
::
$classMap
[
$className
];
if
(
isset
(
s
tatic
::
$classMap
[
$className
]))
{
$classFile
=
s
tatic
::
$classMap
[
$className
];
if
(
$classFile
[
0
]
===
'@'
)
{
$classFile
=
static
::
getAlias
(
$classFile
);
}
...
...
@@ -362,8 +362,8 @@ class BaseYii
$class
=
ltrim
(
$class
,
'\\'
);
if
(
isset
(
s
elf
::
$objectConfig
[
$class
]))
{
$config
=
array_merge
(
s
elf
::
$objectConfig
[
$class
],
$config
);
if
(
isset
(
s
tatic
::
$objectConfig
[
$class
]))
{
$config
=
array_merge
(
s
tatic
::
$objectConfig
[
$class
],
$config
);
}
if
((
$n
=
func_num_args
())
>
1
)
{
...
...
@@ -394,7 +394,7 @@ class BaseYii
public
static
function
trace
(
$message
,
$category
=
'application'
)
{
if
(
YII_DEBUG
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_TRACE
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_TRACE
,
$category
);
}
}
...
...
@@ -407,7 +407,7 @@ class BaseYii
*/
public
static
function
error
(
$message
,
$category
=
'application'
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_ERROR
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_ERROR
,
$category
);
}
/**
...
...
@@ -419,7 +419,7 @@ class BaseYii
*/
public
static
function
warning
(
$message
,
$category
=
'application'
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_WARNING
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_WARNING
,
$category
);
}
/**
...
...
@@ -431,7 +431,7 @@ class BaseYii
*/
public
static
function
info
(
$message
,
$category
=
'application'
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_INFO
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_INFO
,
$category
);
}
/**
...
...
@@ -453,7 +453,7 @@ class BaseYii
*/
public
static
function
beginProfile
(
$token
,
$category
=
'application'
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_BEGIN
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_BEGIN
,
$category
);
}
/**
...
...
@@ -465,7 +465,7 @@ class BaseYii
*/
public
static
function
endProfile
(
$token
,
$category
=
'application'
)
{
s
elf
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_END
,
$category
);
s
tatic
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_END
,
$category
);
}
/**
...
...
@@ -504,8 +504,8 @@ class BaseYii
*/
public
static
function
t
(
$category
,
$message
,
$params
=
[],
$language
=
null
)
{
if
(
s
elf
::
$app
!==
null
)
{
return
s
elf
::
$app
->
getI18n
()
->
translate
(
$category
,
$message
,
$params
,
$language
?:
self
::
$app
->
language
);
if
(
s
tatic
::
$app
!==
null
)
{
return
s
tatic
::
$app
->
getI18n
()
->
translate
(
$category
,
$message
,
$params
,
$language
?:
static
::
$app
->
language
);
}
else
{
$p
=
[];
foreach
((
array
)
$params
as
$name
=>
$value
)
{
...
...
framework/yii/helpers/BaseInflector.php
View file @
900100c2
...
...
@@ -280,8 +280,8 @@ class BaseInflector
*/
public
static
function
pluralize
(
$word
)
{
if
(
isset
(
s
elf
::
$specials
[
$word
]))
{
return
s
elf
::
$specials
[
$word
];
if
(
isset
(
s
tatic
::
$specials
[
$word
]))
{
return
s
tatic
::
$specials
[
$word
];
}
foreach
(
static
::
$plurals
as
$rule
=>
$replacement
)
{
if
(
preg_match
(
$rule
,
$word
))
{
...
...
@@ -298,7 +298,7 @@ class BaseInflector
*/
public
static
function
singularize
(
$word
)
{
$result
=
array_search
(
$word
,
s
elf
::
$specials
,
true
);
$result
=
array_search
(
$word
,
s
tatic
::
$specials
,
true
);
if
(
$result
!==
false
)
{
return
$result
;
}
...
...
framework/yii/web/Response.php
View file @
900100c2
...
...
@@ -254,7 +254,7 @@ class Response extends \yii\base\Response
throw
new
InvalidParamException
(
"The HTTP status code is invalid:
$value
"
);
}
if
(
$text
===
null
)
{
$this
->
statusText
=
isset
(
s
elf
::
$httpStatuses
[
$this
->
_statusCode
])
?
self
::
$httpStatuses
[
$this
->
_statusCode
]
:
''
;
$this
->
statusText
=
isset
(
s
tatic
::
$httpStatuses
[
$this
->
_statusCode
])
?
static
::
$httpStatuses
[
$this
->
_statusCode
]
:
''
;
}
else
{
$this
->
statusText
=
$text
;
}
...
...
tests/unit/TestCase.php
View file @
900100c2
...
...
@@ -32,10 +32,10 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
*/
public
function
getParam
(
$name
,
$default
=
null
)
{
if
(
s
elf
::
$params
===
null
)
{
s
elf
::
$params
=
require
(
__DIR__
.
'/data/config.php'
);
if
(
s
tatic
::
$params
===
null
)
{
s
tatic
::
$params
=
require
(
__DIR__
.
'/data/config.php'
);
}
return
isset
(
s
elf
::
$params
[
$name
])
?
self
::
$params
[
$name
]
:
$default
;
return
isset
(
s
tatic
::
$params
[
$name
])
?
static
::
$params
[
$name
]
:
$default
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment