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

Get the class using its name, not just its namespace name #2429

Merged
merged 1 commit into from
May 11, 2024

Conversation

27pchrisl
Copy link
Contributor

Hi!

In raising this pull request, I confirm the following:

  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR (not yet, but I can do if this is a correct fix)
  • I updated the CHANGELOG

Small description of change: I made this change while diagnosing why https://github.com/RubixML/Tensor could not be compiled against PHP 8.3, it was encountering the same issue as described in #2277.

The compile errors were, for example:
/Users/chrisl/Code/Tensor/ext/tensor/vector.zep.c:3715:30: error: use of undeclared identifier '_tensor_ce'

This was because for an example class Tensor\Vector the compiler was generating the identifier _tensor_ce instead of tensor_vector_ce.

I tracked this down to

$classNamespace = explode(self::NAMESPACE_SEPARATOR, $reflection->getNamespaceName());
in the area where the code has different techniques for discovering the class name and namespace.

If I force the code to use the simpler technique by making the conditional at

if (class_exists($this->classname) || interface_exists($this->classname)) {
false, it gets $classNamespace and $className correctly for the code that follows the if statement. It appeared that $classNamespace should be the FQDN, not just the namespace.

I was not sure whether this was the correct fix for this issue, so I welcome any feedback.

Copy link

sonarcloud bot commented May 11, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Jeckerson Jeckerson merged commit 424bd30 into zephir-lang:development May 11, 2024
18 of 23 checks passed
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.

2 participants