Skip to content

Commit 018605a

Browse files
authored
Merge pull request #1124 from phalcon/3.2.x
3.2.7
2 parents b62a35e + 4628363 commit 018605a

33 files changed

+163
-62
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ env:
5252

5353
before_install:
5454
- export PHP_VERSION=$(php-config --version)
55+
- export PHP_MAJOR="$(echo $TRAVIS_PHP_VERSION | cut -d '.' -f 1)"
5556
- export PHP_EXTENSION_DIR=$(php-config --extension-dir)
5657
- phpenv config-rm xdebug.ini || true
5758
- if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com $GH_TOKEN; fi;
@@ -67,12 +68,14 @@ install:
6768

6869
before_script:
6970
- ln -s $PWD/phalcon.php ~/bin/phalcon
71+
- '[[ "$PHP_MAJOR" == "5" ]] || composer require --dev phpstan/phpstan'
7072

7173
script:
7274
- vendor/bin/codecept build
7375
- vendor/bin/codecept run unit -v
7476
- vendor/bin/codecept run functional -v
7577
- vendor/bin/codecept run console -v
78+
- '[[ "$PHP_MAJOR" == "5" ]] || vendor/bin/phpstan analyse -l 1 -c phpstan.neon scripts -vvv'
7679

7780
notifications:
7881
email:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ This command should display something similar to:
114114
```sh
115115
$ phalcon --help
116116

117-
Phalcon DevTools (3.2.0)
117+
Phalcon DevTools (3.2.7)
118118

119119
Help:
120120
Lists the commands available in Phalcon devtools

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
bootstrap: %rootDir%/../../../tests/phpstan.php
3+
4+
excludes_analyse:
5+
- %rootDir%/../../../scripts/Phalcon/Generator/*

scripts/Phalcon/Access/Policy/Ip.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/**
2828
* \Phalcon\Access\Policy\Ip
2929
*
30+
* @property \Phalcon\Http\Request|\Phalcon\Http\RequestInterface $request
3031
* @package Phalcon\Access\Policy
3132
*/
3233
class Ip extends Injectable implements PolicyInterface

scripts/Phalcon/Bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
/**
2929
* \Phalcon\Web\Tools\Library\Bootstrap
3030
*
31+
* @method mixed getShared($name, $parameters=null)
32+
* @method mixed get($name, $parameters=null)
3133
* @package Phalcon\Web\Tools\Library
3234
*/
3335
class Bootstrap

scripts/Phalcon/Builder/Model.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Phalcon\Db\ReferenceInterface;
3030
use Phalcon\Validation\Validator\Email as EmailValidator;
3131
use Phalcon\Text;
32+
use \Phalcon\Db\Adapter\Pdo;
3233

3334

3435
/**
@@ -241,15 +242,9 @@ public function build()
241242
if (!$db->tableExists($table, $schema)) {
242243
throw new BuilderException(sprintf('Table "%s" does not exist.', $table));
243244
}
244-
$fields = $db->describeColumns($table, $schema);
245245

246-
if (!$this->options->contains('referenceList')) {
247-
foreach ($db->listTables($schema) as $name) {
248-
$referenceList[$name] = $db->describeReferences($name, $schema);;
249-
}
250-
} else {
251-
$referenceList = $this->options->get('referenceList');
252-
}
246+
$fields = $db->describeColumns($table, $schema);
247+
$referenceList = $this->getReferenceList($schema, $db);
253248

254249
foreach ($referenceList as $tableName => $references) {
255250
foreach ($references as $reference) {
@@ -536,4 +531,25 @@ protected function getEntityClassName(ReferenceInterface $reference, $namespace)
536531

537532
return $fqcn;
538533
}
534+
535+
/**
536+
* Get reference list from option
537+
*
538+
* @param string $schema
539+
* @param Pdo $db
540+
* @return array
541+
*/
542+
protected function getReferenceList($schema, Pdo $db)
543+
{
544+
if ($this->options->contains('referenceList')) {
545+
return $this->options->get('referenceList');
546+
}
547+
548+
$referenceList = [];
549+
foreach ($db->listTables($schema) as $name) {
550+
$referenceList[$name] = $db->describeReferences($name, $schema);;
551+
}
552+
553+
return $referenceList;
554+
}
539555
}

scripts/Phalcon/Commands/Builtin/Model.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
use Phalcon\Script\Color;
2727
use Phalcon\Commands\Command;
2828
use Phalcon\Builder\Model as ModelBuilder;
29+
use Phalcon\Config;
30+
use Phalcon\Config\Adapter\Ini as ConfigIni;
2931

3032
/**
3133
* Model Command

scripts/Phalcon/Commands/DotPhalconMissingException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function __construct (string $message = self::DEFAULT_MESSAGE , $code = 0
3838
{
3939
$this->message = $message;
4040
$this->code = $code;
41+
42+
parent::__construct();
4143
}
4244

4345
public function scanPathMessage()

scripts/Phalcon/Console/OptionParserTrait.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
namespace Phalcon\Console;
2121

22+
use Phalcon\Version\IncrementalItem as IncrementalVersion;
23+
use Phalcon\Version\ItemCollection as VersionCollection;
24+
use Phalcon\Mvc\Model\Migration as ModelMigration;
25+
use InvalidArgumentException;
26+
2227
/**
2328
* \Phalcon\Utils\OptionParserTrait
2429
*
@@ -46,4 +51,45 @@ public function getPrefixOption($prefix, $prefixEnd = '*')
4651

4752
return substr($prefix, 0, -1);
4853
}
54+
55+
/**
56+
* Get version name to generate migration
57+
*
58+
* @return IncrementalVersion
59+
*/
60+
public function getVersionNameGeneratingMigration()
61+
{
62+
if (empty($this->options)) {
63+
throw new InvalidArgumentException('Options were not defined yet');
64+
}
65+
66+
// Use timestamped version if description is provided
67+
if ($this->options['descr']) {
68+
$this->options['version'] = (string)(int)(microtime(true) * pow(10, 6));
69+
VersionCollection::setType(VersionCollection::TYPE_TIMESTAMPED);
70+
$versionItem = VersionCollection::createItem($this->options['version'] . '_' . $this->options['descr']);
71+
72+
// Elsewhere use old-style incremental versioning
73+
// The version is specified
74+
} elseif ($this->options['version']) {
75+
VersionCollection::setType(VersionCollection::TYPE_INCREMENTAL);
76+
$versionItem = VersionCollection::createItem($this->options['version']);
77+
78+
// The version is guessed automatically
79+
} else {
80+
VersionCollection::setType(VersionCollection::TYPE_INCREMENTAL);
81+
$versionItems = ModelMigration::scanForVersions($this->options['migrationsDir']);
82+
83+
if (!isset($versionItems[0])) {
84+
$versionItem = VersionCollection::createItem('1.0.0');
85+
86+
} else {
87+
/** @var IncrementalVersion $versionItem */
88+
$versionItem = VersionCollection::maximum($versionItems);
89+
$versionItem = $versionItem->addMinor(1);
90+
}
91+
}
92+
93+
return $versionItem;
94+
}
4995
}

scripts/Phalcon/Devtools/Version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ class Version extends PhVersion
3939
*/
4040
protected static function _getVersion()
4141
{
42-
return [3, 2, 5, 4, 0];
42+
return [3, 2, 7, 4, 0];
4343
}
4444
}

0 commit comments

Comments
 (0)