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
d7df7053
Commit
d7df7053
authored
May 07, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
=== array() => empty()
parent
901dabc3
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
25 additions
and
23 deletions
+25
-23
YiiBase.php
framework/YiiBase.php
+1
-1
MigrateController.php
framework/console/controllers/MigrateController.php
+8
-5
Command.php
framework/db/Command.php
+1
-1
QueryBuilder.php
framework/db/QueryBuilder.php
+3
-3
Json.php
framework/helpers/base/Json.php
+1
-1
I18N.php
framework/i18n/I18N.php
+1
-1
FileValidator.php
framework/validators/FileValidator.php
+4
-4
Validator.php
framework/validators/Validator.php
+1
-2
Sort.php
framework/web/Sort.php
+1
-1
UrlManager.php
framework/web/UrlManager.php
+1
-1
FragmentCache.php
framework/widgets/FragmentCache.php
+3
-3
No files found.
framework/YiiBase.php
View file @
d7df7053
...
...
@@ -456,7 +456,7 @@ class YiiBase
}
return
$reflection
->
newInstanceArgs
(
$args
);
}
else
{
return
$config
===
array
(
)
?
new
$class
:
new
$class
(
$config
);
return
empty
(
$config
)
?
new
$class
:
new
$class
(
$config
);
}
}
...
...
framework/console/controllers/MigrateController.php
View file @
d7df7053
...
...
@@ -144,7 +144,8 @@ class MigrateController extends Controller
*/
public
function
actionUp
(
$limit
=
0
)
{
if
((
$migrations
=
$this
->
getNewMigrations
())
===
array
())
{
$migrations
=
$this
->
getNewMigrations
();
if
(
empty
(
$migrations
))
{
echo
"No new migration found. Your system is up-to-date.
\n
"
;
Yii
::
$app
->
end
();
}
...
...
@@ -198,7 +199,8 @@ class MigrateController extends Controller
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
if
((
$migrations
=
$this
->
getMigrationHistory
(
$limit
))
===
array
())
{
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
return
;
}
...
...
@@ -244,7 +246,8 @@ class MigrateController extends Controller
throw
new
Exception
(
"The step argument must be greater than 0."
);
}
if
((
$migrations
=
$this
->
getMigrationHistory
(
$limit
))
===
array
())
{
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
return
;
}
...
...
@@ -407,7 +410,7 @@ class MigrateController extends Controller
{
$limit
=
(
int
)
$limit
;
$migrations
=
$this
->
getMigrationHistory
(
$limit
);
if
(
$migrations
===
array
(
))
{
if
(
empty
(
$migrations
))
{
echo
"No migration has been done before.
\n
"
;
}
else
{
$n
=
count
(
$migrations
);
...
...
@@ -441,7 +444,7 @@ class MigrateController extends Controller
{
$limit
=
(
int
)
$limit
;
$migrations
=
$this
->
getNewMigrations
();
if
(
$migrations
===
array
(
))
{
if
(
empty
(
$migrations
))
{
echo
"No new migrations found. Your system is up-to-date.
\n
"
;
}
else
{
$n
=
count
(
$migrations
);
...
...
framework/db/Command.php
View file @
d7df7053
...
...
@@ -106,7 +106,7 @@ class Command extends \yii\base\Component
*/
public
function
getRawSql
()
{
if
(
$this
->
_params
===
array
(
))
{
if
(
empty
(
$this
->
_params
))
{
return
$this
->
_sql
;
}
else
{
$params
=
array
();
...
...
framework/db/QueryBuilder.php
View file @
d7df7053
...
...
@@ -722,7 +722,7 @@ class QueryBuilder extends \yii\base\Object
if
(
!
is_array
(
$condition
))
{
return
(
string
)
$condition
;
}
elseif
(
$condition
===
array
(
))
{
}
elseif
(
empty
(
$condition
))
{
return
''
;
}
if
(
isset
(
$condition
[
0
]))
{
// operator format: operator, operand 1, operand 2, ...
...
...
@@ -813,7 +813,7 @@ class QueryBuilder extends \yii\base\Object
$values
=
(
array
)
$values
;
if
(
$values
===
array
()
||
$column
===
array
(
))
{
if
(
empty
(
$values
)
||
empty
(
$column
))
{
return
$operator
===
'IN'
?
'0=1'
:
''
;
}
...
...
@@ -885,7 +885,7 @@ class QueryBuilder extends \yii\base\Object
$values
=
(
array
)
$values
;
if
(
$values
===
array
(
))
{
if
(
empty
(
$values
))
{
return
$operator
===
'LIKE'
||
$operator
===
'OR LIKE'
?
'0=1'
:
''
;
}
...
...
framework/helpers/base/Json.php
View file @
d7df7053
...
...
@@ -34,7 +34,7 @@ class Json
$expressions
=
array
();
$value
=
static
::
processData
(
$value
,
$expressions
);
$json
=
json_encode
(
$value
,
$options
);
return
$expressions
===
array
(
)
?
$json
:
strtr
(
$json
,
$expressions
);
return
empty
(
$expressions
)
?
$json
:
strtr
(
$json
,
$expressions
);
}
/**
...
...
framework/i18n/I18N.php
View file @
d7df7053
...
...
@@ -109,7 +109,7 @@ class I18N extends Component
unset
(
$params
[
0
]);
}
return
$params
===
array
(
)
?
$message
:
strtr
(
$message
,
$params
);
return
empty
(
$params
)
?
$message
:
strtr
(
$message
,
$params
);
}
/**
...
...
framework/validators/FileValidator.php
View file @
d7df7053
...
...
@@ -116,7 +116,7 @@ class FileValidator extends Validator
}
if
(
!
is_array
(
$this
->
types
))
{
$this
->
types
=
preg_split
(
'/[\s,]+/'
,
strtolower
(
$this
->
types
),
-
1
,
PREG_SPLIT_NO_EMPTY
);
}
}
}
/**
...
...
@@ -138,8 +138,8 @@ class FileValidator extends Validator
}
}
$object
->
$attribute
=
array_values
(
$files
);
if
(
$files
===
array
(
))
{
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
if
(
empty
(
$files
))
{
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
}
if
(
count
(
$files
)
>
$this
->
maxFiles
)
{
$this
->
addError
(
$object
,
$attribute
,
$this
->
tooMany
,
array
(
'{attribute}'
=>
$attribute
,
'{limit}'
=>
$this
->
maxFiles
));
...
...
@@ -153,7 +153,7 @@ class FileValidator extends Validator
if
(
$file
instanceof
UploadedFile
&&
$file
->
getError
()
!=
UPLOAD_ERR_NO_FILE
)
{
$this
->
validateFile
(
$object
,
$attribute
,
$file
);
}
else
{
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
$this
->
addError
(
$object
,
$attribute
,
$this
->
uploadRequired
);
}
}
}
...
...
framework/validators/Validator.php
View file @
d7df7053
...
...
@@ -262,7 +262,6 @@ abstract class Validator extends Component
*/
public
function
isEmpty
(
$value
,
$trim
=
false
)
{
return
$value
===
null
||
$value
===
array
()
||
$value
===
''
||
$trim
&&
is_scalar
(
$value
)
&&
trim
(
$value
)
===
''
;
return
$value
===
null
||
empty
(
$value
)
||
$value
===
''
||
$trim
&&
is_scalar
(
$value
)
&&
trim
(
$value
)
===
''
;
}
}
framework/web/Sort.php
View file @
d7df7053
...
...
@@ -251,7 +251,7 @@ class Sort extends \yii\base\Object
}
}
}
if
(
$this
->
_attributeOrders
===
array
(
)
&&
is_array
(
$this
->
defaults
))
{
if
(
empty
(
$this
->
_attributeOrders
)
&&
is_array
(
$this
->
defaults
))
{
$this
->
_attributeOrders
=
$this
->
defaults
;
}
}
...
...
framework/web/UrlManager.php
View file @
d7df7053
...
...
@@ -90,7 +90,7 @@ class UrlManager extends Component
*/
protected
function
compileRules
()
{
if
(
!
$this
->
enablePrettyUrl
||
$this
->
rules
===
array
(
))
{
if
(
!
$this
->
enablePrettyUrl
||
empty
(
$this
->
rules
))
{
return
;
}
if
(
is_string
(
$this
->
cache
))
{
...
...
framework/widgets/FragmentCache.php
View file @
d7df7053
...
...
@@ -107,7 +107,7 @@ class FragmentCache extends Widget
$data
=
array
(
$content
,
$this
->
dynamicPlaceholders
);
$this
->
cache
->
set
(
$this
->
calculateKey
(),
$data
,
$this
->
duration
,
$this
->
dependency
);
if
(
$this
->
view
->
cacheStack
===
array
(
)
&&
!
empty
(
$this
->
dynamicPlaceholders
))
{
if
(
empty
(
$this
->
view
->
cacheStack
)
&&
!
empty
(
$this
->
dynamicPlaceholders
))
{
$content
=
$this
->
updateDynamicContent
(
$content
,
$this
->
dynamicPlaceholders
);
}
echo
$content
;
...
...
@@ -133,7 +133,7 @@ class FragmentCache extends Widget
if
(
is_array
(
$data
)
&&
count
(
$data
)
===
2
)
{
list
(
$content
,
$placeholders
)
=
$data
;
if
(
is_array
(
$placeholders
)
&&
count
(
$placeholders
)
>
0
)
{
if
(
$this
->
view
->
cacheStack
===
array
(
))
{
if
(
empty
(
$this
->
view
->
cacheStack
))
{
// outermost cache: replace placeholder with dynamic content
$content
=
$this
->
updateDynamicContent
(
$content
,
$placeholders
);
}
...
...
@@ -171,4 +171,4 @@ class FragmentCache extends Widget
}
return
$this
->
cache
->
buildKey
(
$factors
);
}
}
}
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