| 364 | } |
| 365 | |
| 366 | func TestClassParserUnsupportedTypes(t *testing.T) { |
| 367 | tests := []struct { |
| 368 | name string |
| 369 | input string |
| 370 | expectedClasses int |
| 371 | expectedMethods int |
| 372 | hasWarning bool |
| 373 | }{ |
| 374 | { |
| 375 | name: "method with array parameter should be rejected", |
| 376 | input: `package main |
| 377 | |
| 378 | //export_php:class TestClass |
| 379 | type TestClass struct { |
| 380 | Name string |
| 381 | } |
| 382 | |
| 383 | //export_php:method TestClass::arrayMethod(array $data): string |
| 384 | func (tc *TestClass) arrayMethod(data any) unsafe.Pointer { |
| 385 | return nil |
| 386 | }`, |
| 387 | expectedClasses: 1, |
| 388 | expectedMethods: 0, |
| 389 | hasWarning: true, |
| 390 | }, |
| 391 | { |
| 392 | name: "method with object parameter should be rejected", |
| 393 | input: `package main |
| 394 | |
| 395 | //export_php:class TestClass |
| 396 | type TestClass struct { |
| 397 | Name string |
| 398 | } |
| 399 | |
| 400 | //export_php:method TestClass::objectMethod(object $obj): string |
| 401 | func (tc *TestClass) objectMethod(obj any) unsafe.Pointer { |
| 402 | return nil |
| 403 | }`, |
| 404 | expectedClasses: 1, |
| 405 | expectedMethods: 0, |
| 406 | hasWarning: true, |
| 407 | }, |
| 408 | { |
| 409 | name: "method with mixed parameter should be rejected", |
| 410 | input: `package main |
| 411 | |
| 412 | //export_php:class TestClass |
| 413 | type TestClass struct { |
| 414 | Name string |
| 415 | } |
| 416 | |
| 417 | //export_php:method TestClass::mixedMethod(mixed $value): string |
| 418 | func (tc *TestClass) mixedMethod(value any) unsafe.Pointer { |
| 419 | return nil |
| 420 | }`, |
| 421 | expectedClasses: 1, |
| 422 | expectedMethods: 0, |
| 423 | hasWarning: true, |