Skip to content

Commit 7de362c

Browse files
committed
Backport rewriting error suppression operator
1 parent 51d00dc commit 7de362c

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/main/php/io/Path.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,9 @@ private static function real0($path, $wd) {
198198
} else {
199199
$normalized.= DIRECTORY_SEPARATOR.$component;
200200
if ($check) {
201-
$stat= @lstat($normalized);
201+
$stat= lstat($normalized);
202202
if (false === $stat) {
203+
\xp::gc(__FILE__);
203204
$check= false;
204205
} else if (0120000 === ($stat[2] & 0120000)) {
205206
$normalized= readlink($normalized);

src/main/php/lang/FileSystemClassLoader.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ public static function instanceFor($path, $expand= true) {
153153
*/
154154
public function packageContents($package) {
155155
$contents= [];
156-
if ($d= @dir($this->path.strtr($package, '.', DIRECTORY_SEPARATOR))) {
156+
$path= $this->path.strtr($package, '.', DIRECTORY_SEPARATOR);
157+
if (is_dir($path)) {
158+
$d= dir($path);
157159
while ($e= $d->read()) {
158160
if ('.' != $e{0}) $contents[]= $e.(is_dir($d->path.DIRECTORY_SEPARATOR.$e) ? '/' : '');
159161
}

src/main/php/lang/XPClass.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,8 @@ public function hasAnnotation($name, $key= null): bool {
587587
$details= self::detailsForClass($this->name);
588588

589589
return $details && ($key
590-
? @array_key_exists($key, @$details['class'][DETAIL_ANNOTATIONS][$name])
591-
: @array_key_exists($name, @$details['class'][DETAIL_ANNOTATIONS])
590+
? array_key_exists($key, $details['class'][DETAIL_ANNOTATIONS][$name] ?? [])
591+
: array_key_exists($name, $details['class'][DETAIL_ANNOTATIONS] ?? [])
592592
);
593593
}
594594

@@ -603,8 +603,8 @@ public function hasAnnotation($name, $key= null): bool {
603603
public function getAnnotation($name, $key= null) {
604604
$details= self::detailsForClass($this->name);
605605
if (!$details || !($key
606-
? @array_key_exists($key, @$details['class'][DETAIL_ANNOTATIONS][$name])
607-
: @array_key_exists($name, @$details['class'][DETAIL_ANNOTATIONS])
606+
? array_key_exists($key, $details['class'][DETAIL_ANNOTATIONS][$name] ?? [])
607+
: array_key_exists($name, $details['class'][DETAIL_ANNOTATIONS] ?? [])
608608
)) {
609609
throw new ElementNotFoundException('Annotation "'.$name.($key ? '.'.$key : '').'" does not exist');
610610
}

0 commit comments

Comments
 (0)