Skip to content

Commit

Permalink
Add stubs
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <[email protected]>
  • Loading branch information
provokateurin committed Mar 30, 2023
1 parent fe900de commit eee0a76
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/stubs/ini_get_wrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace bantu\IniGetWrapper;

class IniGetWrapper {}
13 changes: 13 additions & 0 deletions build/stubs/psr_clock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Psr\Clock;

use DateTimeImmutable;

interface ClockInterface
{
/**
* Returns the current time as a DateTimeImmutable Object
*/
public function now(): DateTimeImmutable;
}
52 changes: 52 additions & 0 deletions build/stubs/psr_container.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace Psr\Container;

use Throwable;

/**
* Base interface representing a generic exception in a container.
*/
interface ContainerExceptionInterface extends Throwable
{
}

/**
* Describes the interface of a container that exposes methods to read its entries.
*/
interface ContainerInterface
{
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param string $id Identifier of the entry to look for.
*
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*
* @return mixed Entry.
*/
public function get(string $id);

/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($id)` returning true does not mean that `get($id)` will not throw an exception.
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
*
* @param string $id Identifier of the entry to look for.
*
* @return bool
*/
public function has(string $id): bool;
}

/**
* No entry was found in the container.
*/
interface NotFoundExceptionInterface extends ContainerExceptionInterface
{
}
59 changes: 59 additions & 0 deletions build/stubs/psr_eventdispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

namespace Psr\EventDispatcher;

/**
* Defines a dispatcher for events.
*/
interface EventDispatcherInterface
{
/**
* Provide all relevant listeners with an event to process.
*
* @param object $event
* The object to process.
*
* @return object
* The Event that was passed, now modified by listeners.
*/
public function dispatch(object $event);
}

/**
* Mapper from an event to the listeners that are applicable to that event.
*/
interface ListenerProviderInterface
{
/**
* @param object $event
* An event for which to return the relevant listeners.
* @return iterable<callable>
* An iterable (array, iterator, or generator) of callables. Each
* callable MUST be type-compatible with $event.
*/
public function getListenersForEvent(object $event) : iterable;
}

/**
* An Event whose processing may be interrupted when the event has been handled.
*
* A Dispatcher implementation MUST check to determine if an Event
* is marked as stopped after each listener is called. If it is then it should
* return immediately without calling any further Listeners.
*/
interface StoppableEventInterface
{
/**
* Is propagation stopped?
*
* This will typically only be used by the Dispatcher to determine if the
* previous listener halted propagation.
*
* @return bool
* True if the Event is complete and no further listeners should be called.
* False to continue calling listeners.
*/
public function isPropagationStopped() : bool;
}
7 changes: 7 additions & 0 deletions build/stubs/sabre_dav_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

class ServiceUnavailable extends Exception {
}

class NotFound extends Exception {
}
28 changes: 28 additions & 0 deletions build/stubs/symfony_component_eventdispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Symfony\Component\EventDispatcher;

interface EventDispatcherInterface {
public function dispatch(mixed $event): object;
}

class GenericEvent {
public function __construct(mixed $subject = null, array $arguments = []) {
}

public function getArgument(string $key): mixed {
return null;
}

public function setArgument(string $key, mixed $value): GenericEvent {
return $this;
}

public function hasArgument(string $key): bool {
return false;
}

public function isPropagationStopped(): bool {
return false;
}
}
1 change: 1 addition & 0 deletions psalm-ocp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<stubs>
<file name="build/stubs/gd.php"/>
<file name="build/stubs/ldap.php"/>
<file name="build/stubs/psr_container.php"/>
</stubs>
<extraFiles>
<directory name="3rdparty"/>
Expand Down
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
<file name="build/stubs/ftp.php"/>
<file name="build/stubs/pcntl.php"/>
<file name="build/stubs/zip.php"/>
<file name="build/stubs/psr_clock.php"/>
<file name="build/stubs/psr_container.php"/>
<file name="build/stubs/psr_eventdispatcher.php"/>
<file name="build/stubs/ini_get_wrapper.php"/>
<file name="build/stubs/sabre_dav_exception.php"/>
<file name="build/stubs/symfony_component_eventdispatcher.php"/>
<file name="3rdparty/sabre/uri/lib/functions.php" />
</stubs>
<issueHandlers>
Expand Down

0 comments on commit eee0a76

Please sign in to comment.