-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6697 from troizet/php_function_guessing_array_ret…
…urn_type PHP: Implemented correct return type guessing for a function that returns an array
- Loading branch information
Showing
13 changed files
with
199 additions
and
3 deletions.
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
2 changes: 2 additions & 0 deletions
2
...beans/modules/php/editor/csl/NavigatorTest/structure/functionGuessingArrayReturnType.pass
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,2 @@ | ||
|-testArrayReturnType [824, 868] : ESCAPED{testArrayReturnType}ESCAPED{(}ESCAPED{)}<font color="#999999">:ESCAPED{array}</font> | ||
|-testArrayReturnTypeWithUnionType [880, 984] : ESCAPED{testArrayReturnTypeWithUnionType}ESCAPED{(}ESCAPED{)}<font color="#999999">:ESCAPED{string}ESCAPED{|}ESCAPED{array}</font> |
29 changes: 29 additions & 0 deletions
29
...ceOverrideMethodWithGuessingArrayType/testInstanceOverrideMethodWithGuessingArrayType.php
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,29 @@ | ||
<?php | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class Foo { | ||
public function myFoo(){ | ||
return [1, 2]; | ||
} | ||
} | ||
|
||
class Bar extends Foo { | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...ethodWithGuessingArrayType.php.testInstanceOverrideMethodWithGuessingArrayType_01.codegen
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,4 @@ | ||
public function myFoo(): array{ | ||
return parent::myFoo(); | ||
} | ||
|
4 changes: 4 additions & 0 deletions
4
...ethodWithGuessingArrayType.php.testInstanceOverrideMethodWithGuessingArrayType_02.codegen
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,4 @@ | ||
public function myFoo(){ | ||
return parent::myFoo(); | ||
} | ||
|
37 changes: 37 additions & 0 deletions
37
...tor/test/unit/data/testfiles/completion/documentation/functionGuessingArrayReturnType.php
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,37 @@ | ||
<?php | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
function testArrayReturnType() | ||
{ | ||
return [1, 2]; | ||
} | ||
|
||
|
||
function testArrayReturnTypeWithUnionType() | ||
{ | ||
if (true) { | ||
return 'string'; | ||
} | ||
return [1, 2]; | ||
} | ||
|
||
testArrayReturnType(); | ||
testArrayReturnTypeWithUnionType(); | ||
|
10 changes: 10 additions & 0 deletions
10
...mentation/functionGuessingArrayReturnType.php.testFunctionGuessingArrayReturnType_01.html
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,10 @@ | ||
<html><body> | ||
<pre>Code completion result for source line: | ||
testArrayReturn|Type(); | ||
(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true) | ||
METHOD testArrayReturnType() [PUBLIC] functionGuessingArrayReturnType.php | ||
</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>testArrayReturnType</b><br/><br/><br /> | ||
<h3>Returns:</h3> | ||
<table> | ||
<tr><th align="left">Type:</th><td>array</td></tr></table></body></html> | ||
|
10 changes: 10 additions & 0 deletions
10
...mentation/functionGuessingArrayReturnType.php.testFunctionGuessingArrayReturnType_02.html
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,10 @@ | ||
<html><body> | ||
<pre>Code completion result for source line: | ||
testArrayReturnTypeWithUnion|Type(); | ||
(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true) | ||
METHOD testArrayReturnTypeWithUnionTy [PUBLIC] functionGuessingArrayReturnType.php | ||
</pre><h2>Documentation:</h2><div align="right"><font size=-1></font></div><b>testArrayReturnTypeWithUnionType</b><br/><br/><br /> | ||
<h3>Returns:</h3> | ||
<table> | ||
<tr><th align="left">Type:</th><td>string | array</td></tr></table></body></html> | ||
|
34 changes: 34 additions & 0 deletions
34
php/php.editor/test/unit/data/testfiles/structure/functionGuessingArrayReturnType.php
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 | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
function testArrayReturnType() | ||
{ | ||
return [1, 2]; | ||
} | ||
|
||
|
||
function testArrayReturnTypeWithUnionType() | ||
{ | ||
if (true) { | ||
return 'string'; | ||
} | ||
return [1, 2]; | ||
} | ||
|
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