Skip to content

Commit

Permalink
Minor tweaks and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-redfern committed Jan 3, 2024
1 parent d855d4b commit 8040008
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.0', '8.1', '8.2']
php-version: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .idea/enumeration.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ function handleHttpRequest(HttpRequestMethod $method, $url, $body = null)
}
```

__Note:__ for simple enumerations, it is recommended to use PHPs native backed enums.

[c++ enumerated types]: https://en.wikipedia.org/wiki/Enumerated_type#C.2B.2B

## Accessing enumeration members
Expand Down Expand Up @@ -95,7 +97,7 @@ in this implementation are Multitons. The `AbstractEnumeration` class simply
defines its members based upon class constants.

Here is an example borrowed from the Java documentation for its enum types. The
following multiton describes all of the planets in our solar system, including
following multiton describes all the planets in our solar system, including
their masses and radii:

```php
Expand Down Expand Up @@ -138,7 +140,8 @@ final class Planet extends AbstractMultiton
new static('SATURN', 5.6851e26, 6.0268e7);
new static('URANUS', 8.6849e25, 2.5559e7);
new static('NEPTUNE', 1.0244e26, 2.4764e7);
// new static('PLUTO', 1.31e22, 1.180e6);
// Pluto will always be a planet to me!
new static('PLUTO', 1.31e22, 1.180e6);
}

/**
Expand All @@ -160,7 +163,7 @@ final class Planet extends AbstractMultiton
```

The above class can be used to take a known weight on earth (in any unit) and
calculate the weight on all of the planets (in the same unit):
calculate the weight on all the planets (in the same unit):

```php
$earthWeight = 175;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": ">=8.0"
"php": ">=8.1"
},
"require-dev": {
"phpunit/phpunit": "^10.4"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<logging/>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="XDEBUG_MODE" value="coverage" />
<ini name="xdebug.mode" value="coverage" />
</php>
<source>
<include>
Expand Down
7 changes: 7 additions & 0 deletions src/AbstractMultiton.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ final public function __unserialize(array $data): void
throw new RuntimeException(sprintf('Cannot unserialize instances of %s', self::class));
}

final public function __set(string $name, $value): void
{
}

final public function __unset(string $name): void
{
}

/**
* Registers the supplied member.
Expand Down

0 comments on commit 8040008

Please sign in to comment.