Skip to content

Commit

Permalink
documented all public methods on facades for typehinting
Browse files Browse the repository at this point in the history
  • Loading branch information
BenRutlandWeb committed Feb 13, 2021
1 parent 778ed71 commit b879f68
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Radiate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function text(string $path, array $data = []): self
*/
public function view(string $path, array $data = []): self
{
$this->html = View::view($path, $this->buildViewData($data));
$this->html = View::make($path, $this->buildViewData($data));

return $this;
}
Expand Down
26 changes: 13 additions & 13 deletions Radiate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ public function __construct(Dispatcher $events, Application $app)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function ajax(string $uri, $action)
{
return $this->addRoute(new AjaxRoute('AJAX', $uri, $action));
}

/**
* Create an GET route
* Create a GET route
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function get(string $uri, $action)
{
Expand All @@ -86,7 +86,7 @@ public function get(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function post(string $uri, $action)
{
Expand All @@ -98,7 +98,7 @@ public function post(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function put(string $uri, $action)
{
Expand All @@ -110,7 +110,7 @@ public function put(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function patch(string $uri, $action)
{
Expand All @@ -122,32 +122,32 @@ public function patch(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function delete(string $uri, $action)
{
return $this->addRoute(new RestRoute('DELETE', $uri, $action));
}

/**
* Create an route with any method
* Create a route with any method
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function any(string $uri, $action)
{
return $this->addRoute(new RestRoute(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'], $uri, $action));
}

/**
* Create an route matching the given methods
* Create a route matching the given methods
*
* @param array $methods
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function matches(array $methods, string $uri, $action)
{
Expand Down Expand Up @@ -190,8 +190,8 @@ public function resource(string $uri, string $action, array $methods = ['index',
/**
* Regsiter the route in the router
*
* @param Radiate\Routing\Route $route
* @return void
* @param \Radiate\Routing\Route $route
* @return \Radiate\Routing\Route
*/
public function addRoute(Route $route)
{
Expand Down
2 changes: 1 addition & 1 deletion Radiate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ public function tap(callable $callback)
public function toArray(): array
{
return $this->map(function ($value) {
return $value instanceof CollectionInterface
return $value instanceof Collection
? $value->toArray()
: $value;
})->all();
Expand Down
25 changes: 25 additions & 0 deletions Radiate/Support/Facades/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

namespace Radiate\Support\Facades;

/**
* @method static string basePath(string $path = null) Get the app base path
* @method static void register(string $provider) Register a service provider
* @method static \Radiate\Foundation\Application middleware(array $middleware) Add a global middleware to the app
* @method static \Radiate\Foundation\Application routeMiddleware(array $middleware) Add a global middleware to the app
* @method static array getRouteMiddleware() Get the route middleware
* @method static void boot() Boot the application
* @method static string getNamespace() Get the app namespace
* @method static bool runningInConsole() Determine if the app is running in the console
* @method static string renderException(\Radiate\Http\Request $request, \Throwable $e) Render an HTTP exception
* @method static string|bool environment(string|array|null $environments = null) Get or check the current application environment.
* @method static bool isLocal() Determine if the app is in a local environment
* @method static bool isDevelopment() Determine if the app is in a development environment
* @method static bool isStaging() Determine if the app is in a staging environment
* @method static bool isProduction() Determine if the app is in a production environment
* @method static void instance(string $abstract, mixed $concrete) Register an existing instance in the container.
* @method static void bind(string $abstract, \Closure $concrete, bool $shared = false) Register a binding with the container.
* @method static void singleton(string $abstract, \Closure $concrete) Register a shared binding with the container.
* @method static bool has(string $abstract) Determine if the abstract is bound to the container
* @method static mixed get(string $abstract) Resolve an instance
* @method static \Radiate\Foundation\Application getInstance() Get the container instance
* @method static \Radiate\Foundation\Application setInstance(\Radiate\Container\Container $container = null) Set the container instance
*
* @see \Radiate\Foundation\Application, \Radiate\Container\Container
*/
class App extends Facade
{
/**
Expand Down
83 changes: 83 additions & 0 deletions Radiate/Support/Facades/Arr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace Radiate\Support\Facades;

use Radiate\Support\Collection;

/**
* @method static \Radiate\Support\Collection add(array $items, mixed $item) Add an item to the collection.
* @method static array all(array $items) Get the collection items
* @method static \Radiate\Support\Collection chunk(array $items, int $size) Split a collection into chunks
* @method static \Radiate\Support\Collection combine(array $items, mixed $values) Create a collection by using this collection for keys and another for its values
* @method static \Radiate\Support\Collection diff(array $items, mixed $items) Get the items in the collection that are not present in the given items
* @method static \Radiate\Support\Collection each(array $items, callable $callback) Execute a callback over each item
* @method static \Radiate\Support\Collection except(array $items, string ...$keys) Get all items except for those with the specified keys.
* @method static \Radiate\Support\Collection filter(array $items, ?callable $callback = null) Iterates over each item in the collection passing them to the callback function
* @method static mixed first(array $items) Gets the first item of the collection
* @method static string|int|null firstKey(array $items) Gets the first key of the collection
* @method static \Radiate\Support\Collection flatten(array $items) Flatten a multi-dimensional array into a single level
* @method static \Radiate\Support\Collection flip(array $items) Exchanges all keys with their associated values in a collection
* @method static \Radiate\Support\Collection forget(array $items, string $key) Unset an item in the collection
* @method static mixed get(array $items, string $key, mixed $default) Get an item from the collection
* @method static bool has(array $items, string $key) Determine if an item in the collection exists
* @method static bool hasKey(array $items, string $key) Determine if the given key or index exists in the collection
* @method static \Radiate\Support\Collection intersect(array $items, mixed $items) Intersect the collection with the given items
* @method static \Radiate\Support\Collection intersectByKeys(array $items, mixed $items) Computes the intersection of the collection using keys for comparison
* @method static bool isEmpty(array $items) Determine if the collection is empty or not
* @method static bool isNotEmpty(array $items) Determine if the collection is empty or not
* @method static string join(array $items, string $glue) Join all items from the collection using a string.
* @method static \Radiate\Support\Collection keys(array $items) Get the keys from the collection
* @method static mixed last(array $items) Gets the last item of the collection
* @method static string|int|null lastKey(array $items) Gets the last key of the collection
* @method static \Radiate\Support\Collection map(array $items, callable $callback) Applies the callback to the elements of the collection
* @method static \Radiate\Support\Collection merge(array $items, mixed $array) Merge the collection with the given items
* @method static \Radiate\Support\Collection mergeRecursive(array $items, mixed $array) Recursively merge the collection with the given items
* @method static \Radiate\Support\Collection only(array $items, string ...$keys) Get the items with the specified keys
* @method static mixed pipe(array $items, callable $callback) Pass the collection to the given callback and return the result
* @method static mixed pop(array $items) Get and remove the last item from the collection
* @method static \Radiate\Support\Collection prepend(array $items, mixed $value, string|int|null $key = null) Push an item onto the beginning of the collection
* @method static \Radiate\Support\Collection push(array $items, mixed ...$values) Push elements onto the end of the collection
* @method static \Radiate\Support\Collection put(array $items, string $key, mixed $value) Push keyed elements onto the end of the collection
* @method static mixed|static random(array $items, int $number = 1, bool $preserveKeys = false) Pick one or more random entries out of the collection
* @method static mixed reduce(array $items, callable $callback, mixed $initial = null) Reduce the collection to a single value
* @method static \Radiate\Support\Collection replace(array $items, mixed $items) Replace the collection items with the given items
* @method static \Radiate\Support\Collection replaceRecursive(array $items, mixed $items) Recursively replace the collection items with the given items
* @method static \Radiate\Support\Collection reverse(array $items) Return a collection with elements in reverse order
* @method static int|string|false search(array $items, mixed $value, bool $strict = false) Searches the collection for a given value and returns the corresponding key if successful
* @method static mixed shift(array $items) Shift an element off the beginning of the collection
* @method static \Radiate\Support\Collection shuffle(array $items) Shuffle the items in the collection
* @method static \Radiate\Support\Collection skip(array $items, int $count) Skip the first x number of items
* @method static \Radiate\Support\Collection slice(array $items, int $offset, ?int $length = null) Extract a slice of the collection
* @method static \Radiate\Support\Collection take(array $items, int $limit) Take the first or last x number of items from the collection
* @method static \Radiate\Support\Collection tap(array $items, callable $callback) Pass the collection to the given callback and then return it
* @method static \Radiate\Support\Collection values(array $items) Return all the values of the collection
*
* @see \Radiate\Support\Collection
*/
class Arr
{
/**
* Make a new instance of stringable
*
* @param array $array
* @return \Radiate\Support\Collection
*/
public static function collect(array $array)
{
return new Collection($array);
}

/**
* Dynamically call the Stringable class
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic(string $method, array $parameters)
{
$arr = (new Collection(array_shift($parameters)))->$method(...$parameters);

return $arr instanceof Collection ? $arr->toArray() : $arr;
}
}
10 changes: 10 additions & 0 deletions Radiate/Support/Facades/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

namespace Radiate\Support\Facades;

/**
* @method static void listen(string|string[] $events, mixed $listener, int $priority = 10, int $argCount = 5) Create an event listener
* @method static bool hasListeners(string $event) Determine if an event has listeners
* @method static mixed dispatch(string $event, mixed ...$payload) Dispatch an event
* @method static void forget(string $event) Forget the event listeners
* @method static void subscribe(string $subscriber) Register an event subscriber with the dispatcher.
* @method static mixed resolveListener(mixed $listener) Resolve a listener
*
* @see \Radiate\Events\Dispatcher
*/
class Event extends Facade
{
/**
Expand Down
26 changes: 26 additions & 0 deletions Radiate/Support/Facades/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

namespace Radiate\Support\Facades;

/**
* @method static \Radiate\Routing\Route ajax(string $uri, mixed $action) Create an ajax route
* @method static \Radiate\Routing\Route get(string $uri, mixed $action) Create a GET route
* @method static \Radiate\Routing\Route post(string $uri, mixed $action) Create a POST route
* @method static \Radiate\Routing\Route put(string $uri, mixed $action) Create a PUT route
* @method static \Radiate\Routing\Route patch(string $uri, mixed $action) Create a PATCH route
* @method static \Radiate\Routing\Route delete(string $uri, mixed $action) Create a DELETE route
* @method static \Radiate\Routing\Route any(string $uri, mixed $action) Create a route with any method
* @method static \Radiate\Routing\Route matches(array $methods, string $uri, mixed $action) Create a route matching the given methods
* @method static void resource(string $uri, string $action, array $methods = ['index', 'show', 'store', 'update', 'destroy']) Create resource routes
* @method static \Radiate\Routing\Route addRoute(\Radiate\Routing\Route $route) Regsiter the route in the router
* @method static bool hasGroupStack() Determine if the router currently has a group stack.
* @method static array getMergedGroupStack() Return the merged group stack
* @method static \Radiate\Routing\Router middleware(string|array $middleware) Set a group middleware
* @method static array getMiddleware() Get the group middleware
* @method static \Radiate\Routing\Router prefix(string $prefix) Set the group prefix
* @method static string getPrefix() Get the group prefix
* @method static \Radiate\Routing\Router namespace(string $namespace) Set the group namespace
* @method static string getNamespace() Get the group namespace
* @method static void group(\Closure|string $routes) Define a group in the router
* @method static void dispatch(\Radiate\Http\Request $request) Dispatch the request to the routes
* @method static void listen(string|string[] $events, mixed $callback) Listen to an event
*
* @see \Radiate\Routing\Router
*/

class Route extends Facade
{
/**
Expand Down
Loading

0 comments on commit b879f68

Please sign in to comment.