<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Generate hastag from a webpage</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

Generate hastag from a webpage

      <?php
        $this->load->helper('form');
        echo form_open("/Hashtags/generate_tags",array('class'=>'form-inline'));
      ?>

           <input type="text" class="form-control" name="url" placeholder="Enter the site url here" required>

         <button type="submit" class="btn btn-primary">Go!</button>
      </form>

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Generate hastag from a webpage</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

Generate hastag from a webpage

      <?php
        $this->load->helper('form');
        echo "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
        echo form_open("/Hashtags/generate_tags",array('class'=>'form-inline'));
      ?>

           <input type="text" class="form-control" name="url" placeholder="Enter the site url here" required>

         <button type="submit" class="btn btn-primary">Go!</button>
      </form>

Use normal without extra libs

Use normal without extra libs


<?php
$pdo = new PDO('mysql:host=mysql.hostinger.co.uk;dbname=u897984522_immo', 'u897984522_asdev', 'RevoK2016I');

<?php
$pdo = new PDO('mysql:host=localhost;dbname=annahda', 'root', '');

Fix contrat-status issues - Date : 21/11/2016


<?php namespace Odoo\Client\Test\Output;

use Odoo\Client\Output\UrlOutput;

class UrlOutputTest extends \PHPUnit_Framework_TestCase
{
    public function testCreateUrl()
    {
        $urlOutput = new UrlOutput();

        $host = 'test.example.com';
        $port = 8069;
        $type = null;

        $output = $urlOutput->createUrl($host, $port, $type);

        $this->assertSame('test.example.com:8069', $output);
    }
}

<?php namespace Odoo\Client\Test\Output;

use Odoo\Client\Output\UrlOutput;

class UrlOutputTest extends \PHPUnit_Framework_TestCase
{
    public function testCreateUrl()
    {
        $urlOutput = new UrlOutput();

        $host = 'test.example.com';
        $port = 8069;
        $type = null;
        $expected = 'test.example.com:8069';

        $output = $urlOutput->createUrl($host, $port, $type);

        $this->assertSame($expected, $output);
    }
}

Add exptected variable for test case

[REF] Add exptected variable for test case


<?php

/**
 * PHP Version 5.3
 *
 * @copyright   (c) 2014-2015 brian ridley
 * @author      brian ridley <ptlis@ptlis.net>
 * @license     http://opensource.org/licenses/MIT MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ptlis\SemanticVersion\Test\Parse;

use ptlis\SemanticVersion\Parse\Token;
use ptlis\SemanticVersion\Parse\VersionParser;
use ptlis\SemanticVersion\Version\Label\LabelBuilder;

class ParseRangeTest extends TestDataProvider
{
    /**
     * @dataProvider tokenProvider
     *
     * @param string $version
     * @param Token[] $tokenList
     * @param array $expectedValueList
     */
    public function testParseRange($version, $tokenList, $expectedValueList, $expectedSerialization)
    {
        $parser = new VersionParser(new LabelBuilder());

        $range = $parser->parseRange($tokenList);

        $this->assertEquals(
            $expectedValueList,
            $range
        );

        $this->assertEquals(
            $expectedSerialization,
            strval($range)
        );
    }
}

<?php

/**
 * PHP Version 5.3
 *
 * @copyright   (c) 2014-2015 brian ridley
 * @author      brian ridley <ptlis@ptlis.net>
 * @license     http://opensource.org/licenses/MIT MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace ptlis\SemanticVersion\Test\Parse;

use ptlis\SemanticVersion\Parse\VersionParser;
use ptlis\SemanticVersion\Version\Label\LabelBuilder;

class ParseRangeTest extends TestDataProvider
{
    /**
     * @dataProvider tokenProvider
     */
    public function testParseRange($version, $tokenList, $expectedRange, $expectedSerialization)
    {
        $parser = new VersionParser(new LabelBuilder());

        $range = $parser->parseRange($tokenList);

        $this->assertEquals(
            $expectedRange,
            $range
        );

        $this->assertEquals(
            $expectedSerialization,
            strval($range)
        );
    }

    /**
     * @dataProvider tokenProvider
     */
    public function testSerializeRange($version, $tokenList, $expectedRange, $expectedSerialization)
    {
        $this->assertEquals(
            $expectedSerialization,
            strval($expectedRange)
        );
    }
}

Refactor parser tests to split out checks


<?php

namespace Blasting\Http;

use Phroute\Phroute\RouteCollector;

/**
 * Routes
 */
final class Routes
{
    public $router;

    public function __construct()
    {
        $this->router = new RouteCollector;
    }

    public function __invoke()
    {
        // Check middleware size, and register middleware
        if (sizeof((new Layers)()) > 0) {
            foreach ((new Layers)() as $key => $fqcn) {
                $this->router->filter($key, function () use ($fqcn) {
                    return (new $fqcn)->handle();
                });
            }
        }

        $this->router->get('/', [\Blasting\Controllers\HomeController::class, 'index']);
        return $this->router->getData();
    }
}

<?php

/**
 * Routes
 */
$route = new League\Route\RouteCollection;

$route->get('/', '\Blasting\Controllers\HomeController::index');

return $route;

Change route implementation using League/Route


<?php
/**
 * This comment block is used just to make IDE suggestions to work
 * @var $this \Ip\View
 */
?>
<?php echo $this->subview('_header.php'); ?>

<?php

if ('search' == $site->getCurrentZoneName()) {
    $layout = 'singleColumn';
} else {
    $layout = $this->getThemeOption('layout', 'doubleColumn');
}

?>

<div role="main" class="<?php echo $layout ?>">

        <?php echo $this->generateBlock('main')->exampleContent('MAIN'); ?>

    <?php if ($layout == 'doubleColumn') { ?>

            <?php echo $this->generateBlock('main2')->exampleContent('main2'); ?>

    <?php } ?>

<?php echo $this->subview('_footer.php'); ?>

<?php
/**
 * This comment block is used just to make IDE suggestions to work
 * @var $this \Ip\View
 */
?>
<?php echo $this->subview('_header.php'); ?>

<?php

if ('search' == $site->getCurrentZoneName()) {
    $layout = 'singleColumn';
} else {
    $layout = $this->getThemeOption('layout', 'doubleColumn');
}

?>

<div role="main" class="<?php echo $layout ?>">

        <?php echo $this->generateBlock('main')->exampleContent('MAIN'); ?>

    <?php if ($layout == 'doubleColumn') { ?>

            <?php echo $this->generateBlock('side1')->exampleContent('Side1'); ?>

    <?php } ?>

<?php echo $this->subview('_footer.php'); ?>

Use name side1 for sidebar slot

Use name side1 for sidebar slot


<?php

namespace ProAI\Datamapper\Support\Traits;

use ProAI\Datamapper\Annotations as ORM;

trait Versionable
{
    /**
     * @ORM\Column(type="integer", unsigned=true)
     */
    protected $latestVersion;

    /**
     * @ORM\Column(type="integer", unsigned=true, primary=true)
     * @ORM\Versioned
     */
    protected $version;
}

<?php

namespace ProAI\Datamapper\Support\Traits;

use ProAI\Datamapper\Annotations as ORM;

trait Versionable
{
    /**
     * @ORM\Column(type="integer", unsigned=true)
     */
    protected $latestVersion;

    /**
     * @ORM\Id
     * @ORM\Column(type="integer", unsigned=true, primary=true)
     * @ORM\Versioned
     */
    protected $version;

    /**
     * @return string
     */
    public function latestVersion()
    {
        return $this->latestVersion->version();
    }

    /**
     * @return string
     */
    public function version()
    {
        return $this->version->version();
    }
}

Fix primary key for version column

Fix primary key for version column


<?php

namespace Oro\Bundle\DataAuditBundle\Migrations\Schema\v1_6;

use Doctrine\DBAL\Schema\Schema;

use Doctrine\DBAL\Types\Type;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\OrderedMigrationInterface;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class SetNotNullable implements Migration, OrderedMigrationInterface
{
    /** {@inheritdoc} */
    public function getOrder()
    {
        return 30;
    }

    /**
     * {@inheritdoc}
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        $auditTable = $schema->getTable('oro_audit');
        $auditTable->getColumn('type')->setType(Type::getType(Type::STRING))->setOptions(['length' => 255]);
        $auditTable->addIndex(['type'], 'idx_oro_audit_type');

        $auditFieldTable = $schema->getTable('oro_audit_field');
        $auditFieldTable->getColumn('type')->setType(Type::getType(Type::STRING))->setOptions(['length' => 255]);
        $auditFieldTable->addIndex(['type'], 'idx_oro_audit_field_type');
    }
}

<?php

namespace Oro\Bundle\DataAuditBundle\Migrations\Schema\v1_6;

use Doctrine\DBAL\Schema\Schema;

use Doctrine\DBAL\Types\Type;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\OrderedMigrationInterface;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class SetNotNullable implements Migration, OrderedMigrationInterface
{
    /** {@inheritdoc} */
    public function getOrder()
    {
        return 30;
    }

    /**
     * {@inheritdoc}
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        $auditTable = $schema->getTable('oro_audit');
        $auditTable->getColumn('type')
            ->setType(Type::getType(Type::STRING))
            ->setOptions(['length' => 255, 'notnull' => true]);
        $auditTable->addIndex(['type'], 'idx_oro_audit_type');

        $auditFieldTable = $schema->getTable('oro_audit_field');
        $auditFieldTable->getColumn('type')
            ->setType(Type::getType(Type::STRING))
            ->setOptions(['length' => 255, 'notnull' => true]);
        $auditFieldTable->addIndex(['type'], 'idx_oro_audit_field_type');
    }
}

Add STI for audit - fix migrations

BB-1334: Add STI for audit
- fix migrations


<?php

namespace Oro\Bundle\FeatureToggleBundle\Checker;

trait FeatureCheckerHolderTrait
{
    /**
     * @var FeatureChecker
     */
    protected $featureChecker;

    /**
     * @var array
     */
    protected $features = [];

    /**
     * @param FeatureChecker $checker
     */
    public function setFeatureChecker(FeatureChecker $checker)
    {
        $this->featureChecker = $checker;
    }

    /**
     * @param string $feature
     */
    public function addFeature($feature)
    {
        $this->features[] = $feature;
    }

    /**
     * @param null|int|object $scopeIdentifier
     * @return bool
     */
    public function isFeaturesEnabled($scopeIdentifier = null)
    {
        foreach ($this->features as $feature) {
            if (!$this->featureChecker->isFeatureEnabled($feature, $scopeIdentifier)) {
                return false;
            }
        }

        return true;
    }

    /**
     * @param string|null $route
     * @param null|int|object $scopeIdentifier
     *
     * @return bool
     */
    public function isRouteEnabled($route = null, $scopeIdentifier = null)
    {
        return $this->featureChecker->isResourceEnabled($route, 'routes', $scopeIdentifier);
    }
}

<?php

namespace Oro\Bundle\FeatureToggleBundle\Checker;

trait FeatureCheckerHolderTrait
{
    /**
     * @var FeatureChecker
     */
    protected $featureChecker;

    /**
     * @var array
     */
    protected $features = [];

    /**
     * @param FeatureChecker $checker
     */
    public function setFeatureChecker(FeatureChecker $checker)
    {
        $this->featureChecker = $checker;
    }

    /**
     * @param string $feature
     */
    public function addFeature($feature)
    {
        $this->features[] = $feature;
    }

    /**
     * @param null|int|object $scopeIdentifier
     * @return bool
     */
    public function isFeaturesEnabled($scopeIdentifier = null)
    {
        foreach ($this->features as $feature) {
            if (!$this->featureChecker->isFeatureEnabled($feature, $scopeIdentifier)) {
                return false;
            }
        }

        return true;
    }
}

CRM-6121: Disable email as a feature
- Updated unit tests for navigation history builder


<?php namespace Orchestra\Testbench\Http;

use Exception;

class Kernel extends \Illuminate\Foundation\Http\Kernel
{
    /**
     * The bootstrap classes for the application.
     *
     * @return void
     */
    protected $bootstrappers = [];

    /**
     * The application's middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    ];

    /**
     * Report the exception to the exception handler.
     *
     * @param  \Exception  $e
     *
     * @return void
     *
     * @throws \Exception
     */
    protected function reportException(Exception $e)
    {
        throw $e;
    }
}

<?php namespace Orchestra\Testbench\Http;

use Exception;

class Kernel extends \Illuminate\Foundation\Http\Kernel
{
    /**
     * The bootstrap classes for the application.
     *
     * @return void
     */
    protected $bootstrappers = [];

    /**
     * The application's middleware stack.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        ],

        'api' => [
            'throttle:60,1',
        ],
    ];

    /**
     * Report the exception to the exception handler.
     *
     * @param  \Exception  $e
     *
     * @return void
     *
     * @throws \Exception
     */
    protected function reportException(Exception $e)
    {
        throw $e;
    }
}

Add middleware group option and populate 'web' group.

Closes #104.

Signed-off-by: crynobone <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php

namespace ForkCMS\Bundle\InstallerBundle\Form\Handler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;

/**
 * Validates and saves the data from the languages form
 *
 * @author Wouter Sioen <wouter.sioen@wijs.be>
 */
class LanguagesHandler
{
    public function process(Form $form, Request $request)
    {
        if (!$request->isMethod('POST')) {
            return false;
        }

        $form->handleRequest($request);

        if ($form->isValid()) {
            return $this->processValidForm($form, $request);
        }

        return false;
    }

    public function processValidForm(Form $form, $request)
    {
        $data = $form->getData();

        // different fields for single and multiple language
        $data->setLanguages(
            ($data->getLanguageType() === 'multiple')
                ? $data->getLanguages()
                : array($data->getDefaultLanguage())
        );

        // take same_interface_language field into account
        $data->setInterfaceLanguages(
            ($data->getSameInterfaceLanguage() === true)
                ? $data->getLanguages()
                : $data->getInterfaceLanguages()
        );

        if ($data->getSameInterfaceLanguage() === true) {
            $data->setDefaultInterfaceLanguage($data->getDefaultLanguage());
        }

        $request->getSession()->set('installation_data', $data);

        return true;
    }
}

<?php

namespace ForkCMS\Bundle\InstallerBundle\Form\Handler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;

/**
 * Validates and saves the data from the languages form
 *
 * @author Wouter Sioen <wouter.sioen@wijs.be>
 */
class LanguagesHandler
{
    public function process(Form $form, Request $request)
    {
        if (!$request->isMethod('POST')) {
            return false;
        }

        $form->handleRequest($request);

        if ($form->isValid()) {
            return $this->processValidForm($form, $request);
        }

        return false;
    }

    public function processValidForm(Form $form, $request)
    {
        $data = $form->getData();

        // different fields for single and multiple language
        $data->setLanguages(
            ($data->getLanguageType() === 'multiple')
                ? $data->getLanguages()
                : array($data->getDefaultLanguage())
        );

        // take same_interface_language field into account
        $data->setInterfaceLanguages(
            ($data->getSameInterfaceLanguage() === true)
                ? $data->getLanguages()
                : $data->getInterfaceLanguages()
        );

        $request->getSession()->set('installation_data', $data);

        return true;
    }
}

Make CMS default interface language install correctly.

We could have a situation where:
* Language == Interface languages (so SameInterfaceLanguages is true)
* Default language != Default Interface language.

This wasn't possible anymore. This changes makes sure the
'sameInterfaceLanguages' check does not enforce the same default
language anymore.


<?php

namespace TeiEditionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 *
 *
 */
trait ArticleReferencesTrait
{
    /* Currently simple sort by article title */
    protected function sortArticleReferences($articleReferences)
    {
        usort($articleReferences, function ($a, $b) {
            return strcmp(mb_strtolower($a->getArticle()->getName(), 'UTF-8'),
                          mb_strtolower($b->getArticle()->getName(), 'UTF-8'));
        });

        return $articleReferences;
    }

    public function getArticleReferences($lang = null, $ignoreArticles = null)
    {
        if (is_null($this->articleReferences)) {
            return [];
        }

        if (is_null($lang)) {
            return $this->articleReferences->toArray();
        }

        $langCode3 = \TeiEditionBundle\Utils\Iso639::code1to3($lang);

        $ignoreArticleIds = [];
        if (!is_null($ignoreArticles)) {
            foreach ($ignoreArticles as $article) {
                $ignoreArticleIds[] = $article->getId();
            }
        }

        return $this->sortArticleReferences($this->articleReferences->filter(
            function ($entity) use ($langCode3, $ignoreArticleIds) {
                if (in_array($entity->getArticle()->getId(), $ignoreArticleIds)) {
                    return false;
                }

                return 1 == $entity->getArticle()->getStatus()
                    && $entity->getArticle()->getLanguage() == $langCode3;
            }
        )->toArray());
    }
}

<?php

namespace TeiEditionBundle\Entity;

/**
 *
 *
 */
trait ArticleReferencesTrait
{
    /* Currently simple sort by article title */
    protected function sortArticleReferences($articleReferences)
    {
        usort($articleReferences, function ($a, $b) {
            return strcmp(mb_strtolower($a->getArticle()->getName(), 'UTF-8'),
                          mb_strtolower($b->getArticle()->getName(), 'UTF-8'));
        });

        return $articleReferences;
    }

    public function getArticleReferences($lang = null, $ignoreArticles = null)
    {
        if (is_null($this->articleReferences)) {
            return [];
        }

        if (is_null($lang)) {
            return $this->articleReferences->toArray();
        }

        $langCode3 = \TeiEditionBundle\Utils\Iso639::code1to3($lang);

        $ignoreArticleIds = [];
        if (!is_null($ignoreArticles)) {
            foreach ($ignoreArticles as $article) {
                $ignoreArticleIds[] = $article->getId();
            }
        }

        return $this->sortArticleReferences($this->articleReferences->filter(
            function ($entity) use ($langCode3, $ignoreArticleIds) {
                if (is_null($entity->getArticle())) {
                    // orphaned references, should only happen on manual delete
                    return false;
                }

                if (in_array($entity->getArticle()->getId(), $ignoreArticleIds)) {
                    return false;
                }

                return 1 == $entity->getArticle()->getStatus()
                    && $entity->getArticle()->getLanguage() == $langCode3;
            }
        )->toArray());
    }
}

Add guard for orphaned references

Add guard for orphaned references


<?php

use yii\db\Migration;

class m160516_095943_init extends Migration
{
    public function up()
    {
        $tableOptions = null;

        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%Cart}}', [
            'sessionId' => $this->string(),
            'cartData' => $this->text(),
            'PRIMARY KEY (`sessionId`)'
        ], $tableOptions);
    }

    public function down()
    {
        $this->dropTable('{{%Cart}}');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}

<?php

use yii\db\Migration;

class m160516_095943_init extends Migration
{
    public function up()
    {
        $tableOptions = null;

        if ($this->db->driverName === 'mysql' || $this->db->driverName === 'mariadb') {

            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

            $this->createTable('{{%Cart}}', [
            'sessionId' => $this->string(),
            'cartData' => 'longtext',
            'PRIMARY KEY (`sessionId`)'
            ], $tableOptions);

        }else{

            $this->createTable('{{%Cart}}', [
            'sessionId' => $this->string(),
            'cartData' => $this->text(),
            'PRIMARY KEY (`sessionId`)'
            ], $tableOptions);
        }

    }

    public function down()
    {
        $this->dropTable('{{%Cart}}');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}

Use longtext instead of text in mysql and mariadb

Text is too short for some objects .. so this pull request is a proposal to use longtext instead of text in mysql and mariadb


<?php
use \DF\Phalcon\Cli\Task;
use \PVL\SyncManager;

class CacheTask extends Task
{
    public function clearAction()
    {
        // Flush local cache.
        \DF\Cache::clean();

        $this->printLn('Local cache flushed.');

        // Flush CloudFlare cache.
        if (DF_APPLICATION_ENV == 'production') {
            $apis = $this->config->apis->toArray();
            if (isset($apis['cloudflare'])) {
                $url_base = 'https://www.cloudflare.com/api_json.html';
                $url_params = array(
                    'tkn' => $apis['cloudflare']['api_key'],
                    'email' => $apis['cloudflare']['email'],
                    'a' => 'fpurge_ts',
                    'z' => $apis['cloudflare']['domain'],
                    'v' => '1',
                );

                $url = $url_base . '?' . http_build_query($url_params);
                $result_raw = @file_get_contents($url);

                $result = @json_decode($result_raw, true);

                if ($result['result'] == 'success')
                    $this->printLn('CloudFlare cache flushed successfully.');
                else
                    $this->printLn('CloudFlare error: ' . $result['msg']);
            }
        }
    }
}

<?php
use \DF\Phalcon\Cli\Task;
use \PVL\SyncManager;

class CacheTask extends Task
{
    public function clearAction()
    {
        // Flush Doctrine cache.
        $em = $this->di->get('em');

        $cacheDriver = $em->getConfiguration()->getMetadataCacheImpl();
        $cacheDriver->deleteAll();

        $queryCacheDriver = $em->getConfiguration()->getQueryCacheImpl();
        $queryCacheDriver->deleteAll();

        $resultCacheDriver = $em->getConfiguration()->getResultCacheImpl();
        $resultCacheDriver->deleteAll();

        $this->printLn('Doctrine ORM cache flushed.');

        // Flush local cache.
        \DF\Cache::clean();

        $this->printLn('Local cache flushed.');

        // Flush CloudFlare cache.
        if (DF_APPLICATION_ENV == 'production') {
            $apis = $this->config->apis->toArray();
            if (isset($apis['cloudflare'])) {
                $url_base = 'https://www.cloudflare.com/api_json.html';
                $url_params = array(
                    'tkn' => $apis['cloudflare']['api_key'],
                    'email' => $apis['cloudflare']['email'],
                    'a' => 'fpurge_ts',
                    'z' => $apis['cloudflare']['domain'],
                    'v' => '1',
                );

                $url = $url_base . '?' . http_build_query($url_params);
                $result_raw = @file_get_contents($url);

                $result = @json_decode($result_raw, true);

                if ($result['result'] == 'success')
                    $this->printLn('CloudFlare cache flushed successfully.');
                else
                    $this->printLn('CloudFlare error: ' . $result['msg']);
            }
        }
    }
}

Add metadata/query/result cache flush to "cache:clear" CLI command.


<?php

require __DIR__.'/../vendor/autoload.php';

class HelloController
{
    public function worldAction($request)
    {
        return "Hallo welt, got swag yo!\n";
    }
}

$container = Yolo\createContainer(
    [
        'debug' => true,
    ],
    [
        new Yolo\DependencyInjection\MonologExtension(),
        new Yolo\DependencyInjection\ServiceControllerExtension(),
        new Yolo\DependencyInjection\CallableExtension(
            'controller',
            function ($configs, $container) {
                $container->register('hello.controller', 'HelloController');
            }
        ),
    ]
);

$app = new Yolo\Application($container);

$app->get('/', 'hello.controller:worldAction');

$app->run();

<?php

require __DIR__.'/../vendor/autoload.php';

class HelloController
{
    private $name;

    public function __construct($name)
    {
        $this->name = $name;
    }

    public function worldAction($request)
    {
        return "Hello, I'm {$this->name}.\n";
    }
}

$container = Yolo\createContainer(
    [
        'hello.name' => 'the amazing app',
    ],
    [
        new Yolo\DependencyInjection\ServiceControllerExtension(),
        new Yolo\DependencyInjection\CallableExtension(
            'controller',
            function ($configs, $container) {
                $container->register('hello.controller', 'HelloController')
                          ->addArgument('%hello.name%');
            }
        ),
    ]
);

$app = new Yolo\Application($container);

$app->get('/', 'hello.controller:worldAction');

$app->run();

Add parameter to service controller example


<?php
/*
Plugin Name: ZnWP Taxonomy Color and Image Plugin
Plugin URI:  https://github.com/zionsg/ZnWP-Taxonomy-Color-Image-Plugin
Description: This plugin allows multiple 3rd party plugins to easily add color and image fields to taxonomies. Demo plugin included.
Author:      Zion Ng
Author URI:  http://intzone.com/
Version:     1.0.0
*/

require_once 'ZnWP_Taxonomy_Color_Image.php'; // PSR-1 states files should not declare classes AND execute code

// init must be run after theme setup to allow functions.php in theme to add action hook
$znwp_taxonomy_color_image_plugin = new ZnWP_Taxonomy_Color_Image();
add_action('after_setup_theme', array($znwp_taxonomy_color_image_plugin, 'init'));

<?php
/*
Plugin Name: ZnWP Taxonomy Color and Image Plugin
Plugin URI:  https://github.com/zionsg/ZnWP-Taxonomy-Color-Image-Plugin
Description: This plugin allows multiple 3rd party plugins to easily add color, image and order fields to taxonomies. Demo plugin included.
Author:      Zion Ng
Author URI:  http://intzone.com/
Version:     1.0.0
*/

require_once 'ZnWP_Taxonomy_Color_Image.php'; // PSR-1 states files should not declare classes AND execute code

// init must be run after theme setup to allow functions.php in theme to add action hook
$znwp_taxonomy_color_image_plugin = new ZnWP_Taxonomy_Color_Image();
add_action('after_setup_theme', array($znwp_taxonomy_color_image_plugin, 'init'));

Update description to mention order field


<?php
/**
 * @package mobile
 */
class MobileSiteTreeExtension extends DataObjectDecorator {

	function MetaTags(&$tags) {
		$config = SiteConfig::current_site_config();

		// Ensure a canonical link is placed, for semantic correctness and SEO
		if(Controller::has_curr() && Controller::curr()->onMobileDomain() && $config->MobileSiteType == 'RedirectToDomain') {
			$oldBaseURL = Director::baseURL();
			Director::setbaseURL($config->FullSiteDomain);
			$tags .= sprintf('<link rel="canonical" href="%s" />', $this->owner->AbsoluteLink()) . "\n";
			Director::setbaseURL($oldBaseURL);
		}
	}

}

<?php
/**
 * @package mobile
 */
class MobileSiteTreeExtension extends DataObjectDecorator {

	function MetaTags(&$tags) {
		$config = SiteConfig::current_site_config();

		// Ensure a canonical link is placed, for semantic correctness and SEO
		if(Controller::has_curr() && Controller::curr()->hasMethod("onMobileDomain") && Controller::curr()->onMobileDomain() && $config->MobileSiteType == 'RedirectToDomain') {
			$oldBaseURL = Director::baseURL();
			Director::setbaseURL($config->FullSiteDomain);
			$tags .= sprintf('<link rel="canonical" href="%s" />', $this->owner->AbsoluteLink()) . "\n";
			Director::setbaseURL($oldBaseURL);
		}
	}

}

Fix for [User Error] Uncaught Exception: Object->__call(): the method 'onmobiledomain' does not exist on 'Security' occurred after new install of Silverstripe 2.4.5 and Silverstripe-Mobile.


<?php

chdir('../../');
include_once("./include/auth.php");
include_once("./plugins/intropage/display.php");

set_default_action();

$lopts = db_fetch_cell('SELECT intropage_opts FROM user_auth WHERE id=' . $_SESSION['sess_user_id']);
if ($lopts == 1)
	top_header();

display_informations();

intropage_console_after();

if ($lopts == 1)
	bottom_footer();

?>

<?php

chdir('../../');
include_once("./include/auth.php");
include_once("./plugins/intropage/display.php");

set_default_action();

$lopts = db_fetch_cell('SELECT intropage_opts FROM user_auth WHERE id=' . $_SESSION['sess_user_id']);
if ($lopts == 1)
//	top_header();
	general_header();

display_informations();

intropage_console_after();

if ($lopts == 1)
	bottom_footer();

?>

Fix displaying console menu in separated tab


                <button type="button" class="close" data-dismiss="modal">×</button>

Create new API key.

                <form action="" method="POST" class="form-horizontal">
                    {{-- CSRF field --}}
                    {{ csrf_field() }}

                <button type="submit" class="btn btn-success">Create</button>
                </form>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

                <button type="button" class="close" data-dismiss="modal">×</button>

Create new API key.

                <form action="" method="POST" class="form-horizontal">
                    {{-- CSRF field --}}
                    {{ csrf_field() }}

                            Service: *

                            <input class="form-control" name="service" id="service" placeholder="service name">

                <button type="submit" class="btn btn-success">Create</button>
                </form>
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

Complete api service creation model

Complete api service creation model


<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace ZendTest\Code\Generator\TestAsset;

class TestClassWithManyProperties
{

    const FOO = 'foo';

    public static $fooStaticProperty = null;

    /**
     * @var bool
     */
    public $fooProperty = true;

    protected static $_barStaticProperty = 1;

    protected $_barProperty = 1.1115;

    private static $_bazStaticProperty = self::FOO;

    private $_bazProperty = array(true, false, true);

    protected $_complexType = array(
        5,
        'one' => 1,
        'two' => '2',
        array(
            'bar',
            'baz',
            //PHP_EOL
        )
    );

}

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace ZendTest\Code\Generator\TestAsset;

class TestClassWithManyProperties
{

    const FOO = 'foo';

    public static $fooStaticProperty = null;

    /**
     * @var bool
     */
    public $fooProperty = true;

    protected static $_barStaticProperty = 1;

    protected $_barProperty = 1.1115;

    private static $_bazStaticProperty = self::FOO;

    private $_bazProperty = array(true, false, true);

    protected $_complexType = array(
        5,
        'one' => 1,
        'two' => '2',
        array(
            'bar',
            'baz',
            "\n"
        )
    );

}

Remove the last occurence of PHP_EOL in a commented test and enabling it


<?php

/*
 * This file is part of Laravel CrowdAuth
 *
 * (c) Daniel McAssey <hello@glokon.me>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateCrowdgroupCrowduserTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('crowdgroup_crowduser', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('crowd_group_id')->unsigned()->index();
			$table->integer('crowd_user_id')->unsigned()->index();
			$table->timestamps();
		});

		Schema::table('crowdgroup_crowduser', function(Blueprint $table)
		{
			$table->foreign('crowd_group_id')->references('id')->on('crowd_groups')->onDelete('cascade');
			$table->foreign('crowd_user_id')->references('id')->on('crowd_users')->onDelete('cascade');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('crowdgroup_crowduser');
	}

}

<?php

/*
 * This file is part of Laravel CrowdAuth
 *
 * (c) Daniel McAssey <hello@glokon.me>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateCrowdgroupCrowduserTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('crowdgroup_crowduser', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('crowd_group_id')->unsigned()->index();
			$table->integer('crowd_user_id')->unsigned()->index();
			$table->timestamps();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('crowdgroup_crowduser');
	}

}

Remove foreign keys as Laravel cant detect class


<?php if (!empty($help)): ?>

<?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($help, array(), $translation_domain) : $help) ?>

<?php endif ?>

<?php if (!empty($help)): ?>
    <p id="<?php echo $view->escape($id) ?>_help" class="help-text"><?php echo $view->escape(false !== $translation_domain ? $view['translator']->trans($help, array(), $translation_domain) : $help) ?>

<?php endif ?>

Add an id to the help

Add an id to the help


<?php

namespace League\HTMLToMarkdown\Converter;

use League\HTMLToMarkdown\Configuration;
use League\HTMLToMarkdown\ConfigurationAwareInterface;
use League\HTMLToMarkdown\ElementInterface;

class EmphasisConverter implements ConverterInterface, ConfigurationAwareInterface
{
    /**
     * @var Configuration
     */
    protected $config;

    /**
     * @param Configuration $config
     */
    public function setConfig(Configuration $config)
    {
        $this->config = $config;
    }

    /**
     * @param ElementInterface $element
     *
     * @return string
     */
    public function convert(ElementInterface $element)
    {
        $tag = $element->getTagName();
        $value = $element->getValue();

        if (!trim($value)) {
            return '';
        }

        if ($tag === 'i' || $tag === 'em') {
            $style = $this->config->getOption('italic_style');
        } else {
            $style = $this->config->getOption('bold_style');
        }

        $prefix = ltrim($value) !== $value ? ' ' : '';
        $suffix = rtrim($value) !== $value ? ' ' : '';

        return $prefix . $style . trim($value) . $style . $suffix;
    }

    /**
     * @return string[]
     */
    public function getSupportedTags()
    {
        return array('em', 'i', 'strong', 'b');
    }
}

Remove formatting issues with CI.

Remove formatting issues with CI.


<?php

namespace fennecweb\ajax\listing;

use \PDO as PDO;

/**
 * Web Service.
 * Returns information of all users projects
 */
class Projects extends \fennecweb\WebService
{
    const ERROR_NOT_LOGGED_IN = "Error. Not logged in.";

    private $db;
    /**
    * @param $querydata[]
    * @returns Array $result
    * <code>
    * array(array('project_id','import_date','OTUs','sample size'));
    * </code>
    */
    public function execute($querydata)
    {
        $db = $this->openDbConnection($querydata);
        $result = array();
        if (!isset($_SESSION['user'])) {
            $result = array("error" => Projects::ERROR_NOT_LOGGED_IN);
        }
        return $result;
    }
}

<?php

namespace fennecweb\ajax\listing;

use \PDO as PDO;

/**
 * Web Service.
 * Returns information of all users projects
 */
class Projects extends \fennecweb\WebService
{
    const ERROR_NOT_LOGGED_IN = "Error. Not logged in.";

    private $db;
    /**
    * @param $querydata[]
    * @returns Array $result
    * <code>
    * array(array('project_id','import_date','OTUs','sample size'));
    * </code>
    */
    public function execute($querydata)
    {
        $db = $this->openDbConnection($querydata);
        $result = array();
        if (!isset($_SESSION['user'])) {
            $result = array("error" => Projects::ERROR_NOT_LOGGED_IN);
        } else {
            $query_get_user_projects = <<<EOF
SELECT import_date,project->>'id' AS id,project->'shape'->>0 AS rows,project->'shape'->>1 AS columns
    FROM full_webuser_data WHERE provider = :provider AND oauth_id = :oauth_id
EOF;
            $stm_get_user_projects = $db->prepare($query_get_user_projects);
            $stm_get_user_projects->bindValue('provider', $_SESSION['user']['provider']);
            $stm_get_user_projects->bindValue('oauth_id', $_SESSION['user']['id']);
            $stm_get_user_projects->execute();

            while ($row = $stm_get_user_projects->fetch(PDO::FETCH_ASSOC)) {
                $project = array();
                $project['id'] = $row['id'];
                $project['import_date'] = $row['import_date'];
                $project['rows'] = $row['rows'];
                $project['columns'] = $row['columns'];
                $result[] = $project;
            }
        }
        return $result;
    }
}

Implement functionality of webservice which should return users projects. Make the failing test pass


<?php

/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Component\Addressing\Model;

use Sylius\Component\Translation\Model\AbstractTranslation;

/**
 * Default country translation model.
 *
 * @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
 */
class CountryTranslation extends AbstractTranslation implements CountryTranslationInterface
{
    /**
     * Country id.
     *
     * @var mixed
     */
    protected $id;

    /**
     * Country name.
     *
     * @var string
     */
    protected $name;

    public function __toString()
    {
        return $this->name;
    }

    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * {@inheritdoc}
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
}

<?php

/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Component\Addressing\Model;

use Sylius\Component\Translation\Model\AbstractTranslation;

/**
 * Default country translation model.
 *
 * @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
 */
class CountryTranslation extends AbstractTranslation implements CountryTranslationInterface
{
    /**
     * Country id.
     *
     * @var mixed
     */
    protected $id;

    /**
     * Country name.
     *
     * @var string
     */
    protected $name;

    /**
     * {@inheritdoc}
     */
    public function __toString()
    {
        return $this->name;
    }

    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * {@inheritdoc}
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
}

Fix the issue with not generating slugs

Fix the issue with not generating slugs


<?php

/*
 * This file is part of the Access to Memory (AtoM) software.
 *
 * Access to Memory (AtoM) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Access to Memory (AtoM) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Access to Memory (AtoM).  If not, see <http://www.gnu.org/licenses/>.
 */

class RightDeleteAction extends sfAction
{
  public function execute($request)
  {
    $this->right = $this->getRoute()->resource;

    // Check user authorization
    if (!QubitAcl::check($this->resource, 'delete'))
    {
      QubitAcl::forwardUnauthorized();
    }

    $this->right->delete();

    return $this->redirect(array($this->resource, 'module' => 'informationobject'));
  }
}

<?php

/*
 * This file is part of the Access to Memory (AtoM) software.
 *
 * Access to Memory (AtoM) is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Access to Memory (AtoM) is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Access to Memory (AtoM).  If not, see <http://www.gnu.org/licenses/>.
 */

class RightDeleteAction extends sfAction
{
  public function execute($request)
  {
    $this->right = $this->getRoute()->resource;
    $relatedObject = $this->right->relationsRelatedByobjectId[0]->subject;

    // Check user authorization against the related object
    if (!QubitAcl::check($relatedObject, 'delete'))
    {
      QubitAcl::forwardUnauthorized();
    }

    $this->right->delete();

    return $this->redirect(array($relatedObject));
  }
}

Fix ACL check and redirect in RightDeleteAction

Refs #7742


<?php

namespace LapaLabs\BlogBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * Interface PostCategoryInterface
 */
interface PostCategoryInterface
{
    /**
     * @return CategoryPostInterface[]|ArrayCollection
     */
    public function getPosts();

    /**
     * @param CategoryPostInterface[]|ArrayCollection $posts
     */
    public function setPosts(ArrayCollection $posts = null);
}

<?php

namespace LapaLabs\BlogBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;

/**
 * Interface PostCategoryInterface
 */
interface PostCategoryInterface
{
    /**
     * @return CategoryPostInterface[]|ArrayCollection
     */
    public function getPosts();

    /**
     * @param CategoryPostInterface[]|ArrayCollection $posts
     */
    public function setPosts(ArrayCollection $posts);
}

Fix set null by default for ArrayCollection


<?php namespace Krucas\Notification;

use Illuminate\Support\ServiceProvider;

class NotificationServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

	/**
	 * Bootstrap the application events.
	 *
	 * @return void
	 */
	public function boot()
	{
		$this->package('edvinaskrucas/notification');
	}

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
        $this->app['config']->package('edvinaskrucas/notification', __DIR__.'/../config');

		$this->app['notification'] = $this->app->share(function($app)
        {
            return new Notification($app['config'], $app['session']);
        });
	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides()
	{
		return array();
	}

}

<?php namespace Krucas\Notification;

use Illuminate\Support\ServiceProvider;

class NotificationServiceProvider extends ServiceProvider {

	/**
	 * Indicates if loading of the provider is deferred.
	 *
	 * @var bool
	 */
	protected $defer = false;

	/**
	 * Bootstrap the application events.
	 *
	 * @return void
	 */
	public function boot()
	{
		$this->package('edvinaskrucas/notification');
	}

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
        $this->app['config']->package('edvinaskrucas/notification', __DIR__.'/../config');

		$this->app['notification'] = $this->app->share(function($app)
        {
            return new Notification($app['config'], $app['session.store']);
        });
	}

	/**
	 * Get the services provided by the provider.
	 *
	 * @return array
	 */
	public function provides()
	{
		return array();
	}

}

Update service provider to reflect changes in Laravel.


<?php
require_once __DIR__ . '/deployer/recipe/configure.php';
require_once __DIR__ . '/deployer/recipe/yii2-app-basic.php';

serverList(__DIR__ . '/stage/servers.yml');
set('repository', '{{repository}}');

set('keep_releases', 2);

set('shared_files', [
    'config/db.php'
]);

task('deploy:build_assets', function () {
   runLocally('gulp build');
   upload(__DIR__ . '/web/css', '{{release_path}}/web/css');
   upload(__DIR__ . '/web/js', '{{release_path}}/web/js');
   upload(__DIR__ . '/web/fonts', '{{release_path}}/web/fonts');
})->desc('Build assets');

task('deploy:configure_composer', function () {
  $stage = env('stage');
  if($stage == 'local') {
    env('composer_options', 'install --verbose --no-progress --no-interaction');
  }
})->desc('Configure composer');

after('deploy:shared', 'deploy:configure');
before('deploy:vendors', 'deploy:configure_composer');
after('deploy:run_migrations', 'deploy:build_assets');

<?php
require_once __DIR__ . '/deployer/recipe/configure.php';
require_once __DIR__ . '/deployer/recipe/yii2-app-basic.php';

serverList(__DIR__ . '/stage/servers.yml');
set('repository', '{{repository}}');

set('keep_releases', 2);

set('shared_files', [
    'config/db.php'
]);

task('deploy:build_assets', function () {
   runLocally('gulp build');
   upload(__DIR__ . '/web/css', '{{release_path}}/web/css');
   upload(__DIR__ . '/web/js', '{{release_path}}/web/js');
   upload(__DIR__ . '/web/fonts', '{{release_path}}/web/fonts');
})->desc('Build assets');

task('deploy:configure_composer', function () {
  $stage = env('app.stage');
  if($stage == 'dev') {
    env('composer_options', 'install --verbose --no-progress --no-interaction');
  }
})->desc('Configure composer');

after('deploy:shared', 'deploy:configure');
before('deploy:vendors', 'deploy:configure_composer');
after('deploy:run_migrations', 'deploy:build_assets');

Configure composer - working edition

Configure composer - working edition


<?php

namespace RadDB\Console\Commands;

use Illuminate\Console\Command;

class ImportDataPage extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
    }
}

<?php

namespace RadDB\Console\Commands;

use Illuminate\Console\Command;

class ImportDataPage extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Array of spreadsheet types
     *
     * @var array
     */
    protected $sheetType = [
        "RAD",
        "FLUORO",
        "MAMMO_HOL",
        "MAMMO_SIE",
        "SBB",
    ];

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
    }
}

Add array of sheet types

Add array of sheet types


<?php

class CalendarsController extends BaseController {

  public function index()
  {
    $events = Events::with('calendar')->orderBy('start_date')->orderBy('end_date')->get();

    return View::make('calendar.index')->with('events', $events);
  }

}

<?php

class CalendarsController extends BaseController {

  public function index()
  {
    $events = Events::with('calendar')->where('active', '=', 1)->orderBy('start_date')->orderBy('end_date')->get();

    return View::make('calendar.index')->with('events', $events);
  }

}

Make sure we limit the /calendar events to just those that are marked as active.


<?php

function var_export_callback($object) {
	return var_export($object, true);
}

function backTrace($backtrace)
{
	require_once 'plugins/sourcetag/geshi.php';
	foreach ($backtrace as $bt) {
		$args = '';
		foreach ($bt['args'] as $a) {
			if ($args) {
				$args .= ', ';
			}
			if (in_array(strtolower($bt['function']), array('rawquery', 'query', 'fetchresult')) && !$args)
				if (is_array($a))
					$args .= "array(".implode(', ', array_merge(array("'...'"), array_map('var_export_callback', array_slice($a, 1)))).")";
				else if (is_string($a))
					$args .= "'...'";
				else
					$args .= '???';
			else
				$args .= var_export($a, true);
		}
		$output .= "{$bt['file']}{$bt['line']}";
		$output .= geshi_highlight("{$bt['class']}{$bt['type']}{$bt['function']}($args)", 'scala', null, true);
		$output .= "
";
	}
	return $output;
}

function var_format($v) // pretty-print var_export
{
	return (str_replace(array("\n"," ","array"),
array("
"," "," array"),
var_export($v,true))."
");
}

<?php

function backTrace($backtrace)
{
	require_once 'plugins/sourcetag/geshi.php';
	foreach ($backtrace as $bt) {
		$args = '';
		foreach ($bt['args'] as $a) {
			if ($args) {
				$args .= ', ';
			}
			if (in_array(strtolower($bt['function']), array('rawquery', 'query', 'fetchresult')) && !$args)
				if (is_array($a))
					$args .= var_export(array_merge(array("..."), array_slice($a, 1)), true);
				else if (is_string($a))
					$args .= "'...'";
				else
					$args .= '???';
			else
				$args .= var_export($a, true);
		}
		$output .= "{$bt['file']}{$bt['line']}";
		$output .= geshi_highlight("{$bt['class']}{$bt['type']}{$bt['function']}($args)", 'scala', null, true);
		$output .= "
";
	}
	return $output;
}

function var_format($v) // pretty-print var_export
{
	return (str_replace(array("\n"," ","array"),
array("
"," "," array"),
var_export($v,true))."
");
}

Make remove first array element logic less complex than it needs to be


<?
class RssesController extends AppController {

//var $name = 'Rss';
var $components = array('RequestHandler');
var $helpers = array ('Rss','Text');

function index() {

  //Configure::write('debug', 0); // dont want debug in ajax returned html
	$this->loadModel('Post');
	//if( $this->RequestHandler->isRss() ){
        $posts = $this->Post->find('all', array('limit' => 20, 'order' => 'Post.created DESC'));
        //$this->set(compact('posts'));
		$this->set(compact('posts'));
		$this->layout = 'rss';

	//}else{
	//	echo 'not RSS!';
	//}

}

}
?>

<?
  /**
   INOROUT - Social Discussion Platform.
   Copyright (C) 2010 EeChia <eechia@gmail.com>

   This program is free software: you can redistribute it and/or
   modify it under the terms of the GNU Affero General Public License
   as published by the Free Software Foundation, either version 3 of
   the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public
   License along with this program.  If not, see
   <http://www.gnu.org/licenses/>.
  */

class RssesController extends AppController {

var $name = 'Rss';
var $components = array('RequestHandler');
var $helpers = array ('Rss','Text');

function index() {

  Configure::write('debug', 0); // dont want debug in ajax returned html
  $this->loadModel('Post');

  $posts = $this->Post->find('all', array('limit' => 20, 'order' => 'Post.created DESC'));
  $this->set(compact('posts'));
  $this->layout = 'rss';

}

?>

Fix debug messages appearing in rss.

Fix debug messages appearing in rss.


<?php

class LoginPage extends Page {

    public function get_page_title(Website $oWebsite) {
        return $oWebsite->t("main.log_in") . '...';
    }

    public function get_short_page_title(Website $oWebsite) {
        return $oWebsite->t("main.log_in");
    }

    public function get_minimum_rank(Website $oWebsite) {
        return Authentication::$USER_RANK;
    }

    public function get_page_content(Website $oWebsite) {
        return <<<EOT

{$oWebsite->t('users.logged_in')}

{$oWebsite->t('users.succesfully_logged_in')}

                get_url_main()}" class="arrow">{$oWebsite->t("main.home")}

                get_url_page("account")}" class="arrow">{$oWebsite->t("main.my_account")}

EOT;
    }

}

$this->register_page(new LoginPage());
?>

<?php

class LoginPage extends Page {

    public function get_page_title(Website $oWebsite) {
        return $oWebsite->t("main.log_in") . '...';
    }

    public function get_short_page_title(Website $oWebsite) {
        return $oWebsite->t("main.log_in");
    }

    public function get_minimum_rank(Website $oWebsite) {
        return Authentication::$USER_RANK;
    }

    public function get_page_content(Website $oWebsite) {
        $admin_links = "";
        if ($oWebsite->logged_in_staff(true)) {
            $admin_links = <<<EOT

                get_url_page("account_management")}" class="arrow">{$oWebsite->t("main.account_management")}

                get_url_page("admin")}" class="arrow">{$oWebsite->t("main.admin")}
EOT;
        }

        return <<<EOT

{$oWebsite->t('users.logged_in')}

{$oWebsite->t('users.succesfully_logged_in')}

                get_url_main()}" class="arrow">{$oWebsite->t("main.home")}

                get_url_page("account")}" class="arrow">{$oWebsite->t("main.my_account")}
                $admin_links

EOT;
    }

}

$this->register_page(new LoginPage());
?>

Add admin links when an admin logs in

Add admin links when an admin logs in


<?php
# tocsv.php - OSDial
#
# Copyright (C) 2010  Lott Caskey  <lottcaskey@gmail.com>    LICENSE: AGPLv3
#
#     This file is part of OSDial.
#
#     OSDial is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as
#     published by the Free Software Foundation, either version 3 of
#     the License, or (at your option) any later version.
#
#     OSDial is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
#
#     You should have received a copy of the GNU Affero General Public
#     License along with OSDial.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
# Includes
require("include/dbconnect.php");
require("include/functions.php");

$mimetype = get_variable("mimetype");
$filename = get_variable("filename");
$download = get_variable('download');
if ($download=='') {
    $download='inline';
} else {
    $download='attachment';
}

if ($filename!='' and $mimetype!='') {
    header("Content-type: $mimetype; charset=utf-8");
    header("Content-Disposition: $download; filename=\"$filename\"");

    echo media_get_filedata($link,$filename);
}

?>

<?php
# tocsv.php - OSDial
#
# Copyright (C) 2010  Lott Caskey  <lottcaskey@gmail.com>    LICENSE: AGPLv3
#
#     This file is part of OSDial.
#
#     OSDial is free software: you can redistribute it and/or modify
#     it under the terms of the GNU Affero General Public License as
#     published by the Free Software Foundation, either version 3 of
#     the License, or (at your option) any later version.
#
#     OSDial is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU Affero General Public License for more details.
#
#     You should have received a copy of the GNU Affero General Public
#     License along with OSDial.  If not, see <http://www.gnu.org/licenses/>.
#
#
#
# Includes
require_once("include/dbconnect.php");
require_once("include/functions.php");

$mimetype = get_variable("mimetype");
$filename = get_variable("filename");
$download = get_variable('download');
if ($download=='') {
    $download='inline';
} else {
    $download='attachment';
}

if ($filename!='' and $mimetype!='') {
    header("Content-type: $mimetype; charset=utf-8");
    header("Content-Disposition: $download; filename=\"$filename\"");

    echo media_get_filedata($link,$filename);
}

?>

Change to require_once so we dont have duplicate function errors.


<?php

/*
 * This file is part of Evenement.
 *
 * Copyright (c) 2011 Igor Wiedler
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

$loader = require __DIR__.'/../vendor/autoload.php';
$loader->add('Evenement\Tests', __DIR__);
$loader->register();

Remove redundant class loader register call


<?php
    class LogsheetComponent {
        protected $db;
        protected $id;

        public function __construct($db, $component_id) {
            $this->db = $db;
            $this->setId($component_id);
        }

        public function setId($component_id) {
            if (is_int($component_id)) {
                $this->id = $component_id;
            }
        }

        public function getId() {
            return $this->id;
        }

        //Make sure an Id has been set for an Object
        protected function checkForId() {
            if(!empty($this->id)) {
                $result = TRUE;
            } else {
                throw new Exception("Error: No ID assigned to object");
            }

            return $result;
        }
    }
?>

<?php
    class LogsheetComponent {
        protected $db;
        protected $id;

        public function __construct($db, $component_id) {
            $this->db = $db;
            $this->setId($component_id);
        }

        public function setId($component_id) {
            $this->id = $component_id;
        }

        public function getId() {
            return $this->id;
        }

        //Make sure an Id has been set for an Object
        protected function checkForId() {
            if(!empty($this->id)) {
                $result = TRUE;
            } else {
                throw new Exception("Error: No ID assigned to object");
            }

            return $result;
        }
    }
?>

Remove check if int in setId

Remove check if int in setId

Led to id not being set from HTML forms. Will leave without checking ID for now.


<?php

namespace PHPShopify;

class CollectionTest extends TestSimpleResource
{

}

<?php

namespace PHPShopify;

class CollectionTest extends TestSimpleResource
{
    /**
     * Test get resource
     *
     * Post and list not available for Collection resource so testGet not possible
     */
    public function testGet()
    {

    }
}

Disable test for Collection resource

Disable test for Collection resource


<?php

namespace Twig;

use Webfactory\Bundle\PiwikBundle\Twig\Extension;

class ExtensionTest extends \PHPUnit_Framework_TestCase
{

    public function testPiwikCodeReturnsNoScriptWhenDisabled()
    {
        $extension = new Extension(true, 1, '', false);
        $this->assertNotContains('script', $extension->piwikCode());
    }

    public function testPiwikCodeReturnsScript()
    {
        $extension = new Extension(false, 1, '', false);
        $this->assertContains('script', $extension->piwikCode());
    }

    public function testPiwikCodeContainsSiteId()
    {
        $siteId = 1234;
        $extension = new Extension(false, $siteId, '', false);
        $this->assertContains((string)$siteId, $extension->piwikCode());
    }

    public function testPiwikCodeContainsHostName()
    {
        $hostname = 'myHost.de';
        $extension = new Extension(false, 1, $hostname, false);
        $this->assertContains($hostname, $extension->piwikCode());
    }

    public function testIsTwigExtension()
    {
        $extension = new Extension(false, 1, '', false);
        $this->assertInstanceOf('\Twig_Extension', $extension);
    }

}

<?php

namespace Twig;

use Webfactory\Bundle\PiwikBundle\Twig\Extension;

class ExtensionTest extends \PHPUnit_Framework_TestCase
{

    public function testPiwikCodeReturnsNoScriptWhenDisabled()
    {
        $extension = new Extension(true, 1, '', false);
        $this->assertNotContains('script', $extension->piwikCode());
    }

    public function testPiwikCodeReturnsScript()
    {
        $extension = new Extension(false, 1, '', false);
        $this->assertContains('script', $extension->piwikCode());
    }

    public function testPiwikCodeContainsSiteId()
    {
        $siteId = 1234;
        $extension = new Extension(false, $siteId, '', false);
        $this->assertContains((string)$siteId, $extension->piwikCode());
    }

    public function testPiwikCodeContainsHostName()
    {
        $hostname = 'myHost.de';
        $extension = new Extension(false, 1, $hostname, false);
        $this->assertContains($hostname, $extension->piwikCode());
    }

    public function testIsTwigExtension()
    {
        $extension = new Extension(false, 1, '', false);
        $this->assertInstanceOf('\Twig_ExtensionInterface', $extension);
    }

}

Test against interface instead of concrete class


<?php

namespace Ambta\DoctrineEncryptBundle\Encryptors;

use \ParagonIE\HiddenString\HiddenString;
use \ParagonIE\Halite\KeyFactory;

/**
 * Class for encrypting and decrypting with the halite library
 *
 * @author Michael de Groot <specamps@gmail.com>
 */

class HaliteEncryptor implements EncryptorInterface
{
    private $encryptionKey;
    private $keyFile;

    /**
     * {@inheritdoc}
     */
    public function __construct(string $keyFile)
    {
        $this->keyFile = $keyFile;
    }

    /**
     * {@inheritdoc}
     */
    public function encrypt($data)
    {
        return \ParagonIE\Halite\Symmetric\Crypto::encrypt(new HiddenString($data), $this->getKey());
    }

    /**
     * {@inheritdoc}
     */
    public function decrypt($data)
    {
        $data = \ParagonIE\Halite\Symmetric\Crypto::decrypt($data, $this->getKey());

        if ($data instanceof HiddenString)
        {
            $data = $data->getString();
        }

        return $data;
    }

    private function getKey()
    {
        if ($this->encryptionKey === null) {
            try {
                $this->encryptionKey = \ParagonIE\Halite\KeyFactory::loadEncryptionKey($this->keyFile);
            } catch (\ParagonIE\Halite\Alerts\CannotPerformOperation $e) {
                $this->encryptionKey = KeyFactory::generateEncryptionKey();
                \ParagonIE\Halite\KeyFactory::save($this->encryptionKey, $this->keyFile);
            }
        }

        return $this->encryptionKey;
    }
}

<?php

namespace Ambta\DoctrineEncryptBundle\Encryptors;

use \ParagonIE\Halite\HiddenString;
use \ParagonIE\Halite\KeyFactory;

/**
 * Class for encrypting and decrypting with the halite library
 *
 * @author Michael de Groot <specamps@gmail.com>
 */

class HaliteEncryptor implements EncryptorInterface
{
    private $encryptionKey;
    private $keyFile;

    /**
     * {@inheritdoc}
     */
    public function __construct(string $keyFile)
    {
        $this->keyFile = $keyFile;
    }

    /**
     * {@inheritdoc}
     */
    public function encrypt($data)
    {
        return \ParagonIE\Halite\Symmetric\Crypto::encrypt(new HiddenString($data), $this->getKey());
    }

    /**
     * {@inheritdoc}
     */
    public function decrypt($data)
    {
        $data = \ParagonIE\Halite\Symmetric\Crypto::decrypt($data, $this->getKey());

        if ($data instanceof HiddenString)
        {
            $data = $data->getString();
        }

        return $data;
    }

    private function getKey()
    {
        if ($this->encryptionKey === null) {
            try {
                $this->encryptionKey = \ParagonIE\Halite\KeyFactory::loadEncryptionKey($this->keyFile);
            } catch (\ParagonIE\Halite\Alerts\CannotPerformOperation $e) {
                $this->encryptionKey = KeyFactory::generateEncryptionKey();
                \ParagonIE\Halite\KeyFactory::save($this->encryptionKey, $this->keyFile);
            }
        }

        return $this->encryptionKey;
    }
}

Revert change for lower versions to still work.


<?php

namespace Enzyme\Axiom\Factories;

use Enzyme\Axiom\Carriers\CarrierInterface;

/**
 * Makes instances from the given data.
 */
interface FactoryInterface
{
    /**
     * Make a new instance from the given data.
     *
     * @param CarrierInterface $data
     *
     * @return Enzyme\Axiom\Instances\InstanceInterface
     */
    public function make(CarrierInterface $data);
}

<?php

namespace Enzyme\Axiom\Factories;

use Enzyme\Axiom\Instances\InstanceInterface;
use Enzyme\Axiom\Carriers\CarrierInterface;

/**
 * Makes instances from the given data.
 */
interface FactoryInterface
{
    /**
     * Make a new instance from the given data.
     *
     * @param CarrierInterface $data
     *
     * @return Enzyme\Axiom\Instances\InstanceInterface
     */
    public function make(CarrierInterface $data);

    /**
     * Update the given instance with the data provided.
     *
     * @param InstanceInterface $instance Instance being updated.
     * @param CarrierInterface  $data     The new data.
     *
     * @return Enzyme\Axiom\Instances\InstanceInterface
     */
    public function update(InstanceInterface $instance, CarrierInterface $data);
}

Add update method to factory interface.

Add update method to factory interface.


<?php

namespace SilverStripe\GraphQL\Schema\DataObject;

use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\QueryHandler\SchemaContextProvider;
use SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException;
use SilverStripe\GraphQL\Schema\SchemaConfig;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use Closure;
use SilverStripe\ORM\SS_List;

/**
 * Generic resolver for DataObjects
 */
class Resolver
{
    /**
     * @param DataObject $obj
     * @param array $args
     * @param array $context
     * @param ResolveInfo|null $info
     * @return array|bool|int|mixed|DataList|DataObject|DBField|SS_List|string|null
     * @throws SchemaBuilderException
     */
    public static function resolve($obj, array $args = [], array $context = [], ?ResolveInfo $info = null)
    {
        $fieldName = $info->fieldName;
        $result = FieldAccessor::singleton()->accessField($obj, $fieldName);
        if ($result === null) {
            $context = SchemaContextProvider::get($context);
            $fieldName = $context->mapFieldByClassName(get_class($obj), $fieldName);
            $result = $fieldName ? FieldAccessor::singleton()->accessField($obj, $fieldName[1]) : null;
        }
        if ($result instanceof DBField) {
            return $result->getValue();
        }

        return $result;
    }
}

<?php

namespace SilverStripe\GraphQL\Schema\DataObject;

use GraphQL\Type\Definition\ResolveInfo;
use SilverStripe\GraphQL\QueryHandler\SchemaContextProvider;
use SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException;
use SilverStripe\GraphQL\Schema\SchemaConfig;
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBField;
use Closure;
use SilverStripe\ORM\SS_List;

/**
 * Generic resolver for DataObjects
 */
class Resolver
{
    /**
     * @param DataObject $obj
     * @param array $args
     * @param array $context
     * @param ResolveInfo|null $info
     * @return array|bool|int|mixed|DataList|DataObject|DBField|SS_List|string|null
     * @throws SchemaBuilderException
     */
    public static function resolve($obj, array $args = [], array $context = [], ?ResolveInfo $info = null)
    {
        $fieldName = $info->fieldName;
        $context = SchemaContextProvider::get($context);
        $fieldName = $context->mapFieldByClassName(get_class($obj), $fieldName);
        $result = $fieldName ? FieldAccessor::singleton()->accessField($obj, $fieldName[1]) : null;
        if ($result instanceof DBField) {
            return $result->getValue();
        }

        return $result;
    }
}

BUGFIX: Allow mapFieldByClassName to be authoritative


<?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Nova\Actions;

use App\Jobs\PushToJedi;
use Illuminate\Support\Str;
use Illuminate\Bus\Queueable;
use Laravel\Nova\Actions\Action;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;

class SyncAccess extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param \Laravel\Nova\Fields\ActionFields  $fields
     * @param \Illuminate\Support\Collection  $models
     *
     * @return void
     *
     * @suppress PhanPossiblyNonClassMethodCall
     */
    public function handle(ActionFields $fields, Collection $models): void
    {
        foreach ($models as $user) {
            if (Str::startsWith($user->uid, 'svc_')) {
                continue;
            }

            // I tried to make this class ShouldQueue so Nova would handle queueing
            // but was getting an exception. I think it's fine to run synchronously...?
            PushToJedi::dispatchNow($user, self::class, request()->user()->id, 'manual');
        }
    }

    /**
     * Get the fields available on the action.
     *
     * @return array<\Laravel\Nova\Fields\Field>
     */
    public function fields(): array
    {
        return [];
    }
}

<?php

declare(strict_types=1);

// phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter,SlevomatCodingStandard.Functions.UnusedParameter

namespace App\Nova\Actions;

use App\Jobs\PushToJedi;
use Illuminate\Support\Str;
use Illuminate\Bus\Queueable;
use Laravel\Nova\Actions\Action;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;

class SyncAccess extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Perform the action on the given models.
     *
     * @param \Laravel\Nova\Fields\ActionFields  $fields
     * @param \Illuminate\Support\Collection  $models
     *
     * @return void
     *
     * @suppress PhanPossiblyNonClassMethodCall
     */
    public function handle(ActionFields $fields, Collection $models): void
    {
        foreach ($models as $user) {
            if (Str::startsWith($user->uid, 'svc_')) {
                continue;
            }

            // I tried to make this class ShouldQueue so Nova would handle queueing
            // but was getting an exception. I think it's fine to run synchronously...?
            PushToJedi::dispatchNow(
                $user,
                self::class,
                request()->user()->id,
                count($models) === 1 ? 'manual' : 'manual_batch'
            );
        }
    }

    /**
     * Get the fields available on the action.
     *
     * @return array<\Laravel\Nova\Fields\Field>
     */
    public function fields(): array
    {
        return [];
    }
}

Mark batch syncs as such to help with caching


<?php

class Test extends PHPUnit_Framework_TestCase
{
	public function testOnePlusOne() {
		$this->assertEquals(1+1, 2);
  	}
}

?>

<?php

// PHP 5.3 - 7.x compatibility
if (!class_exists('\PHPUnit\Framework\TestCase') &&
    class_exists('\PHPUnit_Framework_TestCase')) {
    class_alias('\PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
}

class Test extends PHPUnit_Framework_TestCase
{
	public function testOnePlusOne() {
		$this->assertEquals(1+1, 2);
  	}
}

?>

Test PHP 5.3 - 7.x compatibility

Test PHP 5.3 - 7.x compatibility


<?php
namespace Respect\Validation\Rules;

class CallbackTest extends \PHPUnit_Framework_TestCase
{
    public function thisIsASampleCallbackUsedInsideThisTest()
    {
        return true;
    }

    public function testCallbackValidatorShouldReturnTrueIfCallbackReturnsTrue()
    {
        $v = new Callback(function() {
                    return true;
                });
        $this->assertTrue($v->assert('wpoiur'));
    }

    /**
     * @expectedException Respect\Validation\Exceptions\CallbackException
     */
    public function testCallbackValidatorShouldReturnFalseIfCallbackReturnsFalse()
    {
        $v = new Callback(function() {
                    return false;
                });
        $this->assertTrue($v->assert('w poiur'));
    }

    public function testCallbackValidatorShouldAcceptArrayCallbackDefinitions()
    {
        $v = new Callback(array($this, 'thisIsASampleCallbackUsedInsideThisTest'));
        $this->assertTrue($v->assert('test'));
    }

    public function testCallbackValidatorShouldAcceptFunctionNamesAsString()
    {
        $v = new Callback('is_string');
        $this->assertTrue($v->assert('test'));
    }

    /**
     * @expectedException Respect\Validation\Exceptions\ComponentException
     */
    public function testInvalidCallbacksShouldRaiseComponentExceptionUponInstantiation()
    {
        $v = new Callback(new \stdClass);
        $this->assertTrue($v->assert('w poiur'));
    }
}

<?php
namespace Respect\Validation\Rules;

class CallbackTest extends \PHPUnit_Framework_TestCase
{
    private $truthy, $falsy;

    function setUp() {
        $this->truthy = new Callback(function() {
            return true;
        });
        $this->falsy = new Callback(function() {
            return false;
        });
    }

    public function thisIsASampleCallbackUsedInsideThisTest()
    {
        return true;
    }

    public function testCallbackValidatorShouldReturnTrueIfCallbackReturnsTrue()
    {
        $this->assertTrue($this->truthy->assert('wpoiur'));
    }

    /**
     * @expectedException Respect\Validation\Exceptions\CallbackException
     */
    public function testCallbackValidatorShouldReturnFalseIfCallbackReturnsFalse()
    {
        $this->assertTrue($this->falsy->assert('w poiur'));
    }

    public function testCallbackValidatorShouldAcceptArrayCallbackDefinitions()
    {
        $v = new Callback(array($this, 'thisIsASampleCallbackUsedInsideThisTest'));
        $this->assertTrue($v->assert('test'));
    }

    public function testCallbackValidatorShouldAcceptFunctionNamesAsString()
    {
        $v = new Callback('is_string');
        $this->assertTrue($v->assert('test'));
    }

    /**
     * @expectedException Respect\Validation\Exceptions\ComponentException
     */
    public function testInvalidCallbacksShouldRaiseComponentExceptionUponInstantiation()
    {
        $v = new Callback(new \stdClass);
        $this->assertTrue($v->assert('w poiur'));
    }
}

Make test Callback a little more reusable


<?php

    include_once  $_SERVER["DOCUMENT_ROOT"].'/system/utils/UserHelper.php';

    Use \App\System\Helpers\UserHelper as UserHelper;

    if ( !isset($_POST['username-modal']) && !isset($_POST['password-modal']) ){
        header('Location: /account/bad_login');
        die();
    }

    $user = array(
        'username' => $_POST['username-modal'],
        'password' => $_POST['password-modal']
    );

    if(isset($_POST['remember_me']) && $_POST['remember_me'] == "true"){
      $remember = true;
    }else{
      $remember = false;
    }
    if (UserHelper::login($user, $remember) === true){
        header('Location: /home');
        die();
    }else{
        header('Location: /account/bad_login');
        die();
    }

 ?>

<?php

    include_once  $_SERVER["DOCUMENT_ROOT"].'/system/utils/UserHelper.php';

    Use \App\System\Helpers\UserHelper as UserHelper;

    if ( !isset($_POST['username']) && !isset($_POST['password']) ){
        header('Location: /account/bad_login');
        die();
    }

    $user = array(
        'username' => $_POST['username'],
        'password' => $_POST['password']
    );

    if(isset($_POST['remember_me']) && $_POST['remember_me'] == "true"){
      $remember = true;
    }else{
      $remember = false;
    }
    if (UserHelper::login($user, $remember) === true){
        header('Location: /home');
        die();
    }else{
        header('Location: /account/bad_login');
        die();
    }

 ?>

Fix nombre de los campos

Fix nombre de los campos


<?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\Definition;

use Overblog\GraphQLBundle\Definition\ConfigProcessor\ConfigProcessorInterface;

final class ConfigProcessor
{
    /**
     * @var ConfigProcessorInterface[]
     */
    private array $processors;

    public function __construct(iterable $processors)
    {
        foreach ($processors as $processor) {
            $this->register($processor);
        }
    }

    public function getProcessors(): array
    {
        return $this->processors;
    }

    public function register(ConfigProcessorInterface $configProcessor): void
    {
        $this->processors[] = $configProcessor;
    }

    /**
     * @phpstan-template T of array
     * @phpstan-param T $config
     * @phpstan-return T
     */
    public function process(array $config): array
    {
        foreach ($this->processors as $processor) {
            $config = $processor->process($config);
        }

        return $config;
    }
}

<?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\Definition;

use Overblog\GraphQLBundle\Definition\ConfigProcessor\ConfigProcessorInterface;

final class ConfigProcessor
{
    /**
     * @var ConfigProcessorInterface[]
     */
    private array $processors = [];

    public function __construct(iterable $processors)
    {
        foreach ($processors as $processor) {
            $this->register($processor);
        }
    }

    public function getProcessors(): array
    {
        return $this->processors;
    }

    public function register(ConfigProcessorInterface $configProcessor): void
    {
        $this->processors[] = $configProcessor;
    }

    /**
     * @phpstan-template T of array
     * @phpstan-param T $config
     * @phpstan-return T
     */
    public function process(array $config): array
    {
        foreach ($this->processors as $processor) {
            $config = $processor->process($config);
        }

        return $config;
    }
}

Define default value for `$processors`

Define default value for `$processors`

This makes it possible to initialize a `ConfigProcessor` that has no processors.

Solves this error:

Typed property Overblog\GraphQLBundle\Definition\ConfigProcessor::$processors must not be accessed before initialization.


<?php

namespace EasyCorp\Bundle\EasyAdminBundle\Form\Type\Configurator;

use EasyCorp\Bundle\EasyAdminBundle\Form\Util\LegacyFormHelper;
use Symfony\Component\Form\FormConfigInterface;

/**
 * This configurator is applied to any form field of type 'collection' and is
 * used to allow adding/removing elements from the collection.
 *
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
 */
class CollectionTypeConfigurator implements TypeConfiguratorInterface
{
    /**
     * {@inheritdoc}
     */
    public function configure($name, array $options, array $metadata, FormConfigInterface $parentConfig)
    {
        if (!isset($options['allow_add'])) {
            $options['allow_add'] = true;
        }

        if (!isset($options['allow_delete'])) {
            $options['allow_delete'] = true;
        }

        // The "delete_empty" option exists as of Sf >= 2.5
        if (class_exists('Symfony\\Component\\Form\\FormErrorIterator')) {
            if (!isset($options['delete_empty'])) {
                $options['delete_empty'] = true;
            }
        }

        // allow using short form types as the 'entry_type' of the collection
        if (isset($options['entry_type'])) {
            $options['entry_type'] = LegacyFormHelper::getType($options['entry_type']);
        }

        return $options;
    }

    /**
     * {@inheritdoc}
     */
    public function supports($type, array $options, array $metadata)
    {
        return in_array($type, array('collection', 'Symfony\Component\Form\Extension\Core\Type\CollectionType'), true);
    }
}

<?php

namespace EasyCorp\Bundle\EasyAdminBundle\Form\Type\Configurator;

use EasyCorp\Bundle\EasyAdminBundle\Form\Util\LegacyFormHelper;
use Symfony\Component\Form\FormConfigInterface;

/**
 * This configurator is applied to any form field of type 'collection' and is
 * used to allow adding/removing elements from the collection.
 *
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
 */
class CollectionTypeConfigurator implements TypeConfiguratorInterface
{
    /**
     * {@inheritdoc}
     */
    public function configure($name, array $options, array $metadata, FormConfigInterface $parentConfig)
    {
        if (!isset($options['allow_add'])) {
            $options['allow_add'] = true;
        }

        if (!isset($options['allow_delete'])) {
            $options['allow_delete'] = true;
        }

        if (!isset($options['delete_empty'])) {
            $options['delete_empty'] = true;
        }

        // allow using short form types as the 'entry_type' of the collection
        if (isset($options['entry_type'])) {
            $options['entry_type'] = LegacyFormHelper::getType($options['entry_type']);
        }

        return $options;
    }

    /**
     * {@inheritdoc}
     */
    public function supports($type, array $options, array $metadata)
    {
        return in_array($type, array('collection', 'Symfony\Component\Form\Extension\Core\Type\CollectionType'), true);
    }
}

Remove form delete_empty legacy BC

Remove form delete_empty legacy BC


#!/usr/bin/env php
<?php
chdir(__DIR__);

$returnStatus = null;
passthru('composer install --dev', $returnStatus);
if ($returnStatus !== 0) {
    exit(1);
}

require 'vendor/autoload.php';

$phpcsCLI = new PHP_CodeSniffer_CLI();
$phpcsArguments = array('standard' => array('PSR1'), 'files' => array('src', 'tests', 'build.php'), 'warningSeverity' => 0);
$phpcsViolations = $phpcsCLI->process($phpcsArguments);
if ($phpcsViolations > 0) {
    exit(1);
}

$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml');
$phpunitArguments = array('coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration);
$testRunner = new PHPUnit_TextUI_TestRunner();
$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments);
if (!$result->wasSuccessful()) {
    exit(1);
}

$coverageFactory = new PHP_CodeCoverage_Report_Factory();
$coverageReport = $coverageFactory->create($result->getCodeCoverage());
if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) {
    file_put_contents('php://stderr', "Code coverage was NOT 100%\n");
    exit(1);
}

echo "Code coverage was 100%\n";

#!/usr/bin/env php
<?php
chdir(__DIR__);

$returnStatus = null;
passthru('composer install', $returnStatus);
if ($returnStatus !== 0) {
    exit(1);
}

require 'vendor/autoload.php';

$phpcsCLI = new PHP_CodeSniffer_CLI();
$phpcsArguments = array('standard' => array('PSR1'), 'files' => array('src', 'tests', 'build.php'), 'warningSeverity' => 0);
$phpcsViolations = $phpcsCLI->process($phpcsArguments);
if ($phpcsViolations > 0) {
    exit(1);
}

$phpunitConfiguration = PHPUnit_Util_Configuration::getInstance(__DIR__ . '/phpunit.xml');
$phpunitArguments = array('coverageHtml' => __DIR__ . '/coverage', 'configuration' => $phpunitConfiguration);
$testRunner = new PHPUnit_TextUI_TestRunner();
$result = $testRunner->doRun($phpunitConfiguration->getTestSuiteConfiguration(), $phpunitArguments);
if (!$result->wasSuccessful()) {
    exit(1);
}

$coverageFactory = new PHP_CodeCoverage_Report_Factory();
$coverageReport = $coverageFactory->create($result->getCodeCoverage());
if ($coverageReport->getNumExecutedLines() !== $coverageReport->getNumExecutableLines()) {
    file_put_contents('php://stderr', "Code coverage was NOT 100%\n");
    exit(1);
}

echo "Code coverage was 100%\n";

Remove --dev from composer install.

Remove --dev from composer install.

--dev is the default.


<?php

namespace Becklyn\SearchBundle\Mapping;

/**
 * Marks the property or method as a field of an searchable item
 *
 * @Annotation
 * @Target({"METHOD", "PROPERTY"})
 */
class Field
{
    /**
     * @var int
     */
    public $weight = 1;

    /**
     * @var int|null
     */
    public $fragments = null;

    /**
     * @var string
     */
    public $format = "plain";
}

<?php

namespace Becklyn\SearchBundle\Mapping;

/**
 * Marks the property or method as a field of an searchable item
 *
 * @Annotation
 * @Target({"METHOD", "PROPERTY"})
 */
class Field
{
    /**
     * @var integer
     */
    public $weight = 1;

    /**
     * @var integer|null
     */
    public $fragments = null;

    /**
     * @var string
     */
    public $format = "plain";
}

Use correct types in doctrine annotations


<?php

namespace Xu\Components;

use Xu\Foundation\Foundation;

/**
 * Component class.
 */
abstract class Component {

    /**
     * xu instance.
     *
     * @var \Xu\Foundation\Xu
     */
    protected $xu;

    /**
     * Create a new component instance.
     *
     * @param \Xu\Foundation\Foundation $xu
     */
    public function __construct( Foundation $xu ) {
        $this->xu = $xu;
    }

    /**
     * Bootstrap the component.
     *
     * @codeCoverageIgnore
     */
    public function bootstrap() {
    }

    /**
     * Return the given object. Useful for chaining.
     *
     * @param mixed $obj
     *
     * @return mixed
     */
    protected function with( $obj ) {
        return $obj;
    }

}

<?php

namespace Xu\Components;

use Xu\Contracts\Foundation\Foundation as FoundationContract;

/**
 * Component class.
 */
abstract class Component {

    /**
     * xu instance.
     *
     * @var \Xu\Contracts\Foundation\Foundation
     */
    protected $xu;

    /**
     * Create a new component instance.
     *
     * @param \Xu\Contracts\Foundation\Foundation $xu
     */
    public function __construct( FoundationContract $xu ) {
        $this->xu = $xu;
    }

    /**
     * Bootstrap the component.
     *
     * @codeCoverageIgnore
     */
    public function bootstrap() {
    }

    /**
     * Return the given object. Useful for chaining.
     *
     * @param mixed $obj
     *
     * @return mixed
     */
    protected function with( $obj ) {
        return $obj;
    }

}

Update component class to take foundation contract


<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLaratoolsMetaInformationTable extends Migration
{
    public function up()
    {
        Schema::create('meta_information', function(Blueprint $table)
        {
            $table->increments('id');
            $table->morphs('owner');
            $table->string('key')->index();
            $table->string('value');
            $table->boolean('is_encrypted');
        });
    }

    public function down()
    {
        Schema::drop('meta_information');
    }
}

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLaratoolsMetaInformationTable extends Migration
{
    public function up()
    {
        Schema::create('meta_information', function(Blueprint $table)
        {
            $table->increments('id');
            $table->timestamps();
            $table->morphs('owner');
            $table->string('key')->index();
            $table->string('value');
            $table->boolean('is_encrypted')->default(false);
        });
    }

    public function down()
    {
        Schema::drop('meta_information');
    }
}

Add default to boolean field and add timestamps


<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Client;

class Project extends Model
{
    protected $fillable = [
        'name',
        'description',
        'client_id'
    ];

    /**
     * The client that the project belongs to
     **/
    public function client()
    {
        return $this->belongsTo('App\Client');
    }

    /**
     * Returns the client object that the project belongs to if one exists or
     * a blank client object if none exists.
     *
     * @return \App\Client
     **/
    public function getClient()
    {
        if (is_null($this->client)) {
            return new Client;
        }

        return $this->client;
    }
}

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Client;

class Project extends Model
{
    protected $fillable = [
        'name',
        'description',
        'client_id'
    ];

    /**
     * The client that the project belongs to
     **/
    public function client()
    {
        return $this->belongsTo('App\Client');
    }

    /**
     * Returns the client object that the project belongs to if one exists or
     * a blank client object if none exists.
     *
     * @return \App\Client
     **/
    public function getClient()
    {
        if (is_null($this->client)) {
            return new Client;
        }

        return $this->client;
    }

    /**
     * The sprints that belong to the project
     **/
    public function sprints()
    {
        return $this->hasMany('App\Sprint');
    }

    /**
     * The tasks that belong to the project
     **/
    public function tasks()
    {
        return $this->hasMany('App\Task');
    }
}

Add sprints and tasks relationships to project model


<?php

namespace vektah\parser_combinator\parser;

class CharRangeParser extends CharParser
{
    public function __construct(array $ranges, $min = null, $max = null, $capture = true)
    {
        $chars = '';

        foreach ($ranges as $first => $last) {
            // Use non numeric keys as chars directly.
            if (!is_string($first)) {
                $chars .= $last;
            }

            for ($i = ord($first); $i <= ord($last); $i++) {
                $chars .= chr($i);
            }
        }

        parent::__construct($chars, $min, $max, $capture);
    }
}

<?php

namespace vektah\parser_combinator\parser;

class CharRangeParser extends CharParser
{
    public function __construct(array $ranges, $min = null, $max = null, $capture = true)
    {
        $chars = '';

        foreach ($ranges as $first => $last) {
            // If the value is an array with one value then treat it as a sequence of chars instead of a range.
            if (is_array($last)) {
                $chars .= $last[0];
            } else {
                for ($i = ord($first); $i <= ord($last); $i++) {
                    $chars .= chr($i);
                }
            }
        }

        parent::__construct($chars, $min, $max, $capture);
    }
}

Change inline char syntax to array

Change inline char syntax to array


<?php
namespace Ensepar\Html2pdfBundle\Service;

class Html2pdf
{
    protected $html2pdf;

    public function __construct($mode, $format, $lang,$unicode,$encoding,$margin)
    {
        $this->html2pdf = new \HTML2PDF($mode, $format, $lang,$unicode,$encoding,$margin);
    }

    public function get(){
        return $this->html2pdf;
    }

}

<?php
namespace Ensepar\Html2pdfBundle\Service;

class Html2pdf
{
    protected $html2pdf;

    public $mode;
    public $format;
    public $lang;
    public $unicode;
    public $margin;

    public function __construct($mode, $format, $lang,$unicode,$encoding,$margin)
    {
    	$this->mode = $mode;
    	$this->format = $format;
    	$this->lang = $lang;
    	$this->unicode = $unicode;
    	$this->margin = $margin;
    }

    public function init()
    {
    	$this->html2pdf = new \HTML2PDF($this->mode, $this->format, $this->lang, $this->unicode, $this->encoding, $this->margin);
    }

    public function get()
    {
        return $this->html2pdf;
    }
}

Allow to set specific parameters per instance


<?php
use yii\helpers\Html;

/* @var $model ShortCirquit\LinkoScopeApi\models\Link */
?>

        <?= ($index + 1) ?>:
        [<?= Html::a($model->title, $model->url, ['target' => '_blank',]); ?>]
        (<?= parse_url($model->url, PHP_URL_HOST) ?>)

<?php if (!Yii::$app->user->isGuest) : ?>

        <?= Html::a('', ['up', 'id' => $model->id,], ['title' => 'Up']) ?>
        <?= Html::a('', ['down', 'id' => $model->id,], ['title' => 'Down']) ?>
        <?= '' /* Html::a('', ['delete', 'id' => $model->id,], ['title' => 'Delete']) */ ?>

<?php endif; ?>

    <?=
        "$model->authorName | " .
        date(DATE_RFC2822, strtotime($model->date)) .
        " | $model->votes votes | " .
        Html::a($model->comments == 0 ? "discuss" : "$model->comments comments", ['link/view', 'id' => $model->id])
    ?>

<?php
use yii\helpers\Html;

/* @var $model ShortCirquit\LinkoScopeApi\models\Link */
?>

        <?= ($index + 1) ?>:
        <?= Html::a('', ['up', 'id' => $model->id,], ['title' => 'Up']) ?>
        <?= Html::a('', ['down', 'id' => $model->id,], ['title' => 'Down']) ?>
        [<?= Html::a($model->title, $model->url, ['target' => '_blank',]); ?>]
        (<?= parse_url($model->url, PHP_URL_HOST) ?>)

<?php if (!Yii::$app->user->isGuest) : ?>

        <?= '' /* Html::a('', ['delete', 'id' => $model->id,], ['title' => 'Delete']) */ ?>

<?php endif; ?>

    <?=
        "$model->authorName | " .
        date(DATE_RFC2822, strtotime($model->date)) .
        " | $model->votes votes | " .
        Html::a($model->comments == 0 ? "discuss" : "$model->comments comments", ['link/view', 'id' => $model->id])
    ?>

Move up/down votes from the far right to just before the title

Now that it's only two icons (and will be only 1 soon), it makes more sense to put it here.