gtkforphp / cairo

PHP extension for Cairo Graphics Library
Other
27 stars 19 forks source link

using enums with Cairo/Context not working anymore under php 7.1 #34

Open swen100 opened 6 years ago

swen100 commented 6 years ago

Hi Elizabeth,

I wanted to try out cairo under php 7.1, but suddenly i got an error. Setting the Fillrule, Antialias (or any other enum) under php 7.0.x works fine, but under 7.1 it raises an TypeError :(

<?php

$surface = new \Cairo\Surface\Image(
    \Cairo\Surface\ImageFormat::ARGB32, 1, 1
);

$context = new \Cairo\Context($surface);

// var_dump( \Cairo\FillRule::EVEN_ODD );

try {
    $context->setFillRule( \Cairo\FillRule::EVEN_ODD );
    $context->setAntialias( \Cairo\Antialias::SUBPIXEL );
} catch (\TypeError $e) {
    echo $e->getMessage(), "\n";
}

gives me: "Value 1 provided is not a const in enum Cairo\FillRule"

Please, can u take a look at it? I would be very appriciate.

Swen

swen100 commented 6 years ago

Hm, when I remove the error-supressing code (ZEND_PARSE_PARAMS_QUIET) in zend_parse_parameters_ex() I get the following:

mod_fcgid: stderr: PHP Fatal error:  Uncaught TypeError: Cairo\\Context::setFillRule() expects parameter 1 to be Cairo\\FillRule, integer given
auroraeosrose commented 6 years ago

This looks like a typehinting issue... I'd have to check changes in the macros underneath - ugh. For now the workaround would be to use enum objects (new Antialias(Antialias::SUBPIXEL)) which is wordy

swen100 commented 6 years ago

Maybe pull request https://github.com/eosforphp/structures/pull/3 fixes this issue? Seems to be very related to issue https://github.com/gtkforphp/cairo/issues/29