Skip to content

Commit 82fa963

Browse files
committed
fix: only alias if the alias exists
This adds a check to ensure that the alias exists as either a class, interface, or trait before attempting to call `class_alias()`.
1 parent 6f38312 commit 82fa963

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 0.2.2 - 2019-04-10
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Changed
12+
13+
- Nothing.
14+
15+
### Deprecated
16+
17+
- Nothing.
18+
19+
### Removed
20+
21+
- Nothing.
22+
23+
### Fixed
24+
25+
- Added a check that the discovered alias exists as a class, interface, or trait
26+
before attempting to call `class_alias()`.
27+
528
## 0.2.1 - 2019-04-10
629

730
### Added

src/Autoloader.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public static function load()
3636
}
3737

3838
$alias = $classes[$check] . substr($class, strlen($check));
39-
class_alias($alias, $class);
39+
40+
if (class_exists($alias) || interface_exists($alias) || trait_exists($alias)) {
41+
class_alias($alias, $class);
42+
}
4043
});
4144
}
4245
}

0 commit comments

Comments
 (0)