This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function foo(int $bar) : int { | |
return $bar * 2; | |
} | |
var_dump( foo(2.5) ); // int(4) and triggers E_NOTICE - great! | |
// but without E_NOTICE it as bad as: | |
var_dump( foo((int) 2.5) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
var_dump(Test::$table); // dumps empty array() | |
class Test | |
{ | |
static $table = array( | |
'_0' => 1, '_1' => 1, '_2' => 1, '_3' => 1, '_4' => 1, '_5' => 1, '_6' => 1, '_7' => 1, '_8' => 1, '_9' => 1, | |
'_10' => 1, '_11' => 1, '_12' => 1, '_13' => 1, '_14' => 1, '_15' => 1, '_16' => 1, '_17' => 1, '_18' => 1, '_19' => 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function verifyIC($ic) | |
{ | |
// be liberal in what you receive | |
$ic = preg_replace('#\s+#', '', $ic); | |
// má požadovaný tvar? | |
if (!preg_match('#^\d{8}$#', $ic)) { | |
return FALSE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Presenters; | |
use Nette; | |
use App\Model; | |
class HomepagePresenter extends BasePresenter | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
... | |
listen 443 ssl; | |
listen 80; | |
if ($server_port = 80) { | |
set $xp A; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<div style="width: 300px; height: 300px; background: blue"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
require '/nette.phar'; | |
class TypeHints | |
{ | |
public $php71 = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// transfer of a persistent parameter between two presenters without an inheritance | |
// (requires nette/application 3.0.0) | |
trait LangParameter | |
{ | |
/** @persistent */ | |
public $lang; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// composing presenters without inheritance | |
// (requires nette/application 2.4.11) | |
trait RequireLoggedUser | |
{ | |
public function injectRequireLoggedUser() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the Nette Framework (https://nette.org) | |
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | |
*/ | |
namespace Nette; | |
use Nette\Utils\ObjectHelpers; |