Skip to content

Commit

Permalink
Merge pull request #1 from codeigniter4/develop
Browse files Browse the repository at this point in the history
Update develop branch
  • Loading branch information
atishhamte authored Mar 28, 2019
2 parents 57b0bc4 + b108541 commit 3abe0e2
Show file tree
Hide file tree
Showing 202 changed files with 1,806 additions and 617 deletions.
38 changes: 20 additions & 18 deletions app/Config/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@
* Events::on('create', [$myInstance, 'myMethod']);
*/

/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (ENVIRONMENT !== 'production')
{
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Events::on('pre_system', function () {
while (\ob_get_level() > 0)
{
\ob_end_flush();
}

Events::on('pre_system', function () {
if (ENVIRONMENT !== 'testing')
{
\ob_start(function ($buffer) {
return $buffer;
});
}
Services::toolbar()->respond();
\ob_start(function ($buffer) {
return $buffer;
});
}

/*
* --------------------------------------------------------------------
* Debug Toolbar Listeners.
* --------------------------------------------------------------------
* If you delete, they will no longer be collected.
*/
if (ENVIRONMENT !== 'production')
{
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
Services::toolbar()->respond();
}
});
46 changes: 46 additions & 0 deletions app/Controllers/BaseController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php namespace App\Controllers;

/**
* Class BaseController
*
* BaseController provides a convenient place for loading components
* and performing functions that are needed by all your controllers.
* Extend this class in any new controllers:
* class Home extends BaseController
*
* For security be sure to declare any new methods as protected or private.
*
* @package CodeIgniter
*/

use CodeIgniter\Controller;

class BaseController extends Controller
{

/**
* An array of helpers to be loaded automatically upon
* class instantiation. These helpers will be available
* to all other controllers that extend BaseController.
*
* @var array
*/
protected $helpers = [ ];

/**
* Constructor.
*
*/
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
{
// Do Not Edit This Line
parent::initController($request, $response, $logger);

//--------------------------------------------------------------------
// Preload any models, libraries, etc, here.
//--------------------------------------------------------------------
// E.g.:
// $this->session = \Config\Services::session();

}
}
2 changes: 1 addition & 1 deletion app/Controllers/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use CodeIgniter\Controller;

class Home extends Controller
class Home extends BaseController
{
public function index()
{
Expand Down
76 changes: 76 additions & 0 deletions contributing/styleguide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,82 @@ Control Structures
if ( $foo ) $bar += $baz;
else $baz = 'bar';

Docblocks
=========

We use phpDocumentor (phpdoc) to generate the API docs, for all of the source
code inside the `system` folder.

It wants to see a file summary docblock at the top of a PHP file,
before any PHP statements, and then a docblock before each documentable
component, namely any class/interface/trait, and all public and protected
methods/functions/variables. The docblock for a method or function
is expected to describe the parameters, return value, and any exceptions
thrown.

Deviations from the above are considered errors by phpdoc.

An example::

<?php

/**
* CodeIgniter
*
* An open source application development framework for PHP
*
...
*
* @package CodeIgniter
* @author CodeIgniter Dev Team
* @copyright 2014-2019 British Columbia Institute of Technology (https://bcit.ca/)
* @license https://opensource.org/licenses/MIT MIT License
* @link https://codeigniter.com
* @since Version 3.0.0
* @filesource
*/
namespace CodeIgniter\Fruit;
use CodeIgniter\Config\BaseConfig;

/**
* Base class for entities in the CodeIgniter\Fruit module.
*
* @property $group
* @property $name
* @property $description
*
* @package CodeIgniter\Fruit
*/
abstract class BaseFruit
{

/**
* The group a fruit belongs to.
*
* @var string
*/
protected $group;

/**
* Fruit constructor.
*
* @param BaseConfig $config
*/
public function __construct(BaseConfig $Config)
{
$this->group = 'Unknown';
}

//--------------------------------------------------------------------

/**
* Model a fruit ripening over time.
*
* @param array $params
*/
abstract public function ripen(array $params);
}

Other
=====

Expand Down
10 changes: 5 additions & 5 deletions phpdoc.dist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
<target>api/build/</target>
</transformer>
<files>
<directory>./system</directory>
<ignore>./vendor/*</ignore>
<ignore>./tests/*</ignore>
<directory>system</directory>
<ignore>vendor/*</ignore>
<ignore>tests/*</ignore>
<ignore>Kint/*</ignore>
</files>

<logging>
<level>warn</level>
<level>err</level>
<paths>
<default>api/log/{DATE}.log</default>
<errors>api/{DATE}.errors.log</errors>
</paths>
</logging>

<transformations>
<template name="responsive" />
<template name="responsive-twig" />
</transformations>
</phpdoc>
4 changes: 3 additions & 1 deletion system/API/ResponseTrait.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace CodeIgniter\API;
<?php

/**
* CodeIgniter
Expand Down Expand Up @@ -36,6 +36,8 @@
* @filesource
*/

namespace CodeIgniter\API;

use Config\Format;
use CodeIgniter\HTTP\Response;

Expand Down
6 changes: 3 additions & 3 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php namespace CodeIgniter\Autoloader;

use Composer\Autoload\ClassLoader;
<?php

/**
* CodeIgniter
Expand Down Expand Up @@ -38,6 +36,8 @@
* @filesource
*/

namespace CodeIgniter\Autoloader;

/**
* CodeIgniter Autoloader
*
Expand Down
46 changes: 45 additions & 1 deletion system/Autoloader/FileLocator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php namespace CodeIgniter\Autoloader;
<?php

/**
* CodeIgniter
Expand Down Expand Up @@ -36,6 +36,8 @@
* @filesource
*/

namespace CodeIgniter\Autoloader;

/**
* Class FileLocator
*
Expand Down Expand Up @@ -376,6 +378,48 @@ public function listFiles(string $path): array

//--------------------------------------------------------------------

/**
* Scans the provided namespace, returning a list of all files
* that are contained within the subpath specified by $path.
*
* @param string $prefix
* @param string $path
*
* @return array
*/
public function listNamespaceFiles(string $prefix, string $path): array
{
if (empty($path) || empty($prefix))
{
return [];
}

$files = [];
helper('filesystem');

// autoloader->getNamespace($prefix) returns an array of paths for that namespace
foreach ($this->autoloader->getNamespace($prefix) as $namespacePath)
{
$fullPath = realpath($namespacePath . $path);

if (! is_dir($fullPath))
{
continue;
}

$tempFiles = get_filenames($fullPath, true);

if (! empty($tempFiles))
{
$files = array_merge($files, $tempFiles);
}
}

return $files;
}

//--------------------------------------------------------------------

/**
* Checks the application folder to see if the file can be found.
* Only for use with filenames that DO NOT include namespacing.
Expand Down
13 changes: 11 additions & 2 deletions system/CLI/BaseCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php namespace CodeIgniter\CLI;

<?php
/**
* CodeIgniter
*
Expand Down Expand Up @@ -36,6 +35,8 @@
* @filesource
*/

namespace CodeIgniter\CLI;

use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -94,6 +95,8 @@ abstract class BaseCommand
protected $arguments = [];

/**
* The Logger to use for a command
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
Expand Down Expand Up @@ -122,6 +125,12 @@ public function __construct(LoggerInterface $logger, CommandRunner $commands)

//--------------------------------------------------------------------

/**
* Actually execute a command.
* This has to be over-ridden in any concrete implementation.
*
* @param array $params
*/
abstract public function run(array $params);

//--------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 3abe0e2

Please sign in to comment.