Skip to content

Commit

Permalink
Merge pull request #52 from stekycz/improvements
Browse files Browse the repository at this point in the history
Move to newer version and prepare version 2.0.0
  • Loading branch information
stekycz authored Feb 1, 2017
2 parents c7b5cff + 0dd7953 commit 3fbe3cd
Show file tree
Hide file tree
Showing 39 changed files with 934 additions and 1,376 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpstan.neon export-ignore
tests export-ignore
21 changes: 4 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
language: php

php:
- 5.3.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1

env:
- PHP_BIN=php
- PHP_BIN=php-cgi

matrix:
allow_failures:
- php: hhvm

exclude:
- php: hhvm
env: PHP_BIN=php-cgi

before_install:
- if [[ "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then cat tests/php.ini-unix >> /etc/hhvm/php.ini; fi
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-add tests/php.ini-unix; fi
- phpenv config-add tests/php.ini-unix

install:
- if [[ "$TRAVIS_PHP_VERSION" == "5.3.3" ]]; then composer config -g disable-tls true; composer config -g secure-http false; fi
- composer self-update
- composer install --prefer-source --no-interaction --optimize-autoloader
- composer install --no-interaction --optimize-autoloader

before_script:
- ./vendor/bin/parallel-lint -e php,phpt --exclude vendor .
- ./vendor/bin/phpstan analyze --no-progress -l 5 -c ./phpstan.neon ./

script:
- ./vendor/bin/tester -s -p $PHP_BIN -j 32 -c ./tests/php.ini-unix ./tests/CronnerTests
Expand Down
63 changes: 0 additions & 63 deletions Cronner/exceptions.php

This file was deleted.

32 changes: 1 addition & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Simple tool which helps with maintenance of cron tasks.

It requires **PHP >= 5.3.3** and **Nette Framework >= 2.0.0**.
It requires **PHP >= 7.0.0** and **Nette Framework >= 2.4.0**.

## Usage

Expand Down Expand Up @@ -169,33 +169,3 @@ start from any reason.
* @cronner-time 11:00, 23:30 - 05:00
*/
```

## Author

My name is Martin Štekl. Feel free to contact me on [e-mail](mailto:[email protected])
or follow me on [Twitter](https://twitter.com/stekycz).

## License

Copyright (c) 2013 Martin Štekl <[email protected]>

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.
30 changes: 14 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,30 @@
"source": "https://github.com/stekycz/Cronner"
},
"require": {
"php": ">=5.3.3",
"tracy/tracy": "@dev",
"nette/di": "@dev",
"nette/bootstrap": "@dev",
"nette/utils": "@dev",
"nette/reflection": "@dev",
"nette/safe-stream": "@dev"
"php": ">=7.0.0",
"tracy/tracy": "^2.4",
"nette/di": "^2.4",
"nette/bootstrap": "^2.4",
"nette/utils": "^2.4",
"nette/reflection": "^2.4",
"nette/safe-stream": "^2.3"
},
"require-dev": {
"nette/tester": "~1.3",
"janmarek/mockista": "~1.0",
"jakub-onderka/php-parallel-lint": "~0.8"
"nette/tester": "^1.7",
"jakub-onderka/php-parallel-lint": "^0.9",
"mockery/mockery": "^0.9",
"phpstan/phpstan": "^0.6"
},
"suggest": {
"kdyby/events": "Events for Nette Framework",
"kdyby/console": "Symfony Console integration for Kdyby components"
},
"autoload": {
"classmap": ["Cronner/"]
"psr-4": {
"stekycz\\": "src"
}
},
"autoload-dev": {
"classmap": ["tests/CronnerTests/objects"]
},
"extra": {
"branch-alias": {
"dev-master": "v1.1.x-dev"
}
}
}
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 Martin Štekl <[email protected]>
Copyright (c) 2017 Martin Štekl <[email protected]>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
11 changes: 11 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
parameters:
projectDir: %rootDir%/../../..
autoload_files:
- %projectDir%/vendor/autoload.php
excludes_analyse:
- %projectDir%/tests/
- %projectDir%/vendor/
ignoreErrors:
- '#.*Cronner::onTaskBegin\(\).*#'
- '#.*Cronner::onTaskFinished\(\).*#'
- '#.*Cronner::onTaskError\(\).*#'
14 changes: 9 additions & 5 deletions Cronner/Bar/Tasks.php → src/Cronner/Bar/Tasks.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace stekycz\Cronner\Bar;

use Nette\Object;
Expand All @@ -10,7 +12,7 @@ class Tasks extends Object implements IBarPanel
{

/**
* @var \stekycz\Cronner\Cronner
* @var Cronner
*/
protected $cronner;

Expand All @@ -19,26 +21,28 @@ public function __construct(Cronner $cronner)
$this->cronner = $cronner;
}

public function getPanel()
public function getPanel() : string
{
$tasks = array();
$tasks = [];
foreach ($this->cronner->getTasks() as $task) {
if (!array_key_exists($task->getObjectName(), $tasks)) {
$tasks[$task->getObjectName()] = array();
$tasks[$task->getObjectName()] = [];
}

$tasks[$task->getObjectName()][] = $task;
}
ob_start();
require __DIR__ . '/templates/panel.phtml';

return ob_get_clean();
}

public function getTab()
public function getTab() : string
{
ob_start();
$count = $this->cronner->countTasks();
require __DIR__ . '/templates/tab.phtml';

return ob_get_clean();
}

Expand Down
File renamed without changes.
File renamed without changes.
44 changes: 8 additions & 36 deletions Cronner/CriticalSection.php → src/Cronner/CriticalSection.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<?php

declare(strict_types=1);

namespace stekycz\Cronner;

use Nette\Object;
use Nette\Utils\FileSystem;



/**
* @author Martin Štekl <[email protected]>
*/
class CriticalSection extends Object
{

Expand All @@ -23,27 +20,17 @@ class CriticalSection extends Object
*/
private $lockFilesDir;



/**
* @param string $lockFilesDir
*/
public function __construct($lockFilesDir)
public function __construct(string $lockFilesDir)
{
$lockFilesDir = rtrim($lockFilesDir, DIRECTORY_SEPARATOR);
FileSystem::createDir($lockFilesDir);
$this->lockFilesDir = $lockFilesDir;
}



/**
* Enters critical section.
*
* @param string $label
* @return bool
*/
public function enter($label)
public function enter(string $label) : bool
{
if ($this->isEntered($label)) {
return FALSE;
Expand All @@ -57,22 +44,18 @@ public function enter($label)
$locked = flock($handle, LOCK_EX | LOCK_NB);
if ($locked === FALSE) {
fclose($handle);

return FALSE;
}
$this->locks[$label] = $handle;

return TRUE;
}



/**
* Leaves critical section.
*
* @param string $label
* @return bool
*/
public function leave($label)
public function leave(string $label) : bool
{
if (!$this->isEntered($label)) {
return FALSE;
Expand All @@ -89,26 +72,15 @@ public function leave($label)
return TRUE;
}



/**
* Returns TRUE if critical section is entered.
*
* @param string $label
* @return bool
*/
public function isEntered($label)
public function isEntered(string $label) : bool
{
return array_key_exists($label, $this->locks) && $this->locks[$label] !== NULL;
}



/**
* @param string $label
* @return string
*/
private function getFilePath($label)
private function getFilePath(string $label) : string
{
return $this->lockFilesDir . "/" . sha1($label);
}
Expand Down
Loading

0 comments on commit 3fbe3cd

Please sign in to comment.