Skip to content

Commit

Permalink
Fix to Facade phpdocs; add Pipeline facade; better middleware handler…
Browse files Browse the repository at this point in the history
… for Http Kernel
  • Loading branch information
donwilson committed Nov 16, 2023
1 parent 588c3d8 commit 2bd4905
Show file tree
Hide file tree
Showing 37 changed files with 536 additions and 295 deletions.
2 changes: 1 addition & 1 deletion src/Magnetar/Cache/InMemory/InMemoryStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function get(
return $this->store[ $key ];
}

if(is_null($callback)) {
if(null === $callback) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Magnetar/Cache/Memcached/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function get(
return $value;
}

if(is_null($callback)) {
if(null === $callback) {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Magnetar/Cache/StoreManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function connection(string|null $driver_name=null): AbstractCacheStore {
// interfaces with the app's configuration to create the default cache store
// unless overwritten by driver_name

if(is_null($driver_name)) {
if(null === $driver_name) {
$driver_name = $this->app->make('config')->get('cache.default', null);

if(is_null($driver_name)) {
if(null === $driver_name) {
throw new Exception('No default cache driver specified');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Magnetar/Container/BoundMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected static function callClass(
// we can pass right back into the 'call' method for dependency binding.
$method = ((count($segments) === 2)?$segments[1]:$defaultMethod);

if(is_null($method)) {
if(null === $method) {
throw new InvalidArgumentException('Method not provided.');
}

Expand Down Expand Up @@ -188,7 +188,7 @@ protected static function addDependencyForCallParameter(
$dependencies[] = $parameters[ $paramName ];

unset($parameters[ $paramName ]);
} elseif(!is_null($className = Helper::getParameterClassName($parameter))) {
} elseif(null !== ($className = Helper::getParameterClassName($parameter))) {
if(array_key_exists($className, $parameters)) {
$dependencies[] = $parameters[ $className ];

Expand Down
28 changes: 14 additions & 14 deletions src/Magnetar/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function bind(
// forget old references
$this->dropStaleInstances($abstract);

if(is_null($concrete)) {
if(null === $concrete) {
$concrete = $abstract;
}

Expand Down Expand Up @@ -736,7 +736,7 @@ protected function resolve(
$concrete = $this->getContextualConcrete($abstract);

// if parameters are provided, we need to create a contextualized instance
$needsContextualBuild = (!empty($parameters) || !is_null($concrete));
$needsContextualBuild = (!empty($parameters) || (null !== $concrete));

// if the instance is already resolved and there's no context, return it
if(isset($this->instances[ $abstract ]) && !$needsContextualBuild) {
Expand All @@ -745,7 +745,7 @@ protected function resolve(

$this->with[] = $parameters;

if(is_null($concrete)) {
if(null === $concrete) {
$concrete = $this->getConcrete($abstract);
}

Expand Down Expand Up @@ -796,7 +796,7 @@ protected function getConcrete(string|callable $abstract): mixed {
* @return Closure|string|array|null The concrete instance
*/
protected function getContextualConcrete(string|callable $abstract): Closure|string|array|null {
if(!is_null($binding = $this->findInContextualBindings($abstract))) {
if(null !== ($binding = $this->findInContextualBindings($abstract))) {
return $binding;
}

Expand All @@ -805,7 +805,7 @@ protected function getContextualConcrete(string|callable $abstract): Closure|str
}

foreach($this->abstractAliases[ $abstract ] as $alias) {
if(!is_null($binding = $this->findInContextualBindings($alias))) {
if(null !== ($binding = $this->findInContextualBindings($alias))) {
return $binding;
}
}
Expand Down Expand Up @@ -866,7 +866,7 @@ public function build(Closure|string $concrete): mixed {
// If there are no constructors, that means there are no dependencies then
// we can just resolve the instances of the objects right away, without
// resolving any other types or dependencies out of these containers.
if(is_null($constructor)) {
if(null === $constructor) {
array_pop($this->buildStack);

return new $concrete;
Expand Down Expand Up @@ -905,7 +905,7 @@ protected function resolveDependencies(array $dependencies): array {
continue;
}

$result = is_null(Helper::getParameterClassName($dependency))
$result = (null === Helper::getParameterClassName($dependency))
? $this->resolvePrimitive($dependency)
: $this->resolveClass($dependency);

Expand Down Expand Up @@ -953,7 +953,7 @@ protected function getLastParameterOverride(): array {
* @throws ResolvingDependenciesException
*/
protected function resolvePrimitive(ReflectionParameter $parameter): mixed {
if(!is_null($concrete = $this->getContextualConcrete('$'. $parameter->getName()))) {
if(null !== ($concrete = $this->getContextualConcrete('$'. $parameter->getName()))) {
return Helper::unwrapIfClosure($concrete, $this);
}

Expand Down Expand Up @@ -1056,7 +1056,7 @@ public function beforeResolving(
$abstract = $this->getAlias($abstract);
}

if(($abstract instanceof Closure) && is_null($callback)) {
if(($abstract instanceof Closure) && (null === $callback)) {
$this->globalBeforeResolvingCallbacks[] = $abstract;
} else {
$this->beforeResolvingCallbacks[ $abstract ][] = $callback;
Expand All @@ -1077,7 +1077,7 @@ public function resolving(
$abstract = $this->getAlias($abstract);
}

if(is_null($callback) && ($abstract instanceof Closure)) {
if((null === $callback) && ($abstract instanceof Closure)) {
$this->globalResolvingCallbacks[] = $abstract;
} else {
$this->resolvingCallbacks[ $abstract ][] = $callback;
Expand All @@ -1098,7 +1098,7 @@ public function afterResolving(
$abstract = $this->getAlias($abstract);
}

if(($abstract instanceof Closure) && is_null($callback)) {
if(($abstract instanceof Closure) && (null === $callback)) {
$this->globalAfterResolvingCallbacks[] = $abstract;
} else {
$this->afterResolvingCallbacks[ $abstract ][] = $callback;
Expand Down Expand Up @@ -1299,7 +1299,7 @@ public function flush(): void {
* @return static
*/
public static function getInstance(): static {
if(is_null(static::$instance)) {
if(null === static::$instance) {
static::$instance = new static;
}

Expand All @@ -1308,8 +1308,8 @@ public static function getInstance(): static {

/**
* Set the shared instance of the container
* @param Container|null $container The container to set as the shared instance
* @return Container|static The shared instance
* @param \Magnetar\Container\Container|null $container The container to set as the shared instance
* @return \Magnetar\Container\Container|static The shared instance
*/
public static function setInstance(Container|null $container = null): Container|static {
return static::$instance = $container;
Expand Down
4 changes: 2 additions & 2 deletions src/Magnetar/Container/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Helper {
* @return array
*/
public static function arrayWrap(mixed $value) {
if(is_null($value)) {
if(null === $value) {
return [];
}

Expand Down Expand Up @@ -51,7 +51,7 @@ public static function getParameterClassName(ReflectionParameter $parameter): st

$name = $type->getName();

if(!is_null($class = $parameter->getDeclaringClass())) {
if(null !== ($class = $parameter->getDeclaringClass())) {
if('self' === $name) {
return $class->getName();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Magnetar/Database/HasQuickQueryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function get_col_assoc(

foreach($raw_rows as $row) {
// determine key column
if(is_null($assoc_col)) {
if(null === $assoc_col) {
if(isset($row[ $assoc_key ]) && ($assoc_key !== $column_key)) {
$assoc_col = $assoc_key;
} else {
Expand All @@ -197,7 +197,7 @@ public function get_col_assoc(
}

// determine value column
if(is_null($value_col)) {
if(null === $value_col) {
if(isset($row[ $column_key ])) {
$value_col = $column_key;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Magnetar/Database/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function selectRaw(string $field, ?string $as=null): self {
throw new QueryBuilderException('Field for selectRaw is empty');
}

if(!is_null($as) && ($as !== $field)) {
if((null !== $as) && ($as !== $field)) {
$this->fields[] = $field .' as `'. $as .'`';
} else {
$this->fields[] = $field;
Expand Down
2 changes: 1 addition & 1 deletion src/Magnetar/Helpers/AliasLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
*/
public static function getInstance(array $aliases=[]): AliasLoader {
// if the instance hasn't been created yet, use the given aliases and create it
if(is_null(static::$instance)) {
if(null === static::$instance) {
return static::$instance = new static($aliases);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Magnetar/Helpers/DefaultServiceProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ public function __construct(
?array $providers=null
) {
$this->providers = $providers ?? [
\Magnetar\Auth\AuthServiceProvider::class,
\Magnetar\Cache\CacheServiceProvider::class,
\Magnetar\Http\CookieJar\CookieJarServiceProvider::class,
\Magnetar\Database\DatabaseServiceProvider::class,
\Magnetar\Filesystem\FilesystemServiceProvider::class,
\Magnetar\Queue\QueueServiceProvider::class,
\Magnetar\Template\TemplateServiceProvider::class,
];
}
Expand Down
Loading

0 comments on commit 2bd4905

Please sign in to comment.