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

Fix broken assertion; minor other fixes #233

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/FFI.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ public static function version(): string
*/
public static function atLeast(int $x, int $y, int $z = 0): bool
{
return self::$library_major > $x ||
self::$library_major == $x && self::$library_minor > $y ||
self::$library_major == $x && self::$library_minor == $y && self::$library_micro >= $z;
return self::$library_major > $x
|| (self::$library_major === $x && self::$library_minor > $y)
|| (self::$library_major === $x && self::$library_minor === $y && self::$library_micro >= $z);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this fixes (or breaks) anything, but at least it should be clearer now.

}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/GObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private static function getMarshaler(string $name, callable $callback): ?Closure
?CData $data
) use (&$callback): void {
assert($numberOfParams === 3);
/*
/**
* Signature: gint64(VipsSourceCustom* source, void* buffer, gint64 length, void* handle)
*/
$bufferLength = (int)FFI::gobject()->g_value_get_int64(\FFI::addr($params[2]));
Expand Down Expand Up @@ -180,7 +180,7 @@ private static function getMarshaler(string $name, callable $callback): ?Closure
?CData $data
) use (&$callback): void {
assert($numberOfParams === 3);
/*
/**
* Signature: gint64(VipsSourceCustom* source, gint64 offset, int whence, void* handle)
*/
$offset = (int)FFI::gobject()->g_value_get_int64(\FFI::addr($params[1]));
Expand All @@ -201,7 +201,7 @@ private static function getMarshaler(string $name, callable $callback): ?Closure
?CData $data
) use (&$callback): void {
assert($numberOfParams === 3);
/*
/**
* Signature: gint64(VipsTargetCustom* target, void* buffer, gint64 length, void* handle)
*/
$bufferPointer = FFI::gobject()->g_value_get_pointer(\FFI::addr($params[1]));
Expand All @@ -223,7 +223,7 @@ private static function getMarshaler(string $name, callable $callback): ?Closure
CData $hint,
?CData $data
) use (&$callback): void {
assert($numberOfParams === 0);
assert($numberOfParams === 1);
Copy link
Contributor Author

@uuf6429 uuf6429 Feb 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing a test to fail.

I saw that the other asserts checked the param count based on the commented signature - 1, so it looks like this one should have been 1.

As to why it doesn't break in git actions, my guess is that they are running against an older version of libvips? (I noted the if (FFI::atLeast(8, 9)) { on line 217)

Copy link
Contributor Author

@uuf6429 uuf6429 Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As to why it doesn't break in git actions, my guess is that they are running against an older version of libvips? (I noted the if (FFI::atLeast(8, 9)) { on line 217)

Actually, that doesn't seem to be the case. A slightly older successful build used libvips 8.12: https://github.com/libvips/php-vips/actions/runs/7757736861/job/21160084456#step:4:121

Maybe PHP is running in production mode in the GitHub actions, which disables assertions? If that's the case, @jcupitt shouldn't we enable enable them?

/**
* Signature: void(VipsTargetCustom* target, void* handle)
*/
Expand All @@ -242,7 +242,7 @@ private static function getMarshaler(string $name, callable $callback): ?Closure
CData $hint,
?CData $data
) use (&$callback): void {
assert($numberOfParams === 0);
assert($numberOfParams === 1);
/**
* Signature: int(VipsTargetCustom* target, void* handle)
*/
Expand Down
Loading