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
26767735
Commit
26767735
authored
Dec 04, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed byte methods, moved path methods back to StringHelper
parent
5f2a612c
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
129 additions
and
131 deletions
+129
-131
ActiveRecord.php
extensions/elasticsearch/ActiveRecord.php
+3
-3
controller.php
extensions/gii/generators/crud/templates/controller.php
+6
-6
search.php
extensions/gii/generators/crud/templates/search.php
+4
-4
_form.php
extensions/gii/generators/crud/templates/views/_form.php
+2
-2
_search.php
extensions/gii/generators/crud/templates/views/_search.php
+2
-2
create.php
extensions/gii/generators/crud/templates/views/create.php
+3
-3
index.php
extensions/gii/generators/crud/templates/views/index.php
+4
-4
update.php
extensions/gii/generators/crud/templates/views/update.php
+3
-3
view.php
extensions/gii/generators/crud/templates/views/view.php
+3
-3
Generator.php
extensions/gii/generators/module/Generator.php
+3
-3
ActiveRecord.php
extensions/redis/ActiveRecord.php
+2
-3
ActiveRecord.php
extensions/sphinx/ActiveRecord.php
+3
-3
Cache.php
framework/yii/caching/Cache.php
+1
-1
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+2
-2
BaseFileHelper.php
framework/yii/helpers/BaseFileHelper.php
+3
-47
BaseSecurity.php
framework/yii/helpers/BaseSecurity.php
+5
-5
BaseStringHelper.php
framework/yii/helpers/BaseStringHelper.php
+45
-1
Response.php
framework/yii/web/Response.php
+2
-2
XmlResponseFormatter.php
framework/yii/web/XmlResponseFormatter.php
+2
-2
StringHelperTest.php
tests/unit/framework/helpers/StringHelperTest.php
+30
-31
ResponseTest.php
tests/unit/framework/web/ResponseTest.php
+1
-1
No files found.
extensions/elasticsearch/ActiveRecord.php
View file @
26767735
...
@@ -10,9 +10,9 @@ namespace yii\elasticsearch;
...
@@ -10,9 +10,9 @@ namespace yii\elasticsearch;
use
yii\base\InvalidCallException
;
use
yii\base\InvalidCallException
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\db\BaseActiveRecord
;
use
yii\db\BaseActiveRecord
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
use
yii\helpers\StringHelper
;
/**
/**
* ActiveRecord is the base class for classes representing relational data in terms of objects.
* ActiveRecord is the base class for classes representing relational data in terms of objects.
...
@@ -226,7 +226,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -226,7 +226,7 @@ class ActiveRecord extends BaseActiveRecord
*/
*/
public
static
function
index
()
public
static
function
index
()
{
{
return
Inflector
::
pluralize
(
Inflector
::
camel2id
(
File
Helper
::
basename
(
get_called_class
()),
'-'
));
return
Inflector
::
pluralize
(
Inflector
::
camel2id
(
String
Helper
::
basename
(
get_called_class
()),
'-'
));
}
}
/**
/**
...
@@ -234,7 +234,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -234,7 +234,7 @@ class ActiveRecord extends BaseActiveRecord
*/
*/
public
static
function
type
()
public
static
function
type
()
{
{
return
Inflector
::
camel2id
(
File
Helper
::
basename
(
get_called_class
()),
'-'
);
return
Inflector
::
camel2id
(
String
Helper
::
basename
(
get_called_class
()),
'-'
);
}
}
/**
/**
...
...
extensions/gii/generators/crud/templates/controller.php
View file @
26767735
<?php
<?php
use
yii\db\ActiveRecordInterface
;
use
yii\db\ActiveRecordInterface
;
use
yii\helpers\
File
Helper
;
use
yii\helpers\
String
Helper
;
/**
/**
* This is the template for generating a CRUD controller class file.
* This is the template for generating a CRUD controller class file.
...
@@ -10,9 +10,9 @@ use yii\helpers\FileHelper;
...
@@ -10,9 +10,9 @@ use yii\helpers\FileHelper;
* @var yii\gii\generators\crud\Generator $generator
* @var yii\gii\generators\crud\Generator $generator
*/
*/
$controllerClass
=
File
Helper
::
basename
(
$generator
->
controllerClass
);
$controllerClass
=
String
Helper
::
basename
(
$generator
->
controllerClass
);
$modelClass
=
File
Helper
::
basename
(
$generator
->
modelClass
);
$modelClass
=
String
Helper
::
basename
(
$generator
->
modelClass
);
$searchModelClass
=
File
Helper
::
basename
(
$generator
->
searchModelClass
);
$searchModelClass
=
String
Helper
::
basename
(
$generator
->
searchModelClass
);
if
(
$modelClass
===
$searchModelClass
)
{
if
(
$modelClass
===
$searchModelClass
)
{
$searchModelAlias
=
$searchModelClass
.
'Search'
;
$searchModelAlias
=
$searchModelClass
.
'Search'
;
}
}
...
@@ -27,7 +27,7 @@ $actionParamComments = $generator->generateActionParamComments();
...
@@ -27,7 +27,7 @@ $actionParamComments = $generator->generateActionParamComments();
echo
"<?php
\n
"
;
echo
"<?php
\n
"
;
?>
?>
namespace
<?=
File
Helper
::
dirname
(
ltrim
(
$generator
->
controllerClass
,
'\\'
))
?>
;
namespace
<?=
String
Helper
::
dirname
(
ltrim
(
$generator
->
controllerClass
,
'\\'
))
?>
;
use
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
;
use
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
;
use
<?=
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
?><?php
if
(
isset
(
$searchModelAlias
))
:?>
as
<?=
$searchModelAlias
?><?php
endif
?>
;
use
<?=
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
?><?php
if
(
isset
(
$searchModelAlias
))
:?>
as
<?=
$searchModelAlias
?><?php
endif
?>
;
...
@@ -38,7 +38,7 @@ use yii\web\VerbFilter;
...
@@ -38,7 +38,7 @@ use yii\web\VerbFilter;
/**
/**
*
<?=
$controllerClass
?>
implements the CRUD actions for
<?=
$modelClass
?>
model.
*
<?=
$controllerClass
?>
implements the CRUD actions for
<?=
$modelClass
?>
model.
*/
*/
class
<?=
$controllerClass
?>
extends
<?=
File
Helper
::
basename
(
$generator
->
baseControllerClass
)
.
"
\n
"
?>
class
<?=
$controllerClass
?>
extends
<?=
String
Helper
::
basename
(
$generator
->
baseControllerClass
)
.
"
\n
"
?>
{
{
public function behaviors()
public function behaviors()
{
{
...
...
extensions/gii/generators/crud/templates/search.php
View file @
26767735
<?php
<?php
use
yii\helpers\
File
Helper
;
use
yii\helpers\
String
Helper
;
/**
/**
* This is the template for generating a CRUD controller class file.
* This is the template for generating a CRUD controller class file.
...
@@ -9,8 +9,8 @@ use yii\helpers\FileHelper;
...
@@ -9,8 +9,8 @@ use yii\helpers\FileHelper;
* @var yii\gii\generators\crud\Generator $generator
* @var yii\gii\generators\crud\Generator $generator
*/
*/
$modelClass
=
File
Helper
::
basename
(
$generator
->
modelClass
);
$modelClass
=
String
Helper
::
basename
(
$generator
->
modelClass
);
$searchModelClass
=
File
Helper
::
basename
(
$generator
->
searchModelClass
);
$searchModelClass
=
String
Helper
::
basename
(
$generator
->
searchModelClass
);
$rules
=
$generator
->
generateSearchRules
();
$rules
=
$generator
->
generateSearchRules
();
$labels
=
$generator
->
generateSearchLabels
();
$labels
=
$generator
->
generateSearchLabels
();
$searchAttributes
=
$generator
->
getSearchAttributes
();
$searchAttributes
=
$generator
->
getSearchAttributes
();
...
@@ -19,7 +19,7 @@ $searchConditions = $generator->generateSearchConditions();
...
@@ -19,7 +19,7 @@ $searchConditions = $generator->generateSearchConditions();
echo
"<?php
\n
"
;
echo
"<?php
\n
"
;
?>
?>
namespace
<?=
File
Helper
::
dirname
(
ltrim
(
$generator
->
searchModelClass
,
'\\'
))
?>
;
namespace
<?=
String
Helper
::
dirname
(
ltrim
(
$generator
->
searchModelClass
,
'\\'
))
?>
;
use yii\base\Model;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use yii\data\ActiveDataProvider;
...
...
extensions/gii/generators/crud/templates/views/_form.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -28,7 +28,7 @@ use yii\widgets\ActiveForm;
...
@@ -28,7 +28,7 @@ use yii\widgets\ActiveForm;
*/
*/
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-form"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-form"
>
<?=
"<?php "
?>
$form = ActiveForm::begin(); ?>
<?=
"<?php "
?>
$form = ActiveForm::begin(); ?>
...
...
extensions/gii/generators/crud/templates/views/_search.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -21,7 +21,7 @@ use yii\widgets\ActiveForm;
...
@@ -21,7 +21,7 @@ use yii\widgets\ActiveForm;
*/
*/
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-search"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-search"
>
<?=
"<?php "
?>
$form = ActiveForm::begin([
<?=
"<?php "
?>
$form = ActiveForm::begin([
'action' => ['index'],
'action' => ['index'],
...
...
extensions/gii/generators/crud/templates/views/create.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -18,11 +18,11 @@ use yii\helpers\Html;
...
@@ -18,11 +18,11 @@ use yii\helpers\Html;
* @var
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
$model
* @var
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
$model
*/
*/
$this->title = 'Create
<?=
Inflector
::
camel2words
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
';
$this->title = 'Create
<?=
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
';
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFileHelper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFileHelper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-create"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-create"
>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
...
...
extensions/gii/generators/crud/templates/views/index.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -23,17 +23,17 @@ use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\w
...
@@ -23,17 +23,17 @@ use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\w
* @var
<?=
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
?>
$searchModel
* @var
<?=
ltrim
(
$generator
->
searchModelClass
,
'\\'
)
?>
$searchModel
*/
*/
$this->title = '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
File
Helper
::
basename
(
$generator
->
modelClass
)))
?>
';
$this->title = '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
)))
?>
';
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-index"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-index"
>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<?=
"<?php "
.
(
$generator
->
indexWidgetType
===
'grid'
?
"// "
:
""
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<?=
"<?php "
.
(
$generator
->
indexWidgetType
===
'grid'
?
"// "
:
""
)
?>
echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<p>
<?=
"<?= "
?>
Html::a('Create
<?=
File
Helper
::
basename
(
$generator
->
modelClass
)
?>
', ['create'], ['class' => 'btn btn-success']) ?>
<?=
"<?= "
?>
Html::a('Create
<?=
String
Helper
::
basename
(
$generator
->
modelClass
)
?>
', ['create'], ['class' => 'btn btn-success']) ?>
</p>
</p>
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
<?php
if
(
$generator
->
indexWidgetType
===
'grid'
)
:
?>
...
...
extensions/gii/generators/crud/templates/views/update.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -20,12 +20,12 @@ use yii\helpers\Html;
...
@@ -20,12 +20,12 @@ use yii\helpers\Html;
* @var
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
$model
* @var
<?=
ltrim
(
$generator
->
modelClass
,
'\\'
)
?>
$model
*/
*/
$this->title = 'Update
<?=
Inflector
::
camel2words
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
: ' . $model->
<?=
$generator
->
getNameAttribute
()
?>
;
$this->title = 'Update
<?=
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
: ' . $model->
<?=
$generator
->
getNameAttribute
()
?>
;
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFileHelper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
BaseFileHelper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->
<?=
$generator
->
getNameAttribute
()
?>
, 'url' => ['view',
<?=
$urlParams
?>
]];
$this->params['breadcrumbs'][] = ['label' => $model->
<?=
$generator
->
getNameAttribute
()
?>
, 'url' => ['view',
<?=
$urlParams
?>
]];
$this->params['breadcrumbs'][] = 'Update';
$this->params['breadcrumbs'][] = 'Update';
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-update"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-update"
>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
...
...
extensions/gii/generators/crud/templates/views/view.php
View file @
26767735
<?php
<?php
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* @var yii\web\View $this
* @var yii\web\View $this
...
@@ -22,10 +22,10 @@ use yii\widgets\DetailView;
...
@@ -22,10 +22,10 @@ use yii\widgets\DetailView;
*/
*/
$this->title = $model->
<?=
$generator
->
getNameAttribute
()
?>
;
$this->title = $model->
<?=
$generator
->
getNameAttribute
()
?>
;
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
File
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => '
<?=
Inflector
::
pluralize
(
Inflector
::
camel2words
(
String
Helper
::
basename
(
$generator
->
modelClass
)))
?>
', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'][] = $this->title;
?>
?>
<div
class=
"
<?=
Inflector
::
camel2id
(
File
Helper
::
basename
(
$generator
->
modelClass
))
?>
-view"
>
<div
class=
"
<?=
Inflector
::
camel2id
(
String
Helper
::
basename
(
$generator
->
modelClass
))
?>
-view"
>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
<h1>
<?=
"<?= "
?>
Html::encode($this->title) ?>
</h1>
...
...
extensions/gii/generators/module/Generator.php
View file @
26767735
...
@@ -7,10 +7,10 @@
...
@@ -7,10 +7,10 @@
namespace
yii\gii\generators\module
;
namespace
yii\gii\generators\module
;
use
Yii
;
use
yii\gii\CodeFile
;
use
yii\gii\CodeFile
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\helpers\FileHelper
;
use
Yii
;
use
yii\helpers\StringHelper
;
/**
/**
* This generator will generate the skeleton code needed by a module.
* This generator will generate the skeleton code needed by a module.
...
@@ -119,7 +119,7 @@ EOD;
...
@@ -119,7 +119,7 @@ EOD;
$files
=
[];
$files
=
[];
$modulePath
=
$this
->
getModulePath
();
$modulePath
=
$this
->
getModulePath
();
$files
[]
=
new
CodeFile
(
$files
[]
=
new
CodeFile
(
$modulePath
.
'/'
.
File
Helper
::
basename
(
$this
->
moduleClass
)
.
'.php'
,
$modulePath
.
'/'
.
String
Helper
::
basename
(
$this
->
moduleClass
)
.
'.php'
,
$this
->
render
(
"module.php"
)
$this
->
render
(
"module.php"
)
);
);
$files
[]
=
new
CodeFile
(
$files
[]
=
new
CodeFile
(
...
...
extensions/redis/ActiveRecord.php
View file @
26767735
...
@@ -9,7 +9,6 @@ namespace yii\redis;
...
@@ -9,7 +9,6 @@ namespace yii\redis;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\db\BaseActiveRecord
;
use
yii\db\BaseActiveRecord
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
use
yii\helpers\StringHelper
;
...
@@ -97,7 +96,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -97,7 +96,7 @@ class ActiveRecord extends BaseActiveRecord
*/
*/
public
static
function
keyPrefix
()
public
static
function
keyPrefix
()
{
{
return
Inflector
::
camel2id
(
File
Helper
::
basename
(
get_called_class
()),
'_'
);
return
Inflector
::
camel2id
(
String
Helper
::
basename
(
get_called_class
()),
'_'
);
}
}
/**
/**
...
@@ -288,7 +287,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -288,7 +287,7 @@ class ActiveRecord extends BaseActiveRecord
if
(
is_numeric
(
$key
))
{
if
(
is_numeric
(
$key
))
{
return
$key
;
return
$key
;
}
elseif
(
is_string
(
$key
))
{
}
elseif
(
is_string
(
$key
))
{
return
ctype_alnum
(
$key
)
&&
StringHelper
::
byteLen
(
$key
)
<=
32
?
$key
:
md5
(
$key
);
return
ctype_alnum
(
$key
)
&&
StringHelper
::
byteLen
gth
(
$key
)
<=
32
?
$key
:
md5
(
$key
);
}
elseif
(
is_array
(
$key
))
{
}
elseif
(
is_array
(
$key
))
{
if
(
count
(
$key
)
==
1
)
{
if
(
count
(
$key
)
==
1
)
{
return
self
::
buildKey
(
reset
(
$key
));
return
self
::
buildKey
(
reset
(
$key
));
...
...
extensions/sphinx/ActiveRecord.php
View file @
26767735
...
@@ -8,13 +8,13 @@
...
@@ -8,13 +8,13 @@
namespace
yii\sphinx
;
namespace
yii\sphinx
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\db\BaseActiveRecord
;
use
yii\base\NotSupportedException
;
use
yii\base\NotSupportedException
;
use
yii\db\ActiveRelationInterface
;
use
yii\db\ActiveRelationInterface
;
use
yii\db\BaseActiveRecord
;
use
yii\db\StaleObjectException
;
use
yii\db\StaleObjectException
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
Yii
;
use
Yii
;
use
yii\helpers\StringHelper
;
/**
/**
* ActiveRecord is the base class for classes representing relational data in terms of objects.
* ActiveRecord is the base class for classes representing relational data in terms of objects.
...
@@ -166,7 +166,7 @@ abstract class ActiveRecord extends BaseActiveRecord
...
@@ -166,7 +166,7 @@ abstract class ActiveRecord extends BaseActiveRecord
*/
*/
public
static
function
indexName
()
public
static
function
indexName
()
{
{
return
Inflector
::
camel2id
(
File
Helper
::
basename
(
get_called_class
()),
'_'
);
return
Inflector
::
camel2id
(
String
Helper
::
basename
(
get_called_class
()),
'_'
);
}
}
/**
/**
...
...
framework/yii/caching/Cache.php
View file @
26767735
...
@@ -100,7 +100,7 @@ abstract class Cache extends Component implements \ArrayAccess
...
@@ -100,7 +100,7 @@ abstract class Cache extends Component implements \ArrayAccess
protected
function
buildKey
(
$key
)
protected
function
buildKey
(
$key
)
{
{
if
(
is_string
(
$key
))
{
if
(
is_string
(
$key
))
{
$key
=
ctype_alnum
(
$key
)
&&
StringHelper
::
byteLen
(
$key
)
<=
32
?
$key
:
md5
(
$key
);
$key
=
ctype_alnum
(
$key
)
&&
StringHelper
::
byteLen
gth
(
$key
)
<=
32
?
$key
:
md5
(
$key
);
}
else
{
}
else
{
$key
=
md5
(
json_encode
(
$key
));
$key
=
md5
(
json_encode
(
$key
));
}
}
...
...
framework/yii/db/ActiveRecord.php
View file @
26767735
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
namespace
yii\db
;
namespace
yii\db
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Inflector
;
use
yii\helpers\Inflector
;
use
yii\helpers\StringHelper
;
/**
/**
* ActiveRecord is the base class for classes representing relational data in terms of objects.
* ActiveRecord is the base class for classes representing relational data in terms of objects.
...
@@ -169,7 +169,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -169,7 +169,7 @@ class ActiveRecord extends BaseActiveRecord
*/
*/
public
static
function
tableName
()
public
static
function
tableName
()
{
{
return
'tbl_'
.
Inflector
::
camel2id
(
File
Helper
::
basename
(
get_called_class
()),
'_'
);
return
'tbl_'
.
Inflector
::
camel2id
(
String
Helper
::
basename
(
get_called_class
()),
'_'
);
}
}
/**
/**
...
...
framework/yii/helpers/BaseFileHelper.php
View file @
26767735
...
@@ -292,11 +292,11 @@ class BaseFileHelper
...
@@ -292,11 +292,11 @@ class BaseFileHelper
if
(
$isDir
=
is_dir
(
$path
))
{
if
(
$isDir
=
is_dir
(
$path
))
{
$path
.=
'/'
;
$path
.=
'/'
;
}
}
$n
=
StringHelper
::
byteLen
(
$path
);
$n
=
StringHelper
::
byteLen
gth
(
$path
);
if
(
!
empty
(
$options
[
'except'
]))
{
if
(
!
empty
(
$options
[
'except'
]))
{
foreach
(
$options
[
'except'
]
as
$name
)
{
foreach
(
$options
[
'except'
]
as
$name
)
{
if
(
StringHelper
::
byteSubstr
(
$path
,
-
StringHelper
::
byteLen
(
$name
),
$n
)
===
$name
)
{
if
(
StringHelper
::
byteSubstr
(
$path
,
-
StringHelper
::
byteLen
gth
(
$name
),
$n
)
===
$name
)
{
return
false
;
return
false
;
}
}
}
}
...
@@ -304,7 +304,7 @@ class BaseFileHelper
...
@@ -304,7 +304,7 @@ class BaseFileHelper
if
(
!
$isDir
&&
!
empty
(
$options
[
'only'
]))
{
if
(
!
$isDir
&&
!
empty
(
$options
[
'only'
]))
{
foreach
(
$options
[
'only'
]
as
$name
)
{
foreach
(
$options
[
'only'
]
as
$name
)
{
if
(
StringHelper
::
byteSubstr
(
$path
,
-
StringHelper
::
byteLen
(
$name
),
$n
)
===
$name
)
{
if
(
StringHelper
::
byteSubstr
(
$path
,
-
StringHelper
::
byteLen
gth
(
$name
),
$n
)
===
$name
)
{
return
true
;
return
true
;
}
}
}
}
...
@@ -338,48 +338,4 @@ class BaseFileHelper
...
@@ -338,48 +338,4 @@ class BaseFileHelper
chmod
(
$path
,
$mode
);
chmod
(
$path
,
$mode
);
return
$result
;
return
$result
;
}
}
/**
* Returns the trailing name component of a path.
* This method is similar to the php function `basename()` except that it will
* treat both \ and / as directory separators, independent of the operating system.
* This method was mainly created to work on php namespaces. When working with real
* file paths, php's `basename()` should work fine for you.
* Note: this method is not aware of the actual filesystem, or path components such as "..".
*
* @param string $path A path string.
* @param string $suffix If the name component ends in suffix this will also be cut off.
* @return string the trailing name component of the given path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
basename
(
$path
,
$suffix
=
''
)
{
if
((
$len
=
mb_strlen
(
$suffix
))
>
0
&&
mb_substr
(
$path
,
-
$len
)
==
$suffix
)
{
$path
=
mb_substr
(
$path
,
0
,
-
$len
);
}
$path
=
rtrim
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/\\'
);
if
((
$pos
=
mb_strrpos
(
$path
,
'/'
))
!==
false
)
{
return
mb_substr
(
$path
,
$pos
+
1
);
}
return
$path
;
}
/**
* Returns parent directory's path.
* This method is similar to `dirname()` except that it will treat
* both \ and / as directory separators, independent of the operating system.
*
* @param string $path A path string.
* @return string the parent directory's path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
dirname
(
$path
)
{
$pos
=
mb_strrpos
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/'
);
if
(
$pos
!==
false
)
{
return
mb_substr
(
$path
,
0
,
$pos
);
}
else
{
return
$path
;
}
}
}
}
framework/yii/helpers/BaseSecurity.php
View file @
26767735
...
@@ -83,7 +83,7 @@ class BaseSecurity
...
@@ -83,7 +83,7 @@ class BaseSecurity
$iv
=
StringHelper
::
byteSubstr
(
$data
,
0
,
$ivSize
);
$iv
=
StringHelper
::
byteSubstr
(
$data
,
0
,
$ivSize
);
$key
=
static
::
deriveKey
(
$password
,
$iv
);
$key
=
static
::
deriveKey
(
$password
,
$iv
);
mcrypt_generic_init
(
$module
,
$key
,
$iv
);
mcrypt_generic_init
(
$module
,
$key
,
$iv
);
$decrypted
=
mdecrypt_generic
(
$module
,
StringHelper
::
byteSubstr
(
$data
,
$ivSize
,
StringHelper
::
byteLen
(
$data
)));
$decrypted
=
mdecrypt_generic
(
$module
,
StringHelper
::
byteSubstr
(
$data
,
$ivSize
,
StringHelper
::
byteLen
gth
(
$data
)));
mcrypt_generic_deinit
(
$module
);
mcrypt_generic_deinit
(
$module
);
mcrypt_module_close
(
$module
);
mcrypt_module_close
(
$module
);
return
static
::
stripPadding
(
$decrypted
);
return
static
::
stripPadding
(
$decrypted
);
...
@@ -96,7 +96,7 @@ class BaseSecurity
...
@@ -96,7 +96,7 @@ class BaseSecurity
*/
*/
protected
static
function
addPadding
(
$data
)
protected
static
function
addPadding
(
$data
)
{
{
$pad
=
self
::
CRYPT_BLOCK_SIZE
-
(
StringHelper
::
byteLen
(
$data
)
%
self
::
CRYPT_BLOCK_SIZE
);
$pad
=
self
::
CRYPT_BLOCK_SIZE
-
(
StringHelper
::
byteLen
gth
(
$data
)
%
self
::
CRYPT_BLOCK_SIZE
);
return
$data
.
str_repeat
(
chr
(
$pad
),
$pad
);
return
$data
.
str_repeat
(
chr
(
$pad
),
$pad
);
}
}
...
@@ -109,7 +109,7 @@ class BaseSecurity
...
@@ -109,7 +109,7 @@ class BaseSecurity
{
{
$end
=
StringHelper
::
byteSubstr
(
$data
,
-
1
,
NULL
);
$end
=
StringHelper
::
byteSubstr
(
$data
,
-
1
,
NULL
);
$last
=
ord
(
$end
);
$last
=
ord
(
$end
);
$n
=
StringHelper
::
byteLen
(
$data
)
-
$last
;
$n
=
StringHelper
::
byteLen
gth
(
$data
)
-
$last
;
if
(
StringHelper
::
byteSubstr
(
$data
,
$n
,
NULL
)
==
str_repeat
(
$end
,
$last
))
{
if
(
StringHelper
::
byteSubstr
(
$data
,
$n
,
NULL
)
==
str_repeat
(
$end
,
$last
))
{
return
StringHelper
::
byteSubstr
(
$data
,
0
,
$n
);
return
StringHelper
::
byteSubstr
(
$data
,
0
,
$n
);
}
}
...
@@ -164,8 +164,8 @@ class BaseSecurity
...
@@ -164,8 +164,8 @@ class BaseSecurity
*/
*/
public
static
function
validateData
(
$data
,
$key
,
$algorithm
=
'sha256'
)
public
static
function
validateData
(
$data
,
$key
,
$algorithm
=
'sha256'
)
{
{
$hashSize
=
StringHelper
::
byteLen
(
hash_hmac
(
$algorithm
,
'test'
,
$key
));
$hashSize
=
StringHelper
::
byteLen
gth
(
hash_hmac
(
$algorithm
,
'test'
,
$key
));
$n
=
StringHelper
::
byteLen
(
$data
);
$n
=
StringHelper
::
byteLen
gth
(
$data
);
if
(
$n
>=
$hashSize
)
{
if
(
$n
>=
$hashSize
)
{
$hash
=
StringHelper
::
byteSubstr
(
$data
,
0
,
$hashSize
);
$hash
=
StringHelper
::
byteSubstr
(
$data
,
0
,
$hashSize
);
$data2
=
StringHelper
::
byteSubstr
(
$data
,
$hashSize
,
$n
-
$hashSize
);
$data2
=
StringHelper
::
byteSubstr
(
$data
,
$hashSize
,
$n
-
$hashSize
);
...
...
framework/yii/helpers/BaseStringHelper.php
View file @
26767735
...
@@ -26,7 +26,7 @@ class BaseStringHelper
...
@@ -26,7 +26,7 @@ class BaseStringHelper
* @param string $string the string being measured for length
* @param string $string the string being measured for length
* @return integer the number of bytes in the given string.
* @return integer the number of bytes in the given string.
*/
*/
public
static
function
byteLen
(
$string
)
public
static
function
byteLen
gth
(
$string
)
{
{
return
mb_strlen
(
$string
,
'8bit'
);
return
mb_strlen
(
$string
,
'8bit'
);
}
}
...
@@ -94,4 +94,48 @@ class BaseStringHelper
...
@@ -94,4 +94,48 @@ class BaseStringHelper
$diff
=
new
\Diff
(
$lines1
,
$lines2
);
$diff
=
new
\Diff
(
$lines1
,
$lines2
);
return
$diff
->
render
(
$renderer
);
return
$diff
->
render
(
$renderer
);
}
}
/**
* Returns the trailing name component of a path.
* This method is similar to the php function `basename()` except that it will
* treat both \ and / as directory separators, independent of the operating system.
* This method was mainly created to work on php namespaces. When working with real
* file paths, php's `basename()` should work fine for you.
* Note: this method is not aware of the actual filesystem, or path components such as "..".
*
* @param string $path A path string.
* @param string $suffix If the name component ends in suffix this will also be cut off.
* @return string the trailing name component of the given path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
basename
(
$path
,
$suffix
=
''
)
{
if
((
$len
=
mb_strlen
(
$suffix
))
>
0
&&
mb_substr
(
$path
,
-
$len
)
==
$suffix
)
{
$path
=
mb_substr
(
$path
,
0
,
-
$len
);
}
$path
=
rtrim
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/\\'
);
if
((
$pos
=
mb_strrpos
(
$path
,
'/'
))
!==
false
)
{
return
mb_substr
(
$path
,
$pos
+
1
);
}
return
$path
;
}
/**
* Returns parent directory's path.
* This method is similar to `dirname()` except that it will treat
* both \ and / as directory separators, independent of the operating system.
*
* @param string $path A path string.
* @return string the parent directory's path.
* @see http://www.php.net/manual/en/function.basename.php
*/
public
static
function
dirname
(
$path
)
{
$pos
=
mb_strrpos
(
str_replace
(
'\\'
,
'/'
,
$path
),
'/'
);
if
(
$pos
!==
false
)
{
return
mb_substr
(
$path
,
0
,
$pos
);
}
else
{
return
$path
;
}
}
}
}
framework/yii/web/Response.php
View file @
26767735
...
@@ -382,7 +382,7 @@ class Response extends \yii\base\Response
...
@@ -382,7 +382,7 @@ class Response extends \yii\base\Response
public
function
sendContentAsFile
(
$content
,
$attachmentName
,
$mimeType
=
'application/octet-stream'
)
public
function
sendContentAsFile
(
$content
,
$attachmentName
,
$mimeType
=
'application/octet-stream'
)
{
{
$headers
=
$this
->
getHeaders
();
$headers
=
$this
->
getHeaders
();
$contentLength
=
StringHelper
::
byteLen
(
$content
);
$contentLength
=
StringHelper
::
byteLen
gth
(
$content
);
$range
=
$this
->
getHttpRange
(
$contentLength
);
$range
=
$this
->
getHttpRange
(
$contentLength
);
if
(
$range
===
false
)
{
if
(
$range
===
false
)
{
$headers
->
set
(
'Content-Range'
,
"bytes */
$contentLength
"
);
$headers
->
set
(
'Content-Range'
,
"bytes */
$contentLength
"
);
...
@@ -395,7 +395,7 @@ class Response extends \yii\base\Response
...
@@ -395,7 +395,7 @@ class Response extends \yii\base\Response
->
setDefault
(
'Content-Type'
,
$mimeType
)
->
setDefault
(
'Content-Type'
,
$mimeType
)
->
setDefault
(
'Cache-Control'
,
'must-revalidate, post-check=0, pre-check=0'
)
->
setDefault
(
'Cache-Control'
,
'must-revalidate, post-check=0, pre-check=0'
)
->
setDefault
(
'Content-Transfer-Encoding'
,
'binary'
)
->
setDefault
(
'Content-Transfer-Encoding'
,
'binary'
)
->
setDefault
(
'Content-Length'
,
StringHelper
::
byteLen
(
$content
))
->
setDefault
(
'Content-Length'
,
StringHelper
::
byteLen
gth
(
$content
))
->
setDefault
(
'Content-Disposition'
,
"attachment; filename=
\"
$attachmentName
\"
"
);
->
setDefault
(
'Content-Disposition'
,
"attachment; filename=
\"
$attachmentName
\"
"
);
list
(
$begin
,
$end
)
=
$range
;
list
(
$begin
,
$end
)
=
$range
;
...
...
framework/yii/web/XmlResponseFormatter.php
View file @
26767735
...
@@ -12,7 +12,7 @@ use DOMElement;
...
@@ -12,7 +12,7 @@ use DOMElement;
use
DOMText
;
use
DOMText
;
use
yii\base\Arrayable
;
use
yii\base\Arrayable
;
use
yii\base\Component
;
use
yii\base\Component
;
use
yii\helpers\
File
Helper
;
use
yii\helpers\
String
Helper
;
/**
/**
* XmlResponseFormatter formats the given data into an XML response content.
* XmlResponseFormatter formats the given data into an XML response content.
...
@@ -66,7 +66,7 @@ class XmlResponseFormatter extends Component implements ResponseFormatterInterfa
...
@@ -66,7 +66,7 @@ class XmlResponseFormatter extends Component implements ResponseFormatterInterfa
protected
function
buildXml
(
$element
,
$data
)
protected
function
buildXml
(
$element
,
$data
)
{
{
if
(
is_object
(
$data
))
{
if
(
is_object
(
$data
))
{
$child
=
new
DOMElement
(
File
Helper
::
basename
(
get_class
(
$data
)));
$child
=
new
DOMElement
(
String
Helper
::
basename
(
get_class
(
$data
)));
$element
->
appendChild
(
$child
);
$element
->
appendChild
(
$child
);
if
(
$data
instanceof
Arrayable
)
{
if
(
$data
instanceof
Arrayable
)
{
$this
->
buildXml
(
$child
,
$data
->
toArray
());
$this
->
buildXml
(
$child
,
$data
->
toArray
());
...
...
tests/unit/framework/helpers/StringHelperTest.php
View file @
26767735
<?php
<?php
namespace
yiiunit\framework\helpers
;
namespace
yiiunit\framework\helpers
;
use
yii\helpers\FileHelper
;
use
yii\helpers\StringHelper
;
use
yii\helpers\StringHelper
;
use
yiiunit\TestCase
;
use
yiiunit\TestCase
;
...
@@ -13,8 +12,8 @@ class StringHelperTest extends TestCase
...
@@ -13,8 +12,8 @@ class StringHelperTest extends TestCase
{
{
public
function
testStrlen
()
public
function
testStrlen
()
{
{
$this
->
assertEquals
(
4
,
StringHelper
::
byteLen
(
'this'
));
$this
->
assertEquals
(
4
,
StringHelper
::
byteLen
gth
(
'this'
));
$this
->
assertEquals
(
6
,
StringHelper
::
byteLen
(
'это'
));
$this
->
assertEquals
(
6
,
StringHelper
::
byteLen
gth
(
'это'
));
}
}
public
function
testSubstr
()
public
function
testSubstr
()
...
@@ -25,45 +24,45 @@ class StringHelperTest extends TestCase
...
@@ -25,45 +24,45 @@ class StringHelperTest extends TestCase
public
function
testBasename
()
public
function
testBasename
()
{
{
$this
->
assertEquals
(
''
,
File
Helper
::
basename
(
''
));
$this
->
assertEquals
(
''
,
String
Helper
::
basename
(
''
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'/file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'/file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/path/to/file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/path/to/file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'/path/to/file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'/path/to/file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/path/to/file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/path/to/file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'\file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'\file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'\file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'\file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'C:\file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'C:\file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'C:\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'C:\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'C:\file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'C:\file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'C:\path\to\file'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'C:\path\to\file'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'C:\path\to\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'C:\path\to\file.test'
,
'.test2'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'C:\path\to\file.test'
,
'.test'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'C:\path\to\file.test'
,
'.test'
));
// mixed paths
// mixed paths
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'/path\to/file.test'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'/path\to/file.test'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'/path/to\file.test'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'/path/to\file.test'
));
$this
->
assertEquals
(
'file.test'
,
File
Helper
::
basename
(
'\path/to\file.test'
));
$this
->
assertEquals
(
'file.test'
,
String
Helper
::
basename
(
'\path/to\file.test'
));
// \ and / in suffix
// \ and / in suffix
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/path/to/filete/st'
,
'te/st'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/path/to/filete/st'
,
'te/st'
));
$this
->
assertEquals
(
'st'
,
File
Helper
::
basename
(
'/path/to/filete/st'
,
'te\st'
));
$this
->
assertEquals
(
'st'
,
String
Helper
::
basename
(
'/path/to/filete/st'
,
'te\st'
));
$this
->
assertEquals
(
'file'
,
File
Helper
::
basename
(
'/path/to/filete\st'
,
'te\st'
));
$this
->
assertEquals
(
'file'
,
String
Helper
::
basename
(
'/path/to/filete\st'
,
'te\st'
));
$this
->
assertEquals
(
'st'
,
File
Helper
::
basename
(
'/path/to/filete\st'
,
'te/st'
));
$this
->
assertEquals
(
'st'
,
String
Helper
::
basename
(
'/path/to/filete\st'
,
'te/st'
));
// http://www.php.net/manual/en/function.basename.php#72254
// http://www.php.net/manual/en/function.basename.php#72254
$this
->
assertEquals
(
'foo'
,
File
Helper
::
basename
(
'/bar/foo/'
));
$this
->
assertEquals
(
'foo'
,
String
Helper
::
basename
(
'/bar/foo/'
));
$this
->
assertEquals
(
'foo'
,
File
Helper
::
basename
(
'\\bar\\foo\\'
));
$this
->
assertEquals
(
'foo'
,
String
Helper
::
basename
(
'\\bar\\foo\\'
));
}
}
}
}
tests/unit/framework/web/ResponseTest.php
View file @
26767735
...
@@ -57,7 +57,7 @@ class ResponseTest extends \yiiunit\TestCase
...
@@ -57,7 +57,7 @@ class ResponseTest extends \yiiunit\TestCase
$this
->
assertEquals
(
206
,
$this
->
response
->
statusCode
);
$this
->
assertEquals
(
206
,
$this
->
response
->
statusCode
);
$headers
=
$this
->
response
->
headers
;
$headers
=
$this
->
response
->
headers
;
$this
->
assertEquals
(
"bytes"
,
$headers
->
get
(
'Accept-Ranges'
));
$this
->
assertEquals
(
"bytes"
,
$headers
->
get
(
'Accept-Ranges'
));
$this
->
assertEquals
(
"bytes "
.
$expectedHeader
.
'/'
.
StringHelper
::
byteLen
(
$fullContent
),
$headers
->
get
(
'Content-Range'
));
$this
->
assertEquals
(
"bytes "
.
$expectedHeader
.
'/'
.
StringHelper
::
byteLen
gth
(
$fullContent
),
$headers
->
get
(
'Content-Range'
));
$this
->
assertEquals
(
'text/plain'
,
$headers
->
get
(
'Content-Type'
));
$this
->
assertEquals
(
'text/plain'
,
$headers
->
get
(
'Content-Type'
));
$this
->
assertEquals
(
"
$length
"
,
$headers
->
get
(
'Content-Length'
));
$this
->
assertEquals
(
"
$length
"
,
$headers
->
get
(
'Content-Length'
));
}
}
...
...
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