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
acba9e5b
Commit
acba9e5b
authored
Oct 17, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix crash when setter w/o arguments is defined
fixes #5623
parent
292a9ff5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
CHANGELOG.md
extensions/apidoc/CHANGELOG.md
+1
-1
Context.php
extensions/apidoc/models/Context.php
+8
-6
No files found.
extensions/apidoc/CHANGELOG.md
View file @
acba9e5b
...
...
@@ -4,7 +4,7 @@ Yii Framework 2 apidoc extension Change Log
2.
0.1 under development
-----------------------
-
no changes in this release.
-
Bug #5623: Fixed crash when a class contains a setter that has no arguments e.g.
`setXyz()`
(cebe)
2.0.0 October 12, 2014
...
...
extensions/apidoc/models/Context.php
View file @
acba9e5b
...
...
@@ -271,7 +271,7 @@ class Context extends Component
if
(
$method
->
isStatic
)
{
continue
;
}
if
(
!
strncmp
(
$name
,
'get'
,
3
)
&&
strlen
(
$name
)
>
3
&&
$this
->
paramsOptional
(
$method
))
{
if
(
!
strncmp
(
$name
,
'get'
,
3
)
&&
strlen
(
$name
)
>
3
&&
$this
->
hasNonOptionalParams
(
$method
))
{
$propertyName
=
'$'
.
lcfirst
(
substr
(
$method
->
name
,
3
));
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
$property
=
$class
->
properties
[
$propertyName
];
...
...
@@ -299,7 +299,7 @@ class Context extends Component
]);
}
}
if
(
!
strncmp
(
$name
,
'set'
,
3
)
&&
strlen
(
$name
)
>
3
&&
$this
->
paramsOptional
(
$method
,
1
))
{
if
(
!
strncmp
(
$name
,
'set'
,
3
)
&&
strlen
(
$name
)
>
3
&&
$this
->
hasNonOptionalParams
(
$method
,
1
))
{
$propertyName
=
'$'
.
lcfirst
(
substr
(
$method
->
name
,
3
));
if
(
isset
(
$class
->
properties
[
$propertyName
]))
{
$property
=
$class
->
properties
[
$propertyName
];
...
...
@@ -331,18 +331,20 @@ class Context extends Component
}
/**
* Check whether a method has `$number` non-optional parameters.
* @param MethodDoc $method
* @param integer $number number of not optional parameters
* @return bool
*/
private
function
paramsOptional
(
$method
,
$number
=
0
)
private
function
hasNonOptionalParams
(
$method
,
$number
=
0
)
{
$count
=
0
;
foreach
(
$method
->
params
as
$param
)
{
if
(
!
$param
->
isOptional
&&
$number
--
<=
0
)
{
return
false
;
if
(
!
$param
->
isOptional
)
{
$count
++
;
}
}
return
true
;
return
$count
==
$number
;
}
/**
...
...
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