-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for PHP 7 return types to collector
- Loading branch information
Showing
9 changed files
with
201 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2010-2017 Arne Blankerts <[email protected]> | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* * Neither the name of Arne Blankerts nor the names of contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @package phpDox | ||
* @author Arne Blankerts <[email protected]> | ||
* @copyright Arne Blankerts <[email protected]>, All rights reserved. | ||
* @license BSD License | ||
*/ | ||
namespace TheSeer\phpDox\Collector { | ||
|
||
use TheSeer\fDOM\fDOMElement; | ||
|
||
class ReturnTypeObject extends AbstractVariableObject { | ||
|
||
public function __construct(fDOMElement $ctx) { | ||
parent::__construct($ctx); | ||
$this->addInternalType('void'); | ||
} | ||
|
||
public function setNullable($isNullable) { | ||
$this->ctx->setAttribute('nullable', $isNullable ? 'true' : 'false'); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
namespace some\test; | ||
|
||
class NullableReturnType { | ||
|
||
public function floatReturn(): ?float { | ||
return 1.0; | ||
} | ||
|
||
public function intReturn(): ?int { | ||
return 1; | ||
} | ||
|
||
public function stringReturn(): ?string { | ||
return 'abc'; | ||
} | ||
|
||
public function callableReturn(): ?Callable { | ||
return function () {}; | ||
} | ||
|
||
public function boolReturn(): ?bool { | ||
return false; | ||
} | ||
|
||
public function arrayReturn(): ?array { | ||
return []; | ||
} | ||
|
||
public function objectReturn(): ?ReturnType { | ||
return new ReturnType(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<phpdox xmlns="http://xml.phpdox.net/config" silent="false"> | ||
|
||
<project name="phpDox-nullable" source="${basedir}/src" workdir="${basedir}/xml"> | ||
|
||
<collector publiconly="false" backend="parser" /> | ||
|
||
<generator output="${basedir}/docs"> | ||
<build engine="html" enabled="true" output="html" /> | ||
<build engine="xml" enabled="true" output="xml" /> | ||
</generator> | ||
|
||
</project> | ||
|
||
</phpdox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace some\test; | ||
|
||
class ReturnType { | ||
|
||
public function unspecifiedReturn() { | ||
} | ||
|
||
public function voidReturn(): void { | ||
} | ||
|
||
public function floatReturn(): float { | ||
return 1.0; | ||
} | ||
|
||
public function intReturn(): int { | ||
return 1; | ||
} | ||
|
||
public function stringReturn(): string { | ||
return 'abc'; | ||
} | ||
|
||
public function callableReturn(): Callable { | ||
return function () {}; | ||
} | ||
|
||
public function boolReturn(): bool { | ||
return false; | ||
} | ||
|
||
public function arrayReturn(): array { | ||
return []; | ||
} | ||
|
||
public function always(): ReturnType { | ||
return new ReturnType(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<phpdox xmlns="http://xml.phpdox.net/config" silent="false"> | ||
|
||
<project name="phpDox-returntype" source="${basedir}/src" workdir="${basedir}/xml"> | ||
|
||
<collector publiconly="false" backend="parser" /> | ||
|
||
<generator output="${basedir}/docs"> | ||
<build engine="html" enabled="true" output="html" /> | ||
<build engine="xml" enabled="true" output="xml" /> | ||
</generator> | ||
|
||
</project> | ||
|
||
</phpdox> |