HomeDevCentral

Fix PhabricatorStory::getRepositoryPHID null exception

Description

Fix PhabricatorStory::getRepositoryPHID null exception

Summary:
When Phabricator fires an notification about an object the Notifications
bot users can't see, PhabricatorStory::getRepositoryPHID API reply is [].

As the code tried to access it as an object, a null exception ensues.
The issue is similar to T916 / f1e56313d6e9.

Fixes T993.

Test Plan:

<?php

namespace Nasqueron\Notifications\Tests;

use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzer;
use Nasqueron\Notifications\Notifications\PhabricatorNotification;
use Nasqueron\Notifications\Phabricator\PhabricatorStory;

class T993Test extends TestCase {

    /**
     * Test T993 is solved.
     */
    public function testT993 () {
        $data = file_get_contents(__DIR__ . '/T993.payload.json');
        $payload = json_decode($data, true);
        $project = "Nasqueron";
        $instance = 'https://devcentral.nasqueron.org';

        $story = PhabricatorStory::loadFromArray($instance, $payload);
        $notification = new PhabricatorNotification($project, $story);
    }

}

Reviewers: dereckson

Maniphest Tasks: T993

Differential Revision: https://devcentral.nasqueron.org/D622