text:
namespace Rsdn.Configuration
{
    using System;
    using System.ComponentModel;
    using System.Linq;
    using System.Reflection;
    using Client;
    using Client.Data;
    using Client.Data.Storage;
    using Community.Interaction.Requests;
    using Community.Presentation;
    using Community.Presentation.Infrastructure;
    using Community.Presentation.NavigationModel;
    using Relay.RequestModel;
    using Relay.RequestModel.Default;
    using SimpleInjector;
    using SimpleInjector.Diagnostics;
    using Windows.UI.Xaml.Controls;

    internal static class ObjectGraph
    {
        private class ContainerWrapper : IServiceProvider, IPresenterProvider
        {
            public ContainerWrapper(Container container)
            {
                this.Container = container;
            }

            public Container Container { get; }

            TViewModel IPresenterProvider.Get<TViewModel>()
            {
                return this.Container.GetInstance<TViewModel>();
            }

            object IServiceProvider.GetService(Type serviceType)
            {
                try
                {
                    return this.Container.GetInstance(serviceType);
                }
                catch (ActivationException)
                {
                    return null;
                }
            }
        }

        public static IServiceProvider Build(Frame presentationFrame)
        {
            var wrapper = new ContainerWrapper(new Container());

            BuildData(wrapper);
            BuildManagement(wrapper, presentationFrame);
            BuildControl(wrapper);
            BuildPresentation(wrapper);

#if DEBUG
            wrapper.Container.Verify();
#endif
            return wrapper;
        }

        private static void BuildData(ContainerWrapper wrapper)
        {
            var dataAccessAssembly = typeof(Gateway).GetTypeInfo().Assembly;
            var baseGatewayIface = typeof(IGateway);

            var registrations =
                from type in dataAccessAssembly.GetExportedTypes()
                where type.GetTypeInfo().IsAbstract == false &&
                    type.GetInterfaces().Contains(baseGatewayIface)
                select new
                {
                    Service = type.GetInterfaces().Single(iface =>
                        iface != baseGatewayIface &&
                        baseGatewayIface.IsAssignableFrom(iface)),
                    Implementation = type
                };

            foreach (var reg in registrations)
            {
                wrapper.Container.Register(reg.Service, reg.Implementation, Lifestyle.Singleton);
            }
        }

        private static void BuildManagement(ContainerWrapper wrapper, Frame presentationFrame)
        {
            wrapper.Container
                .RegisterSingleton<INavigationService>(
                    () => new FrameNavigationService(presentationFrame, navigationStackName: "AppFrame"));

            wrapper.Container
                .RegisterSingleton<ICredentialManager, CredentialManager>();
            wrapper.Container
                .RegisterSingleton<IUpdateManager, UpdateManager>();
        }

        private static void BuildControl(ContainerWrapper wrapper)
        {
            var controlAssemblies = new[] { typeof(IGateway).GetTypeInfo().Assembly };

            wrapper.Container
                .RegisterSingleton<IRequestDispatcher>(() => new DefaultRequestDispatcher(wrapper));

            wrapper.Container
                .Register(typeof(IQueryHandler<,>), controlAssemblies);
            wrapper.Container
                .Register(typeof(IAsyncQueryHandler<,>), controlAssemblies);

            wrapper.Container
                .Register(typeof(ICommandHandler<>), controlAssemblies);
            wrapper.Container
                .Register(typeof(IAsyncCommandHandler<>), controlAssemblies);

            wrapper.Container
                .RegisterSingleton<IEventDispatcher>(() => new EventDispatcher(wrapper.Container));
            // We don't register blindly all event handlers here,
            // only presenters are registered as event handlers later in BuildPresentation

#if DEBUG
            wrapper.Container
                .RegisterDecorator(typeof(IRequestDispatcher), typeof(DebugRequestDispatcher), Lifestyle.Singleton);
#endif
        }

        private static void BuildPresentation(ContainerWrapper wrapper)
        {
            var presentationAssembly = typeof(PresenterLocator).GetTypeInfo().Assembly;
            var excludedServiceTypes = new[] {
                typeof(IDisposable), typeof(INotifyPropertyChanged),
                typeof(INavigable), typeof(ITombstone)
            };

            var registrations = (from presenterType in presentationAssembly.GetExportedTypes()
                                 let isPagePresenter = presenterType.GetTypeInfo().IsSubclassOf(typeof(NavigablePresenter))
                                 let isDialogPresenter = presenterType.GetTypeInfo().IsSubclassOf(typeof(DialogPresenter))
                                 where presenterType.GetTypeInfo().IsAbstract == false && (isPagePresenter || isDialogPresenter)
                                 select new
                                 {
                                     Services = presenterType.GetInterfaces().Except(excludedServiceTypes).ToArray(),
                                     Implementation = presenterType,
                                     Registration = isPagePresenter ?
                                        Lifestyle.Singleton.CreateRegistration(presenterType, wrapper.Container) :
                                        Lifestyle.Transient.CreateRegistration(presenterType, wrapper.Container),
                                     IsTransient = isDialogPresenter,
                                 }).ToArray();

            foreach (var reg in registrations)
            {
                wrapper.Container.AddRegistration(reg.Implementation, reg.Registration);
                if (reg.IsTransient)
                {
                    reg.Registration.SuppressDiagnosticWarning(DiagnosticType.DisposableTransientComponent,
                        justification: "Dialog presenter lifetime is handled by DialogManager.");
                }
            }

            // Mostly these are event handler interfaces
            var serviceTypes = registrations.SelectMany(reg => reg.Services).Distinct();
            foreach (var item in serviceTypes)
            {
                var serviceType = item;
                var implRegistrations = from reg in registrations
                                        where reg.Services.Contains(serviceType)
                                        select reg.Registration;

                foreach (var reg in implRegistrations)
                    wrapper.Container.AddRegistration(serviceType, reg);
            }

            wrapper.Container
                .RegisterSingleton<IDialogManager, DialogManager>();
            wrapper.Container
                .RegisterSingleton(() => new PresenterLocator(wrapper));
        }
    }
}


text:
<?php
namespace Lithe\User\Tests;

use GrahamCampbell\TestBench\AbstractPackageTestCase;

class AbstractTestCase extends AbstractPackageTestCase
{

    /**
     * Setup the test environment.
     */
    public function setUp()
    {
        parent::setUp();

        $this->artisan('migrate', [
            '--database' => 'testbench',
            '--realpath' => realpath(__DIR__ . '/../resources/database/migrations')
        ]);

        $this->app['config']->set('auth.model', 'Lithe\User\Models\User');
    }

    /**
     * (non-PHPdoc)
     *
     * @see \GrahamCampbell\TestBench\AbstractPackageTestCase::getEnvironmentSetUp()
     */
    protected function getEnvironmentSetUp($app)
    {
        $app['config']->set('database.default', 'testbench');
        $app['config']->set('database.connections.testbench', [
            'driver' => 'sqlite',
            'database' => ':memory:',
            'prefix' => ''
        ]);
    }

    /**
     * (non-PHPdoc)
     *
     * @see \GrahamCampbell\TestBench\AbstractPackageTestCase::getPackageProviders()
     */
    protected function getPackageProviders($app)
    {
        return [
            //'Lithe\Theme\ThemeServiceProvider',
            //'Lithe\Lithe\ModuleServiceProvider'
        ];
    }

    /**
     * Test running migration.
     *
     * @test
     */
    public function testRunningMigration()
    {
        $users = \DB::table('users')->where('id', '=', 1)->first();
        $this->assertEquals('matthew@javelet.net', $users->email);
        $this->assertTrue(\Hash::check('123bee', $users->password));
    }
}

redpajama_set_name: RedPajamaGithub


text:
What kind of issue is this?

 - [ ] Question. This issue tracker is not the place for questions. If you want to ask how to do
       something, or to understand why something isn't working the way you expect it to, use Stack
       Overflow. https://stackoverflow.com/questions/tagged/MultiType

 - [ ] Bug report. If you've found a bug, spend the time to write a failing test. Please provide
       your device name, device OS version, and describe the reproduction steps.

 - [ ] Feature Request. Start by telling us what problem you're trying to solve. Often a solution
       already exists! Don't send pull requests to implement new features without first getting our
       support. Sometimes we leave features out on purpose to keep the project small.

###### Info:

 - MultiType version:
 - Device OS version:
 - Device Name:

###### Description:

###### Reproduction Steps:

###### My thoughts:

###### What did I do:


text:
<?php

namespace Monad;

class Identity extends Monad
{
    public static $unit = [__CLASS__, 'unit'];

    public function bind(callable $transform)
    {
        return $this->runTransform($transform);
    }

    public function __toString()
    {
        return "Identity({$this->value})";
    }
}


text:
<?php
/*
Plugin Name: Users Only
Plugin URI: https://github.com/jacobbuck/wp-users-only
Description: Restrict a website to logged in users only, and disable the dashboard for non-admin user types.
Version: 2.2.2
Author: Jacob Buck
Author URI: http://jacobbuck.co.nz/
*/

require('class.users_only.php');
require('class.users_only_settings.php');
require('class.users_only_shortcodes.php');

Users_Only::initialize();
Users_Only_Settings::initialize();
Users_Only_Shortcodes::initialize();


text:
.PHONY: qa lint cs csf phpstan tests coverage

all:
	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs

vendor: composer.json composer.lock
	composer install

qa: lint cs

lint: vendor
	vendor/bin/parallel-lint -e php,phpt src

cs: vendor
	vendor/bin/phpcs -sp --standard=vendor/nella/coding-standard/Nella/ruleset.xml src