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
c1445871
Commit
c1445871
authored
Apr 16, 2014
by
Thiago Talma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correction of many errors code inspection.
Adjustments code according to the standards. Adding missing PHPDoc comment.
parent
664d2aa0
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
128 additions
and
61 deletions
+128
-61
ArrayAccessTrait.php
framework/base/ArrayAccessTrait.php
+2
-0
ErrorHandler.php
framework/base/ErrorHandler.php
+1
-1
Formatter.php
framework/base/Formatter.php
+1
-3
Theme.php
framework/base/Theme.php
+1
-0
MemCache.php
framework/caching/MemCache.php
+17
-6
CaptchaAction.php
framework/captcha/CaptchaAction.php
+8
-4
FixtureController.php
framework/console/controllers/FixtureController.php
+6
-4
MessageController.php
framework/console/controllers/MessageController.php
+5
-2
MigrateController.php
framework/console/controllers/MigrateController.php
+2
-1
ActiveQueryTrait.php
framework/db/ActiveQueryTrait.php
+1
-0
ActiveRelationTrait.php
framework/db/ActiveRelationTrait.php
+12
-0
BaseActiveRecord.php
framework/db/BaseActiveRecord.php
+4
-0
Connection.php
framework/db/Connection.php
+5
-2
Container.php
framework/di/Container.php
+1
-1
DataColumn.php
framework/grid/DataColumn.php
+1
-2
BaseConsole.php
framework/helpers/BaseConsole.php
+1
-0
BaseInflector.php
framework/helpers/BaseInflector.php
+8
-4
MessageFormatter.php
framework/i18n/MessageFormatter.php
+2
-1
SyslogTarget.php
framework/log/SyslogTarget.php
+2
-2
CompareValidator.php
framework/validators/CompareValidator.php
+18
-9
error.php
framework/views/errorHandler/error.php
+15
-4
JsonResponseFormatter.php
framework/web/JsonResponseFormatter.php
+12
-12
ViewAction.php
framework/web/ViewAction.php
+1
-1
yii
framework/yii
+2
-2
No files found.
framework/base/ArrayAccessTrait.php
View file @
c1445871
...
...
@@ -15,6 +15,8 @@ namespace yii\base;
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*
* @property array $data
*/
trait
ArrayAccessTrait
{
...
...
framework/base/ErrorHandler.php
View file @
c1445871
...
...
@@ -176,7 +176,7 @@ abstract class ErrorHandler extends Component
* Renders the exception.
* @param \Exception $exception the exception to be rendered.
*/
protected
abstract
function
renderException
(
$exception
);
abstract
protected
function
renderException
(
$exception
);
/**
* Logs the given exception
...
...
framework/base/Formatter.php
View file @
c1445871
...
...
@@ -184,9 +184,7 @@ class Formatter extends Component
return
$this
->
nullDisplay
;
}
return
str_replace
(
'<p></p>'
,
''
,
'<p>'
.
preg_replace
(
'/[\r\n]{2,}/'
,
"</p>
\n
<p>"
,
Html
::
encode
(
$value
))
.
'</p>'
);
return
str_replace
(
'<p></p>'
,
''
,
'<p>'
.
preg_replace
(
'/[\r\n]{2,}/'
,
"</p>
\n
<p>"
,
Html
::
encode
(
$value
))
.
'</p>'
);
}
/**
...
...
framework/base/Theme.php
View file @
c1445871
...
...
@@ -181,6 +181,7 @@ class Theme extends Component
* Converts a relative file path into an absolute one using [[basePath]].
* @param string $path the relative file path to be converted.
* @return string the absolute file path
* @throws InvalidConfigException if [[baseUrl]] is not set
*/
public
function
getPath
(
$path
)
{
...
...
framework/caching/MemCache.php
View file @
c1445871
...
...
@@ -107,15 +107,26 @@ class MemCache extends Cache
$timeout
=
(
int
)
(
$server
->
timeout
/
1000
)
+
((
$server
->
timeout
%
1000
>
0
)
?
1
:
0
);
if
(
$paramCount
===
9
)
{
$cache
->
addServer
(
$server
->
host
,
$server
->
port
,
$server
->
persistent
,
$server
->
weight
,
$timeout
,
$server
->
retryInterval
,
$server
->
status
,
$server
->
failureCallback
,
$server
->
timeout
$server
->
host
,
$server
->
port
,
$server
->
persistent
,
$server
->
weight
,
$timeout
,
$server
->
retryInterval
,
$server
->
status
,
$server
->
failureCallback
,
$server
->
timeout
);
}
else
{
$cache
->
addServer
(
$server
->
host
,
$server
->
port
,
$server
->
persistent
,
$server
->
weight
,
$timeout
,
$server
->
retryInterval
,
$server
->
status
,
$server
->
failureCallback
$server
->
host
,
$server
->
port
,
$server
->
persistent
,
$server
->
weight
,
$timeout
,
$server
->
retryInterval
,
$server
->
status
,
$server
->
failureCallback
);
}
}
...
...
framework/captcha/CaptchaAction.php
View file @
c1445871
...
...
@@ -252,10 +252,12 @@ class CaptchaAction extends Action
{
$image
=
imagecreatetruecolor
(
$this
->
width
,
$this
->
height
);
$backColor
=
imagecolorallocate
(
$image
,
$backColor
=
imagecolorallocate
(
$image
,
(
int
)
(
$this
->
backColor
%
0x1000000
/
0x10000
),
(
int
)
(
$this
->
backColor
%
0x10000
/
0x100
),
$this
->
backColor
%
0x100
);
$this
->
backColor
%
0x100
);
imagefilledrectangle
(
$image
,
0
,
0
,
$this
->
width
,
$this
->
height
,
$backColor
);
imagecolordeallocate
(
$image
,
$backColor
);
...
...
@@ -263,10 +265,12 @@ class CaptchaAction extends Action
imagecolortransparent
(
$image
,
$backColor
);
}
$foreColor
=
imagecolorallocate
(
$image
,
$foreColor
=
imagecolorallocate
(
$image
,
(
int
)
(
$this
->
foreColor
%
0x1000000
/
0x10000
),
(
int
)
(
$this
->
foreColor
%
0x10000
/
0x100
),
$this
->
foreColor
%
0x100
);
$this
->
foreColor
%
0x100
);
$length
=
strlen
(
$code
);
$box
=
imagettfbbox
(
30
,
0
,
$this
->
fontFile
,
$code
);
...
...
framework/console/controllers/FixtureController.php
View file @
c1445871
...
...
@@ -89,8 +89,9 @@ class FixtureController extends Controller
}
if
(
!
$foundFixtures
)
{
throw
new
Exception
(
"No files were found by name:
\"
"
.
implode
(
', '
,
$fixtures
)
.
"
\"
.
\n
"
.
"Check that files with these name exists, under fixtures path:
\n\"
"
.
$this
->
getFixturePath
()
.
"
\"
."
throw
new
Exception
(
"No files were found by name:
\"
"
.
implode
(
', '
,
$fixtures
)
.
"
\"
.
\n
"
.
"Check that files with these name exists, under fixtures path:
\n\"
"
.
$this
->
getFixturePath
()
.
"
\"
."
);
}
...
...
@@ -131,8 +132,9 @@ class FixtureController extends Controller
}
if
(
!
$foundFixtures
)
{
throw
new
Exception
(
"No files were found by name:
\"
"
.
implode
(
', '
,
$fixtures
)
.
"
\"
.
\n
"
.
"Check that fixtures with these name exists, under fixtures path:
\n\"
"
.
$this
->
getFixturePath
()
.
"
\"
."
throw
new
Exception
(
"No files were found by name:
\"
"
.
implode
(
', '
,
$fixtures
)
.
"
\"
.
\n
"
.
"Check that fixtures with these name exists, under fixtures path:
\n\"
"
.
$this
->
getFixturePath
()
.
"
\"
."
);
}
...
...
framework/console/controllers/MessageController.php
View file @
c1445871
...
...
@@ -221,7 +221,7 @@ class MessageController extends Controller
}
else
{
$last_id
=
$db
->
getLastInsertID
();
$db
->
createCommand
()
->
update
(
->
update
(
$sourceMessageTable
,
[
'message'
=>
new
\yii\db\Expression
(
"CONCAT('@@',message,'@@')"
)],
[
'in'
,
'id'
,
$obsolete
]
...
...
@@ -253,7 +253,10 @@ class MessageController extends Controller
foreach
(
$translator
as
$currentTranslator
)
{
$n
=
preg_match_all
(
'/\b'
.
$currentTranslator
.
'\s*\(\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*,\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\s*[,\)]/s'
,
$subject
,
$matches
,
PREG_SET_ORDER
);
$subject
,
$matches
,
PREG_SET_ORDER
);
for
(
$i
=
0
;
$i
<
$n
;
++
$i
)
{
if
((
$pos
=
strpos
(
$matches
[
$i
][
1
],
'.'
))
!==
false
)
{
$category
=
substr
(
$matches
[
$i
][
1
],
$pos
+
1
,
-
1
);
...
...
framework/console/controllers/MigrateController.php
View file @
c1445871
...
...
@@ -95,7 +95,8 @@ class MigrateController extends Controller
*/
public
function
options
(
$actionId
)
{
return
array_merge
(
parent
::
options
(
$actionId
),
return
array_merge
(
parent
::
options
(
$actionId
),
[
'migrationPath'
,
'migrationTable'
,
'db'
],
// global for all actions
(
$actionId
==
'create'
)
?
[
'templateFile'
]
:
[]
// action create
);
...
...
framework/db/ActiveQueryTrait.php
View file @
c1445871
...
...
@@ -159,6 +159,7 @@ trait ActiveQueryTrait
{
$primaryModel
=
new
$this
->
modelClass
;
$relations
=
$this
->
normalizeRelations
(
$primaryModel
,
$with
);
/** @var ActiveQuery $relation */
foreach
(
$relations
as
$name
=>
$relation
)
{
if
(
$relation
->
asArray
===
null
)
{
// inherit asArray from primary query
...
...
framework/db/ActiveRelationTrait.php
View file @
c1445871
...
...
@@ -16,6 +16,10 @@ use yii\base\InvalidParamException;
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*
* @method ActiveRelationTrait one()
* @method ActiveRelationTrait[] all()
* @property ActiveRecord $modelClass
*/
trait
ActiveRelationTrait
{
...
...
@@ -248,12 +252,20 @@ trait ActiveRelationTrait
}
}
/**
* @param ActiveRecordInterface[] $primaryModels primary models
* @param ActiveRecordInterface[] $models models
* @param string $primaryName the primary relation name
* @param string $name the relation name
* @return null
*/
private
function
populateInverseRelation
(
&
$primaryModels
,
$models
,
$primaryName
,
$name
)
{
if
(
empty
(
$models
)
||
empty
(
$primaryModels
))
{
return
;
}
$model
=
reset
(
$models
);
/** @var ActiveQueryInterface|ActiveQuery $relation */
$relation
=
$model
instanceof
ActiveRecordInterface
?
$model
->
getRelation
(
$name
)
:
(
new
$this
->
modelClass
)
->
getRelation
(
$name
);
if
(
$relation
->
multiple
)
{
...
...
framework/db/BaseActiveRecord.php
View file @
c1445871
...
...
@@ -145,6 +145,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* @param string|array $condition the conditions that will be put in the WHERE part of the UPDATE SQL.
* Please refer to [[Query::where()]] on how to specify this parameter.
* @return integer the number of rows updated
* @throws NotSupportedException if not overrided
*/
public
static
function
updateAll
(
$attributes
,
$condition
=
''
)
{
...
...
@@ -164,6 +165,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* @param string|array $condition the conditions that will be put in the WHERE part of the UPDATE SQL.
* Please refer to [[Query::where()]] on how to specify this parameter.
* @return integer the number of rows updated
* @throws NotSupportedException if not overrided
*/
public
static
function
updateAllCounters
(
$counters
,
$condition
=
''
)
{
...
...
@@ -184,6 +186,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* Please refer to [[Query::where()]] on how to specify this parameter.
* @param array $params the parameters (name => value) to be bound to the query.
* @return integer the number of rows deleted
* @throws NotSupportedException if not overrided
*/
public
static
function
deleteAll
(
$condition
=
''
,
$params
=
[])
{
...
...
@@ -908,6 +911,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*/
public
function
refresh
()
{
/** @var ActiveQuery $record */
$record
=
$this
->
findOne
(
$this
->
getPrimaryKey
(
true
));
if
(
$record
===
null
)
{
return
false
;
...
...
framework/db/Connection.php
View file @
c1445871
...
...
@@ -528,14 +528,17 @@ class Connection extends Component
*/
public
function
quoteSql
(
$sql
)
{
return
preg_replace_callback
(
'/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/'
,
return
preg_replace_callback
(
'/(\\{\\{(%?[\w\-\. ]+%?)\\}\\}|\\[\\[([\w\-\. ]+)\\]\\])/'
,
function
(
$matches
)
{
if
(
isset
(
$matches
[
3
]))
{
return
$this
->
quoteColumnName
(
$matches
[
3
]);
}
else
{
return
str_replace
(
'%'
,
$this
->
tablePrefix
,
$this
->
quoteTableName
(
$matches
[
2
]));
}
},
$sql
);
},
$sql
);
}
/**
...
...
framework/di/Container.php
View file @
c1445871
...
...
@@ -263,7 +263,7 @@ class Container extends Component
*/
public
function
setSingleton
(
$class
,
$definition
=
[],
array
$params
=
[])
{
$this
->
_definitions
[
$class
]
=
$this
->
normalizeDefinition
(
$class
,
$definition
);
;
$this
->
_definitions
[
$class
]
=
$this
->
normalizeDefinition
(
$class
,
$definition
);
$this
->
_params
[
$class
]
=
$params
;
$this
->
_singletons
[
$class
]
=
null
;
return
$this
;
...
...
framework/grid/DataColumn.php
View file @
c1445871
...
...
@@ -142,8 +142,7 @@ class DataColumn extends Column
if
(
is_string
(
$this
->
filter
))
{
return
$this
->
filter
;
}
elseif
(
$this
->
filter
!==
false
&&
$this
->
grid
->
filterModel
instanceof
Model
&&
$this
->
attribute
!==
null
&&
$this
->
grid
->
filterModel
->
isAttributeActive
(
$this
->
attribute
))
{
$this
->
attribute
!==
null
&&
$this
->
grid
->
filterModel
->
isAttributeActive
(
$this
->
attribute
))
{
if
(
is_array
(
$this
->
filter
))
{
$options
=
array_merge
([
'prompt'
=>
''
],
$this
->
filterInputOptions
);
return
Html
::
activeDropDownList
(
$this
->
grid
->
filterModel
,
$this
->
attribute
,
$this
->
filter
,
$options
);
...
...
framework/helpers/BaseConsole.php
View file @
c1445871
...
...
@@ -341,6 +341,7 @@ class BaseConsole
function
(
$ansi
)
use
(
&
$tags
)
{
$styleA
=
[];
foreach
(
explode
(
';'
,
$ansi
)
as
$controlCode
)
{
$style
=
[];
switch
(
$controlCode
)
{
case
self
::
FG_BLACK
:
$style
=
[
'color'
=>
'#000000'
];
...
...
framework/helpers/BaseInflector.php
View file @
c1445871
...
...
@@ -500,10 +500,14 @@ class BaseInflector
return
$number
.
'th'
;
}
switch
(
$number
%
10
)
{
case
1
:
return
$number
.
'st'
;
case
2
:
return
$number
.
'nd'
;
case
3
:
return
$number
.
'rd'
;
default
:
return
$number
.
'th'
;
case
1
:
return
$number
.
'st'
;
case
2
:
return
$number
.
'nd'
;
case
3
:
return
$number
.
'rd'
;
default
:
return
$number
.
'th'
;
}
}
}
framework/i18n/MessageFormatter.php
View file @
c1445871
...
...
@@ -344,7 +344,8 @@ class MessageFormatter extends Component
return
$arg
;
}
throw
new
NotSupportedException
(
"Message format 'number' is only supported for integer values. You have to install PHP intl extension to use this feature."
);
case
'none'
:
return
$arg
;
case
'none'
:
return
$arg
;
case
'select'
:
/* http://icu-project.org/apiref/icu4c/classicu_1_1SelectFormat.html
selectStyle = (selector '{' message '}')+
...
...
framework/log/SyslogTarget.php
View file @
c1445871
...
...
@@ -29,7 +29,7 @@ class SyslogTarget extends Target
/**
* @var array syslog levels
*/
private
$syslogLevels
=
[
private
$
_
syslogLevels
=
[
Logger
::
LEVEL_TRACE
=>
LOG_DEBUG
,
Logger
::
LEVEL_PROFILE_BEGIN
=>
LOG_DEBUG
,
Logger
::
LEVEL_PROFILE_END
=>
LOG_DEBUG
,
...
...
@@ -45,7 +45,7 @@ class SyslogTarget extends Target
{
openlog
(
$this
->
identity
,
LOG_ODELAY
|
LOG_PID
,
$this
->
facility
);
foreach
(
$this
->
messages
as
$message
)
{
syslog
(
$this
->
syslogLevels
[
$message
[
1
]],
$this
->
formatMessage
(
$message
));
syslog
(
$this
->
_
syslogLevels
[
$message
[
1
]],
$this
->
formatMessage
(
$message
));
}
closelog
();
}
...
...
framework/validators/CompareValidator.php
View file @
c1445871
...
...
@@ -161,15 +161,24 @@ class CompareValidator extends Validator
protected
function
compareValues
(
$operator
,
$value
,
$compareValue
)
{
switch
(
$operator
)
{
case
'=='
:
return
$value
==
$compareValue
;
case
'==='
:
return
$value
===
$compareValue
;
case
'!='
:
return
$value
!=
$compareValue
;
case
'!=='
:
return
$value
!==
$compareValue
;
case
'>'
:
return
$value
>
$compareValue
;
case
'>='
:
return
$value
>=
$compareValue
;
case
'<'
:
return
$value
<
$compareValue
;
case
'<='
:
return
$value
<=
$compareValue
;
default
:
return
false
;
case
'=='
:
return
$value
==
$compareValue
;
case
'==='
:
return
$value
===
$compareValue
;
case
'!='
:
return
$value
!=
$compareValue
;
case
'!=='
:
return
$value
!==
$compareValue
;
case
'>'
:
return
$value
>
$compareValue
;
case
'>='
:
return
$value
>=
$compareValue
;
case
'<'
:
return
$value
<
$compareValue
;
case
'<='
:
return
$value
<=
$compareValue
;
default
:
return
false
;
}
}
...
...
framework/views/errorHandler/error.php
View file @
c1445871
<?php
/**
* @var \Exception $exception
* @var \
yii\base\
Exception $exception
* @var \yii\web\ErrorHandler $handler
*/
if
(
$exception
instanceof
\yii\web\HttpException
)
{
...
...
@@ -22,8 +22,11 @@ if ($exception instanceof \yii\base\UserException) {
}
else
{
$message
=
'An internal server error occurred.'
;
}
if
(
method_exists
(
$this
,
'beginPage'
))
{
$this
->
beginPage
();
}
?>
<?php
if
(
method_exists
(
$this
,
'beginPage'
))
$this
->
beginPage
();
?>
<!DOCTYPE html>
<html>
<head>
...
...
@@ -80,7 +83,14 @@ if ($exception instanceof \yii\base\UserException) {
<div
class=
"version"
>
<?=
date
(
'Y-m-d H:i:s'
,
time
())
?>
</div>
<?php
if
(
method_exists
(
$this
,
'endBody'
))
$this
->
endBody
();
// to allow injecting code into body (mostly by Yii Debug Toolbar) ?>
<?php
if
(
method_exists
(
$this
,
'endBody'
))
{
$this
->
endBody
();
// to allow injecting code into body (mostly by Yii Debug Toolbar)
}
?>
</body>
</html>
<?
php
if
(
method_exists
(
$this
,
'endPage'
))
$this
->
endPage
();
?>
<?php
if
(
method_exists
(
$this
,
'endPage'
))
{
$this
->
endPage
();
}
\ No newline at end of file
framework/web/JsonResponseFormatter.php
View file @
c1445871
...
...
@@ -28,18 +28,18 @@ class JsonResponseFormatter extends Component implements ResponseFormatterInterf
*/
public
$useJsonp
=
false
;
/**
* Formats the specified response.
* @param Response $response the response to be formatted.
*/
public
function
format
(
$response
)
{
if
(
$this
->
useJsonp
)
{
$this
->
formatJsonp
(
$response
);
}
else
{
$this
->
formatJson
(
$response
);
}
}
/**
* Formats the specified response.
* @param Response $response the response to be formatted.
*/
public
function
format
(
$response
)
{
if
(
$this
->
useJsonp
)
{
$this
->
formatJsonp
(
$response
);
}
else
{
$this
->
formatJson
(
$response
);
}
}
/**
* Formats response data in JSON format.
...
...
framework/web/ViewAction.php
View file @
c1445871
...
...
@@ -70,7 +70,7 @@ class ViewAction extends Action
$viewName
=
$this
->
resolveViewName
();
$controllerLayout
=
null
;
if
(
$this
->
layout
!==
null
)
{
if
(
$this
->
layout
!==
null
)
{
$controllerLayout
=
$this
->
controller
->
layout
;
$this
->
controller
->
layout
=
$this
->
layout
;
}
...
...
framework/yii
View file @
c1445871
...
...
@@ -17,8 +17,8 @@ defined('STDOUT') or define('STDOUT', fopen('php://stdout', 'w'));
require
(
__DIR__
.
'/Yii.php'
);
$application
=
new
yii\console\Application
([
'id'
=>
'yii-console'
,
'basePath'
=>
__DIR__
.
'/console'
,
'id'
=>
'yii-console'
,
'basePath'
=>
__DIR__
.
'/console'
,
]);
$exitCode
=
$application
->
run
();
exit
(
$exitCode
);
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