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
1c414caa
Commit
1c414caa
authored
Jul 30, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved checks where substr_compare is used, replaced more substr + comapre…
Improved checks where substr_compare is used, replaced more substr + comapre cases with substr_compare
parent
ca9d4867
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
49 additions
and
37 deletions
+49
-37
PhpDocController.php
build/controllers/PhpDocController.php
+22
-14
TypeDoc.php
extensions/apidoc/models/TypeDoc.php
+1
-1
BaseRenderer.php
extensions/apidoc/renderers/BaseRenderer.php
+1
-1
seeAlso.php
extensions/apidoc/templates/html/views/seeAlso.php
+5
-3
Generator.php
extensions/gii/generators/crud/Generator.php
+1
-1
Generator.php
extensions/gii/generators/model/Generator.php
+4
-4
Generator.php
extensions/gii/generators/module/Generator.php
+1
-1
Generator.php
extensions/mongodb/gii/model/Generator.php
+1
-1
Generator.php
extensions/sphinx/gii/model/Generator.php
+3
-3
HelpController.php
framework/console/controllers/HelpController.php
+1
-1
MessageController.php
framework/console/controllers/MessageController.php
+2
-2
BaseHtml.php
framework/helpers/BaseHtml.php
+2
-2
GettextMoFile.php
framework/i18n/GettextMoFile.php
+2
-1
MessageFormatter.php
framework/i18n/MessageFormatter.php
+2
-1
Target.php
framework/log/Target.php
+1
-1
No files found.
build/controllers/PhpDocController.php
View file @
1c414caa
...
...
@@ -170,12 +170,15 @@ class PhpDocController extends Controller
$namespaceLine
=
''
;
$contentAfterNamespace
=
false
;
foreach
(
$lines
as
$i
=>
$line
)
{
if
(
substr
(
trim
(
$line
),
0
,
9
)
===
'namespace'
)
{
$namespace
=
$i
;
$namespaceLine
=
trim
(
$line
);
}
elseif
(
$namespace
!==
false
&&
trim
(
$line
)
!==
''
)
{
$contentAfterNamespace
=
$i
;
break
;
$line
=
trim
(
$line
);
if
(
!
empty
(
$line
))
{
if
(
substr_compare
(
$line
,
'namespace'
,
0
,
9
)
===
0
)
{
$namespace
=
$i
;
$namespaceLine
=
$line
;
}
elseif
(
$namespace
!==
false
)
{
$contentAfterNamespace
=
$i
;
break
;
}
}
}
...
...
@@ -275,14 +278,18 @@ class PhpDocController extends Controller
// TODO move these checks to different action
$lines
=
explode
(
"
\n
"
,
$newDoc
);
if
(
trim
(
$lines
[
1
])
==
'*'
||
substr
(
trim
(
$lines
[
1
]),
0
,
3
)
==
'* @'
)
{
$firstLine
=
trim
(
$lines
[
1
]);
if
(
$firstLine
===
'*'
||
(
!
empty
(
$firstLine
)
&&
substr_compare
(
$firstLine
,
'* @'
,
0
,
3
)
===
0
))
{
$this
->
stderr
(
"[WARN] Class
$className
has no short description.
\n
"
,
Console
::
FG_YELLOW
,
Console
::
BOLD
);
}
foreach
(
$lines
as
$line
)
{
if
(
substr
(
trim
(
$line
),
0
,
9
)
==
'* @since '
)
{
$seenSince
=
true
;
}
elseif
(
substr
(
trim
(
$line
),
0
,
10
)
==
'* @author '
)
{
$seenAuthor
=
true
;
$line
=
trim
(
$line
);
if
(
!
empty
(
$line
))
{
if
(
substr_compare
(
$line
,
'* @since '
,
0
,
9
)
===
0
)
{
$seenSince
=
true
;
}
elseif
(
substr_compare
(
$line
,
'* @author '
,
0
,
10
)
===
0
)
{
$seenAuthor
=
true
;
}
}
}
...
...
@@ -350,13 +357,14 @@ class PhpDocController extends Controller
$propertyPart
=
false
;
$propertyPosition
=
false
;
foreach
(
$lines
as
$i
=>
$line
)
{
if
(
substr
(
trim
(
$line
),
0
,
12
)
==
'* @property '
)
{
$line
=
trim
(
$line
);
if
(
!
empty
(
$line
)
&&
substr_compare
(
$line
,
'* @property '
,
0
,
12
)
===
0
)
{
$propertyPart
=
true
;
}
elseif
(
$propertyPart
&&
trim
(
$line
)
==
'*'
)
{
}
elseif
(
$propertyPart
&&
$line
==
'*'
)
{
$propertyPosition
=
$i
;
$propertyPart
=
false
;
}
if
(
substr
(
trim
(
$line
),
0
,
10
)
==
'* @author '
&&
$propertyPosition
===
false
)
{
if
(
!
empty
(
$line
)
&&
substr_compare
(
$line
,
'* @author '
,
0
,
10
)
===
0
&&
$propertyPosition
===
false
)
{
$propertyPosition
=
$i
-
1
;
$propertyPart
=
false
;
}
...
...
extensions/apidoc/models/TypeDoc.php
View file @
1c414caa
...
...
@@ -46,7 +46,7 @@ class TypeDoc extends BaseDoc
}
}
}
if
(
substr_compare
(
$subjectName
,
'()'
,
-
2
,
2
)
===
0
)
{
if
(
!
empty
(
$subjectName
)
&&
substr_compare
(
$subjectName
,
'()'
,
-
2
,
2
)
===
0
)
{
return
null
;
}
if
(
$this
->
properties
===
null
)
{
...
...
extensions/apidoc/renderers/BaseRenderer.php
View file @
1c414caa
...
...
@@ -72,7 +72,7 @@ abstract class BaseRenderer extends Component
foreach
(
$types
as
$type
)
{
$postfix
=
''
;
if
(
is_string
(
$type
))
{
if
(
substr_compare
(
$type
,
'[]'
,
-
2
,
2
)
===
0
)
{
if
(
!
empty
(
$type
)
&&
substr_compare
(
$type
,
'[]'
,
-
2
,
2
)
===
0
)
{
$postfix
=
'[]'
;
$type
=
substr
(
$type
,
0
,
-
2
);
}
...
...
extensions/apidoc/templates/html/views/seeAlso.php
View file @
1c414caa
...
...
@@ -23,10 +23,12 @@ if (empty($see)) {
}
else
{
echo
'<p>See also:</p><ul>'
;
foreach
(
$see
as
$ref
)
{
if
(
substr_compare
(
$ref
,
'>'
,
-
1
,
1
))
{
$ref
.=
'.'
;
if
(
!
empty
(
$ref
))
{
if
(
substr_compare
(
$ref
,
'>'
,
-
1
,
1
))
{
$ref
.=
'.'
;
}
echo
"<li>
$ref
</li>"
;
}
echo
"<li>
$ref
</li>"
;
}
echo
'</ul>'
;
}
extensions/gii/generators/crud/Generator.php
View file @
1c414caa
...
...
@@ -373,7 +373,7 @@ class Generator extends \yii\gii\Generator
$labels
[
$name
]
=
'ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$name
);
if
(
strcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
if
(
!
empty
(
$label
)
&&
substr_compare
(
$label
,
' id'
,
-
3
,
null
,
true
)
===
0
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
$labels
[
$name
]
=
$label
;
...
...
extensions/gii/generators/model/Generator.php
View file @
1c414caa
...
...
@@ -196,7 +196,7 @@ class Generator extends \yii\gii\Generator
$labels
[
$column
->
name
]
=
'ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$column
->
name
);
if
(
strcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
if
(
!
empty
(
$label
)
&&
substr_compare
(
$label
,
' id'
,
-
3
,
null
,
true
)
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
$labels
[
$column
->
name
]
=
$label
;
...
...
@@ -428,7 +428,7 @@ class Generator extends \yii\gii\Generator
*/
protected
function
generateRelationName
(
$relations
,
$className
,
$table
,
$key
,
$multiple
)
{
if
(
strcasecmp
(
substr
(
$key
,
-
2
),
'id'
)
===
0
&&
strcasecmp
(
$key
,
'id'
))
{
if
(
!
empty
(
$key
)
&&
substr_compare
(
$key
,
'id'
,
-
2
,
null
,
true
)
===
0
&&
strcasecmp
(
$key
,
'id'
))
{
$key
=
rtrim
(
substr
(
$key
,
0
,
-
2
),
'_'
);
}
if
(
$multiple
)
{
...
...
@@ -478,7 +478,7 @@ class Generator extends \yii\gii\Generator
if
(
$this
->
isReservedKeyword
(
$this
->
modelClass
))
{
$this
->
addError
(
'modelClass'
,
'Class name cannot be a reserved PHP keyword.'
);
}
if
(
substr_compare
(
$this
->
tableName
,
'*'
,
-
1
)
&&
$this
->
modelClass
==
''
)
{
if
(
(
empty
(
$this
->
tableName
)
||
substr_compare
(
$this
->
tableName
,
'*'
,
-
1
)
)
&&
$this
->
modelClass
==
''
)
{
$this
->
addError
(
'modelClass'
,
'Model Class cannot be blank if table name does not end with asterisk.'
);
}
}
...
...
@@ -488,7 +488,7 @@ class Generator extends \yii\gii\Generator
*/
public
function
validateTableName
()
{
if
(
strpos
(
$this
->
tableName
,
'*'
)
!==
false
&&
substr
(
$this
->
tableName
,
-
1
)
!==
'*'
)
{
if
(
strpos
(
$this
->
tableName
,
'*'
)
!==
false
&&
substr
_compare
(
$this
->
tableName
,
'*'
,
-
1
)
)
{
$this
->
addError
(
'tableName'
,
'Asterisk is only allowed as the last character.'
);
return
;
...
...
extensions/gii/generators/module/Generator.php
View file @
1c414caa
...
...
@@ -146,7 +146,7 @@ EOD;
if
(
strpos
(
$this
->
moduleClass
,
'\\'
)
===
false
||
Yii
::
getAlias
(
'@'
.
str_replace
(
'\\'
,
'/'
,
$this
->
moduleClass
),
false
)
===
false
)
{
$this
->
addError
(
'moduleClass'
,
'Module class must be properly namespaced.'
);
}
if
(
substr_compare
(
$this
->
moduleClass
,
'\\'
,
-
1
,
1
)
===
0
)
{
if
(
empty
(
$this
->
moduleClass
)
||
substr_compare
(
$this
->
moduleClass
,
'\\'
,
-
1
,
1
)
===
0
)
{
$this
->
addError
(
'moduleClass'
,
'Module class name must not be empty. Please enter a fully qualified class name. e.g. "app\\modules\\admin\\Module".'
);
}
}
...
...
extensions/mongodb/gii/model/Generator.php
View file @
1c414caa
...
...
@@ -182,7 +182,7 @@ class Generator extends \yii\gii\Generator
$label
=
'ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$attribute
);
if
(
s
trcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
if
(
s
ubstr_compare
(
$label
,
' id'
,
-
3
,
null
,
true
)
===
0
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
}
...
...
extensions/sphinx/gii/model/Generator.php
View file @
1c414caa
...
...
@@ -180,7 +180,7 @@ class Generator extends \yii\gii\Generator
$labels
[
$column
->
name
]
=
'ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$column
->
name
);
if
(
s
trcasecmp
(
substr
(
$label
,
-
3
),
' id'
)
===
0
)
{
if
(
s
ubstr_compare
(
$label
,
' id'
,
-
3
,
null
,
true
)
===
0
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
$labels
[
$column
->
name
]
=
$label
;
...
...
@@ -266,7 +266,7 @@ class Generator extends \yii\gii\Generator
if
(
$this
->
isReservedKeyword
(
$this
->
modelClass
))
{
$this
->
addError
(
'modelClass'
,
'Class name cannot be a reserved PHP keyword.'
);
}
if
(
substr_compare
(
$this
->
indexName
,
'*'
,
-
1
)
&&
$this
->
modelClass
==
''
)
{
if
(
(
empty
(
$this
->
indexName
)
||
substr_compare
(
$this
->
indexName
,
'*'
,
-
1
)
)
&&
$this
->
modelClass
==
''
)
{
$this
->
addError
(
'modelClass'
,
'Model Class cannot be blank if table name does not end with asterisk.'
);
}
}
...
...
@@ -276,7 +276,7 @@ class Generator extends \yii\gii\Generator
*/
public
function
validateIndexName
()
{
if
(
strpos
(
$this
->
indexName
,
'*'
)
!==
false
&&
substr
(
$this
->
indexName
,
-
1
)
!==
'*'
)
{
if
(
strpos
(
$this
->
indexName
,
'*'
)
!==
false
&&
substr
_compare
(
$this
->
indexName
,
'*'
,
-
1
)
)
{
$this
->
addError
(
'indexName'
,
'Asterisk is only allowed as the last character.'
);
return
;
...
...
framework/console/controllers/HelpController.php
View file @
1c414caa
...
...
@@ -156,7 +156,7 @@ class HelpController extends Controller
if
(
is_dir
(
$controllerPath
))
{
$files
=
scandir
(
$controllerPath
);
foreach
(
$files
as
$file
)
{
if
(
strcmp
(
substr
(
$file
,
-
14
),
'Controller.php'
)
===
0
)
{
if
(
!
empty
(
$file
)
&&
substr_compare
(
$file
,
'Controller.php'
,
-
14
)
===
0
)
{
$controllerClass
=
$module
->
controllerNamespace
.
'\\'
.
substr
(
basename
(
$file
),
0
,
-
4
);
if
(
$this
->
validateControllerClass
(
$controllerClass
))
{
$commands
[]
=
$prefix
.
Inflector
::
camel2id
(
substr
(
basename
(
$file
),
0
,
-
14
));
...
...
framework/console/controllers/MessageController.php
View file @
1c414caa
...
...
@@ -331,7 +331,7 @@ class MessageController extends Controller
ksort
(
$existingMessages
);
foreach
(
$existingMessages
as
$message
=>
$translation
)
{
if
(
!
isset
(
$merged
[
$message
])
&&
!
isset
(
$todo
[
$message
])
&&
!
$removeUnused
)
{
if
(
mb_strlen
(
$translation
,
Yii
::
$app
->
charset
)
>=
2
&&
substr_compare
(
$translation
,
'@@'
,
0
,
2
)
===
0
&&
substr_compare
(
$translation
,
'@@'
,
-
2
)
===
0
)
{
if
(
!
empty
(
$translation
)
&&
substr_compare
(
$translation
,
'@@'
,
0
,
2
)
===
0
&&
substr_compare
(
$translation
,
'@@'
,
-
2
)
===
0
)
{
$todo
[
$message
]
=
$translation
;
}
else
{
$todo
[
$message
]
=
'@@'
.
$translation
.
'@@'
;
...
...
@@ -445,7 +445,7 @@ EOD;
// add obsolete unused messages
foreach
(
$existingMessages
as
$message
=>
$translation
)
{
if
(
!
isset
(
$merged
[
$category
.
chr
(
4
)
.
$message
])
&&
!
isset
(
$todos
[
$category
.
chr
(
4
)
.
$message
])
&&
!
$removeUnused
)
{
if
(
mb_strlen
(
$translation
,
Yii
::
$app
->
charset
)
>=
2
&&
substr
(
$translation
,
0
,
2
)
===
'@@'
&&
substr
(
$translation
,
-
2
)
===
'@@'
)
{
if
(
!
empty
(
$translation
)
&&
substr
(
$translation
,
0
,
2
)
===
'@@'
&&
substr
(
$translation
,
-
2
)
===
'@@'
)
{
$todos
[
$category
.
chr
(
4
)
.
$message
]
=
$translation
;
}
else
{
$todos
[
$category
.
chr
(
4
)
.
$message
]
=
'@@'
.
$translation
.
'@@'
;
...
...
framework/helpers/BaseHtml.php
View file @
1c414caa
...
...
@@ -797,13 +797,13 @@ class BaseHtml
if
(
!
array_key_exists
(
'size'
,
$options
))
{
$options
[
'size'
]
=
4
;
}
if
(
!
empty
(
$options
[
'multiple'
])
&&
substr
(
$name
,
-
2
)
!==
'[]'
)
{
if
(
!
empty
(
$options
[
'multiple'
])
&&
!
empty
(
$name
)
&&
substr_compare
(
$name
,
'[]'
,
-
2
)
)
{
$name
.=
'[]'
;
}
$options
[
'name'
]
=
$name
;
if
(
isset
(
$options
[
'unselect'
]))
{
// add a hidden field so that if the list box has no option being selected, it still submits a value
if
(
substr_compare
(
$name
,
'[]'
,
-
2
)
===
0
)
{
if
(
!
empty
(
$name
)
&&
substr_compare
(
$name
,
'[]'
,
-
2
)
===
0
)
{
$name
=
substr
(
$name
,
0
,
-
2
);
}
$hidden
=
static
::
hiddenInput
(
$name
,
$options
[
'unselect'
]);
...
...
framework/i18n/GettextMoFile.php
View file @
1c414caa
...
...
@@ -107,7 +107,8 @@ class GettextMoFile extends GettextFile
$id
=
$this
->
readString
(
$fileHandle
,
$sourceLengths
[
$i
],
$sourceOffsets
[
$i
]);
$separatorPosition
=
strpos
(
$id
,
chr
(
4
));
if
((
$context
&&
$separatorPosition
!==
false
&&
substr
(
$id
,
0
,
$separatorPosition
)
===
$context
)
||
if
((
$context
&&
$separatorPosition
!==
false
&&
!
empty
(
$id
)
&&
substr_compare
(
$id
,
$context
,
0
,
$separatorPosition
)
===
0
)
||
(
!
$context
&&
$separatorPosition
===
false
))
{
if
(
$separatorPosition
!==
false
)
{
$id
=
substr
(
$id
,
$separatorPosition
+
1
);
...
...
framework/i18n/MessageFormatter.php
View file @
1c414caa
...
...
@@ -390,7 +390,8 @@ class MessageFormatter extends Component
return
false
;
}
$selector
=
trim
(
$plural
[
$i
++
]);
if
(
$i
==
1
&&
substr
(
$selector
,
0
,
7
)
==
'offset:'
)
{
if
(
$i
==
1
&&
!
empty
(
$selector
)
&&
substr_compare
(
$selector
,
'offset:'
,
0
,
7
)
===
0
)
{
$offset
=
(
int
)
trim
(
mb_substr
(
$selector
,
7
,
(
$pos
=
mb_strpos
(
str_replace
([
"
\n
"
,
"
\r
"
,
"
\t
"
],
' '
,
$selector
),
' '
,
7
))
-
7
));
$selector
=
trim
(
mb_substr
(
$selector
,
$pos
+
1
));
}
...
...
framework/log/Target.php
View file @
1c414caa
...
...
@@ -204,7 +204,7 @@ abstract class Target extends Component
$matched
=
empty
(
$categories
);
foreach
(
$categories
as
$category
)
{
if
(
$message
[
2
]
===
$category
||
substr
(
$category
,
-
1
)
===
'*'
&&
strpos
(
$message
[
2
],
rtrim
(
$category
,
'*'
))
===
0
)
{
if
(
$message
[
2
]
===
$category
||
!
empty
(
$category
)
&&
substr_compare
(
$category
,
'*'
,
-
1
)
===
0
&&
strpos
(
$message
[
2
],
rtrim
(
$category
,
'*'
))
===
0
)
{
$matched
=
true
;
break
;
}
...
...
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