Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stub supports void type return value #2124

Merged
merged 2 commits into from
Nov 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Library/Stubs/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ protected function buildMethod(ClassMethod $method, bool $isInterface, string $i
if ($supported > 1) {
$return = '';
}
} elseif (version_compare(PHP_VERSION, '7.1.0', '>=') && $method->isVoid()) {
fagai marked this conversation as resolved.
Show resolved Hide resolved
$return = 'void';
}

if (!empty($return)) {
$return = ': '.$return;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/stubs/issues/expected/Issue_1900.zep.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

134 changes: 134 additions & 0 deletions tests/fixtures/stubs/issues/expected/Issue_1900_PHP70.zep.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/fixtures/stubs/issues/expected/Issue_1986.zep.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions tests/fixtures/stubs/issues/expected/Issue_1986_PHP70.zep.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions tests/sharness/t0005-stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ test_expect_success "Should properly generate type hint" \
test_expect_success "Should properly namespace imports (use block)" \
"test_cmp expected/Issue_1778.zep.php ide/0.0.1/Stubs/Issue_1778.zep.php"

if test_have_prereq PHP70; then
expected="Issue_1900_PHP70.zep.php"
else
expected="Issue_1900.zep.php"
fi
# See: https://github.com/phalcon/zephir/issues/1900
test_expect_success "Should properly generate return types for stubs" \
"test_cmp expected/Issue_1900.zep.php ide/0.0.1/Stubs/Issue_1900.zep.php"
"test_cmp expected/$expected ide/0.0.1/Stubs/Issue_1900.zep.php"

# See: https://github.com/phalcon/zephir/issues/1907
test_expect_success "Should properly generate Namespace for extends" \
Expand All @@ -43,9 +48,14 @@ test_expect_success "Should properly generate Namespace for extends" \
test_expect_success "Should properly generate Namespace for extends (slash)" \
"test_cmp expected/Issue_1907.zep.php ide/0.0.1/Stubs/Issue_1907.zep.php"

if test_have_prereq PHP70; then
expected="Issue_1986_PHP70.zep.php"
else
expected="Issue_1986.zep.php"
fi
# See: https://github.com/phalcon/zephir/issues/1986
test_expect_success "Should properly generate Aliases for use statements" \
"test_cmp expected/Issue_1986.zep.php ide/0.0.1/Stubs/Issue_1986.zep.php"
"test_cmp expected/$expected ide/0.0.1/Stubs/Issue_1986.zep.php"

# See: https://github.com/phalcon/zephir/issues/1896
test_expect_success "Should generage CamelCase folders for stubs" \
Expand Down