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
9c7a06b1
Commit
9c7a06b1
authored
May 03, 2012
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better comments style, missing @thorws
parent
6e592f03
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
Component.php
framework/base/Component.php
+15
-7
Object.php
framework/base/Object.php
+7
-3
No files found.
framework/base/Component.php
View file @
9c7a06b1
...
@@ -47,9 +47,11 @@ class Component extends \yii\base\Object
...
@@ -47,9 +47,11 @@ class Component extends \yii\base\Object
public
function
__get
(
$name
)
public
function
__get
(
$name
)
{
{
$getter
=
'get'
.
$name
;
$getter
=
'get'
.
$name
;
if
(
method_exists
(
$this
,
$getter
))
{
// read property, e.g. getName()
if
(
method_exists
(
$this
,
$getter
))
{
// read property, e.g. getName()
return
$this
->
$getter
();
return
$this
->
$getter
();
}
else
{
// behavior property
}
else
{
// behavior property
$this
->
ensureBehaviors
();
$this
->
ensureBehaviors
();
foreach
(
$this
->
_b
as
$behavior
)
{
foreach
(
$this
->
_b
as
$behavior
)
{
if
(
$behavior
->
canGetProperty
(
$name
))
{
if
(
$behavior
->
canGetProperty
(
$name
))
{
...
@@ -91,7 +93,8 @@ class Component extends \yii\base\Object
...
@@ -91,7 +93,8 @@ class Component extends \yii\base\Object
// as behavior: attach behavior
// as behavior: attach behavior
$name
=
trim
(
substr
(
$name
,
3
));
$name
=
trim
(
substr
(
$name
,
3
));
$this
->
attachBehavior
(
$name
,
\Yii
::
createObject
(
$value
));
$this
->
attachBehavior
(
$name
,
\Yii
::
createObject
(
$value
));
}
else
{
// behavior property
}
else
{
// behavior property
$this
->
ensureBehaviors
();
$this
->
ensureBehaviors
();
foreach
(
$this
->
_b
as
$behavior
)
{
foreach
(
$this
->
_b
as
$behavior
)
{
if
(
$behavior
->
canSetProperty
(
$name
))
{
if
(
$behavior
->
canSetProperty
(
$name
))
{
...
@@ -122,9 +125,11 @@ class Component extends \yii\base\Object
...
@@ -122,9 +125,11 @@ class Component extends \yii\base\Object
public
function
__isset
(
$name
)
public
function
__isset
(
$name
)
{
{
$getter
=
'get'
.
$name
;
$getter
=
'get'
.
$name
;
if
(
method_exists
(
$this
,
$getter
))
{
// property is not null
if
(
method_exists
(
$this
,
$getter
))
{
// property is not null
return
$this
->
$getter
()
!==
null
;
return
$this
->
$getter
()
!==
null
;
}
else
{
// behavior property
}
else
{
// behavior property
$this
->
ensureBehaviors
();
$this
->
ensureBehaviors
();
foreach
(
$this
->
_b
as
$behavior
)
{
foreach
(
$this
->
_b
as
$behavior
)
{
if
(
$behavior
->
canGetProperty
(
$name
))
{
if
(
$behavior
->
canGetProperty
(
$name
))
{
...
@@ -150,10 +155,12 @@ class Component extends \yii\base\Object
...
@@ -150,10 +155,12 @@ class Component extends \yii\base\Object
public
function
__unset
(
$name
)
public
function
__unset
(
$name
)
{
{
$setter
=
'set'
.
$name
;
$setter
=
'set'
.
$name
;
if
(
method_exists
(
$this
,
$setter
))
{
// write property
if
(
method_exists
(
$this
,
$setter
))
{
// write property
$this
->
$setter
(
null
);
$this
->
$setter
(
null
);
return
;
return
;
}
else
{
// behavior property
}
else
{
// behavior property
$this
->
ensureBehaviors
();
$this
->
ensureBehaviors
();
foreach
(
$this
->
_b
as
$behavior
)
{
foreach
(
$this
->
_b
as
$behavior
)
{
if
(
$behavior
->
canSetProperty
(
$name
))
{
if
(
$behavior
->
canSetProperty
(
$name
))
{
...
@@ -178,6 +185,7 @@ class Component extends \yii\base\Object
...
@@ -178,6 +185,7 @@ class Component extends \yii\base\Object
* will be implicitly called when an unknown method is being invoked.
* will be implicitly called when an unknown method is being invoked.
* @param string $name the method name
* @param string $name the method name
* @param array $params method parameters
* @param array $params method parameters
* @throws Exception when calling unknown method
* @return mixed the method return value
* @return mixed the method return value
*/
*/
public
function
__call
(
$name
,
$params
)
public
function
__call
(
$name
,
$params
)
...
...
framework/base/Object.php
View file @
9c7a06b1
...
@@ -82,7 +82,8 @@ class Object
...
@@ -82,7 +82,8 @@ class Object
public
function
__isset
(
$name
)
public
function
__isset
(
$name
)
{
{
$getter
=
'get'
.
$name
;
$getter
=
'get'
.
$name
;
if
(
method_exists
(
$this
,
$getter
))
{
// property is not null
if
(
method_exists
(
$this
,
$getter
))
{
// property is not null
return
$this
->
$getter
()
!==
null
;
return
$this
->
$getter
()
!==
null
;
}
else
{
}
else
{
return
false
;
return
false
;
...
@@ -103,7 +104,8 @@ class Object
...
@@ -103,7 +104,8 @@ class Object
public
function
__unset
(
$name
)
public
function
__unset
(
$name
)
{
{
$setter
=
'set'
.
$name
;
$setter
=
'set'
.
$name
;
if
(
method_exists
(
$this
,
$setter
))
{
// write property
if
(
method_exists
(
$this
,
$setter
))
{
// write property
$this
->
$setter
(
null
);
$this
->
$setter
(
null
);
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
}
elseif
(
method_exists
(
$this
,
'get'
.
$name
))
{
throw
new
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
throw
new
Exception
(
'Unsetting read-only property: '
.
get_class
(
$this
)
.
'.'
.
$name
);
...
@@ -119,6 +121,7 @@ class Object
...
@@ -119,6 +121,7 @@ class Object
* will be implicitly called when an unknown method is being invoked.
* will be implicitly called when an unknown method is being invoked.
* @param string $name the method name
* @param string $name the method name
* @param array $params method parameters
* @param array $params method parameters
* @throws Exception when calling unknown method
* @return mixed the method return value
* @return mixed the method return value
*/
*/
public
function
__call
(
$name
,
$params
)
public
function
__call
(
$name
,
$params
)
...
@@ -267,7 +270,8 @@ class Object
...
@@ -267,7 +270,8 @@ class Object
}
elseif
(
$n
===
4
)
{
}
elseif
(
$n
===
4
)
{
$object
=
new
$class
(
$args
[
1
],
$args
[
2
],
$args
[
3
]);
$object
=
new
$class
(
$args
[
1
],
$args
[
2
],
$args
[
3
]);
}
else
{
}
else
{
array_shift
(
$args
);
// remove $config
// remove $config
array_shift
(
$args
);
$r
=
new
\ReflectionClass
(
$class
);
$r
=
new
\ReflectionClass
(
$class
);
$object
=
$r
->
newInstanceArgs
(
$args
);
$object
=
$r
->
newInstanceArgs
(
$args
);
}
}
...
...
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