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

3.4.x php8 #1

Open
wants to merge 22 commits into
base: 3.4.x
Choose a base branch
from
Open

3.4.x php8 #1

wants to merge 22 commits into from

Conversation

Bellardia
Copy link
Contributor

This is a full port of Phalcon 3.4.x to PHP 8.

To get here required modernizing the kernel libraries (ext/kernel/) to be PHP 8 compatible. I'll skip the sausage making for how that works since it requires extensive knowledge of PHP internals. With a PHP 8 capable kernel and updated build configurations, we can then begin to compile Phalcon (ext/phalcon/).

There are several major depreciations in PHP 8 that are frequently used in Phalcon 3.4.x, most commonly the Creation of dynamic property,\Serializable interfaces and required parameters after optional parameters.

Creation of dynamic property occurs when a variable is assigned to a class without it being included in the class definition:

this->{property} = "value"

This is unfortunately is a very common mechanism within Phalcon (especially for Config, Di and Model) . To get around this, I backported changes from Phalcon 5, including a full overhaul of Config.

Config has been redesigned to not assign directly to it's own instance, which allowed for handy features like (array) $di->credentials to transparently convert the underlying stdClass to an array. Without dynamic properties, these values need to be housed somewhere other than the class instance itself, ie. this->data[property] = "value"

This is not fully backwards compatible, but it was possible to rewrite our usage of Config in JBX in a way that's compatible with both versions of Config (original and rewrite) which was a bit easier then building a new Config system that works identically across versions.

Fixing \Serializable and other bugs were generally more straightforward, just modifying the Phalcon source as necessary.

required parameters after optional parameters is also not possible to make fully backwards compatible. This is addressed in the JBX source in necessary locations with PHP version guards which decide which ordering to use. Luckily, our use of ABIs with this issue was minimal.

I have WIP changes that modernizes the Tests (tests/) and gets them working again, but unfortunately some dependencies only support PHP 7.4, so it brings us to a weird place where we can only test the PHP 8 build on PHP 7.4, which doesn't guarantee that it works. Since this was another pretty involved undertaking I abandoned the effort and am relying on our JBX tests instead to verify compatibility.

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.

1 participant