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

Adding PHP-CPP Interface to multiple inherited extension classes stops php from executing #425

Open
betrixed opened this issue Aug 28, 2019 · 1 comment

Comments

@betrixed
Copy link

PHP-CPP implementation of interfaces isn't working very well for me.

This issue comes with a github project of some combined PHP-CPP example classes.
The extension example code that has problems with adding interfaces is found at
https://github.com/betrixed/Toml-Pun8
(Previous commit branch master 3779b8ce31bdedd0bae42ec348bfbd47134d670a)

The current master commit had its Interface declarations commented out, because php 7.3 will not run if they were compiled in. Commit number 8dc7e75fc473156465d8faf23c0a3e2cb9914216
"Interface initialisation fails - removed". appears to initialise and run a simple php test script.

This sort of worked for earlier php versions, possibly with PHP-CPP 2.1 and php 7.2. At least it didn't stop php from running.
For what its worth, the project has a string class for utf-8 text processing, features PHP-CPP built in interfaces to implement C++ hash table string keys, KeyTable, and sequential array ValueList, as part of TOML parser, to see how this would go.

To implement the TOML document relations, KeyTable and ValueList derive from a common C++ class, TomlBase, and also multi-inherit the PHP_CPP supplied Php::Countable, ArrayAccess, Traversable, Serialiable.

The examples and documentation on PHP-CPP site are minimal for the interfaces, but then I suppose the source code is all.

So it perhaps stretches the capabilities and complexity of having "implements" user - constructed interfaces by Php::Interface on top of multi-inherited classes. However, the ArrayAccess and others are not declared by Php::Interface construction, they are bolted on deeper in the object works, by classImpl handlers. So checking for interface \ArrayAccess does not work in php code, even if the PHP-CPP extension class has compile this in.

Also I compiled the extension with std=c++17, to take advantage of extra template classes, while the installed shared PHP-CPP library defaults to c++11. That is most likely not an issue.

The two commits can be built with the simple Makefiles. The earlier commit code stops php from starting up, so the error occurs at module registration.

@betrixed
Copy link
Author

I confirmed that a recent 7.2 version and 2.2 PHP-CPP works for adding interface definition to a class, but 7.3 definitely crashes , simply by typing php -v, (a most basic test). I presume PHP 7.3 has different interface registration requirements.

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

No branches or pull requests

1 participant