openactive / models-php

PHP Models for the OpenActive Opportunity and Booking Specifications
MIT License
6 stars 8 forks source link

Reserved word 'Abstract' used in PropertyEnumeration.php #102

Open drinkynet opened 2 years ago

drinkynet commented 2 years ago

Method OrderItem::setAttendeeDetailsRequired() expects an argument of type \OpenActive\Enums\PropertyEnumeration[] or null passing it an array of instances of Enums (GivenName & FamilyName) generates this syntax error:

PHP Parse error: syntax error, unexpected 'Abstract' (T_ABSTRACT), expecting identifier (T_STRING) in .../vendor/openactive/models/src/Enums/PropertyEnumeration.php on line 88

Line 88 of \OpenActive\Enums\PropertyEnumeration attempts to declare a const called Abstract, which isn't allowed.

Snippet from \OpenActive\Enums\PropertyEnumeration

drinkynet commented 2 years ago

It also doesn't like the use of Yield on line 1533

Snippet of PropertyEnumeration.php

drinkynet commented 2 years ago

Commenting out lines 88 and 1533 lets it work as a quick and dirty fix.

nathansalter commented 2 years ago

This will also happen for any of the reserved PHP words https://www.php.net/manual/en/reserved.keywords.php

After removing words which I feel are unlikely, the list is this:

abstract
break
case
catch
class
clone
const
continue
declare
default
extends
final
finally
for
global
implements
include
interface
list
namespace
new
print
private
protected
public
readonly
require
static
switch
throw
use
while
yield

We should put something in the model generator library to do something else here.

nathansalter commented 2 years ago

Worth noting that:

$v = new OpenActive\Enums\PropertyEnumeration\GivenName;

Works in PHP 8.0+, but fails in earlier PHP versions. Calling $t = new OpenActive\Enums\PropertyEnumeration\Abstract; never works.