Skip to content

Commit 91754d0

Browse files
committed
Throw Error instead of PropertyNotDefined/InvalidArgumentException
1 parent b00472b commit 91754d0

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ None
2020

2121
### Other Changes
2222

23-
Updated PHPUnit to v9.6 to avoid [vulnerability](https://github.com/ICanBoogie/Inflector/security/dependabot/1).
23+
- Updated PHPUnit to v9.6 to avoid [vulnerability](https://github.com/ICanBoogie/Inflector/security/dependabot/1).
24+
- Throw `Error` instead of `PropertyNotDefined`/`InvalidArgumentException`.
25+
- Remove dependency on `icanboogie/common`.
26+
2427

2528

2629

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"ext-mbstring": "*"
3434
},
3535
"require-dev": {
36-
"icanboogie/common": "^2.1",
3736
"phpstan/phpstan": "^2.1",
3837
"phpunit/phpunit": "^9.6.34|^11.4"
3938
},

lib/Inflections.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,15 @@ public static function get(string $locale = Inflector::DEFAULT_LOCALE): Inflecti
106106
*
107107
* @return mixed
108108
*
109-
* @throws PropertyNotDefined in an attempt to read an inaccessible property. If the {@see PropertyNotDefined}
110-
* class is not available a {@see \InvalidArgumentException} is thrown instead.
109+
* @throws \Error in an attempt to read an inaccessible property.
111110
*/
112111
public function __get(string $property)
113112
{
114113
if (isset(self::READERS[$property])) {
115114
return $this->$property;
116115
}
117116

118-
if (class_exists(PropertyNotDefined::class)) {
119-
throw new PropertyNotDefined([ $property, $this ]);
120-
} else {
121-
throw new InvalidArgumentException("Property not defined: $property");
122-
}
117+
throw new \Error("Undefined property: " . self::class . "::\$$property");
123118
}
124119

125120
/**

lib/Inflector.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,15 @@ public function __construct(?Inflections $inflections = null)
6262
* Returns the {@see $inflections} property.
6363
*
6464
* @return mixed
65-
* @throws PropertyNotDefined in an attempt to read an inaccessible property. If the {@see PropertyNotDefined}
66-
* class is not available a {@see InvalidArgumentException} is thrown instead.
65+
* @throws \Error in an attempt to read an inaccessible property.
6766
*/
6867
public function __get(string $property)
6968
{
7069
if ($property === 'inflections') {
7170
return $this->$property;
7271
}
7372

74-
if (class_exists(PropertyNotDefined::class)) {
75-
throw new PropertyNotDefined([ $property, $this ]);
76-
} else {
77-
throw new InvalidArgumentException("Property not defined: $property");
78-
}
73+
throw new \Error("Undefined property: " . static::class . "::\$$property");
7974
}
8075

8176
/**

0 commit comments

Comments
 (0)