Skip to content

Regenerate the stubs to remove inaccessible symbols #62

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

Merged
merged 2 commits into from
Feb 9, 2023
Merged

Regenerate the stubs to remove inaccessible symbols #62

merged 2 commits into from
Feb 9, 2023

Conversation

johnbillion
Copy link
Contributor

This doesn't need to be merged (unless you want to). I updated the stubs generator and regenerated the stubs after php-stubs/generator#15 . This PR shows which symbols have been removed.

@johnbillion
Copy link
Contributor Author

Roughly 4% decrease in the size of the stub file.

@herndlm
Copy link
Contributor

herndlm commented Feb 9, 2023

not much unfortunately, but better than nothing I guess :)

@szepeviktor
Copy link
Member

szepeviktor commented Feb 9, 2023

This doesn't need to be merged (unless you want to).

Decision! It makes viktor go crazy!!!
Please be half-boolean with me.

@johnbillion
Copy link
Contributor Author

johnbillion commented Feb 9, 2023

if (!empty(true===true)) merge()

@herndlm
Copy link
Contributor

herndlm commented Feb 9, 2023

MERGE IT!

@szepeviktor
Copy link
Member

Please add ^0.8.3 constraint

"php-stubs/generator": "^0.8.1",

@szepeviktor
Copy link
Member

Thank you.

CI misses this part of the generator script.

# Add ReturnTypeWillChange attribute to PHP 8-incompatible methods.
declare -r -a REQUESTS_V1_METHODS=(
"Requests_Cookie_Jar::getIterator"
"Requests_Cookie_Jar::offsetExists"
"Requests_Cookie_Jar::offsetGet"
"Requests_Cookie_Jar::offsetSet"
"Requests_Cookie_Jar::offsetUnset"
"Requests_Utility_CaseInsensitiveDictionary::getIterator"
"Requests_Utility_CaseInsensitiveDictionary::offsetExists"
"Requests_Utility_CaseInsensitiveDictionary::offsetGet"
"Requests_Utility_CaseInsensitiveDictionary::offsetSet"
"Requests_Utility_CaseInsensitiveDictionary::offsetUnset"
"Requests_Utility_FilteredIterator::current"
"Requests_Utility_FilteredIterator::__unserialize"
"Requests_Utility_FilteredIterator::unserialize"
)
for METHOD in "${REQUESTS_V1_METHODS[@]}"; do
# Get the line number where the method is defined.
LINE="$(php -r "require 'wordpress-stubs.php'; print (new ReflectionMethod('${METHOD}'))->getStartLine();")"
if [ -z "${LINE}" ]; then
continue
fi
echo "${METHOD} is defined on line ${LINE}."
# Check the previous line for ReturnTypeWillChange attribute.
if sed -e "$((LINE - 1)) !d" "${FILE}" | grep -q -F '#[ReturnTypeWillChange]'; then
continue
fi
# Grab leading whitespace on the current line so we can indent ReturnTypeWillChange correctly.
LEADING_WHITESPACES="$(sed -e "${LINE} !d;s#^\\(\\s\\+\\).*\$#\\1#" "${FILE}")"
# Insert the ReturnTypeWillChange attribute.
sed -i -e "${LINE} i\\" -e "${LEADING_WHITESPACES}#[ReturnTypeWillChange]" "${FILE}"
done

@szepeviktor szepeviktor merged commit 2a0a9d6 into php-stubs:master Feb 9, 2023
@szepeviktor
Copy link
Member

All right. I add it myself ...

@johnbillion johnbillion deleted the remove-inaccessible-symbols branch February 9, 2023 11:09
@szepeviktor
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants