Cleanup PHP Snippets

This commit is contained in:
Daniel Siepmann 2023-11-30 08:20:59 +01:00
parent 8244983c2d
commit dc8e02c1df
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -46,19 +46,6 @@ snippet compilerpass
}
});
snippet t3sqlde
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)
->getConnectionByName('Default')
->getConfiguration()
->setSQLLogger(new class implements \Doctrine\DBAL\Logging\SQLLogger {
public function startQuery($sql, ?array $params = null, ?array $types = null) {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($sql, 'sql', 8, false);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($params, 'params', 8, false);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($types, 'types', 8, false);
}
public function stopQuery() { }
});
snippet declare_strict
declare(strict_types=1);
@ -67,20 +54,9 @@ snippet t3log
->getLogger('das')
->debug('DAS', [${1}]);
snippet t3mem
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')
->getLogger('das')
->debug('memory stats ${1}', [
'memory_get_usage' => \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(memory_get_usage()),
'memory_get_peak_usage' => \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize(memory_get_peak_usage()),
]);
snippet throw
throw new \Exception('${1:message}', `system('date +%s')`);
snippet t3devlog
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('${1:message}', '${2:ds}', ${3:0}, ${4:[]});
snippet construct
public function __construct(
${0}
@ -93,53 +69,6 @@ snippet invoke
) {
}
snippet sfile
<?php
declare(strict_types=1);
namespace `expand('%:h:gs?src/??:gs?/?\\\?')`;
/**
* Class `expand('%:t:s?.php??')`
* @package `expand('%:h:gs?src/??:gs?/?\\\?')`
*/
class `expand('%:t:s?.php??')`
{
${0}
}
snippet lfile
<?php
namespace `expand('%:h:gs?/?\\?:s?.?\u&?')`;
/**
*
*/
class ${1:`expand('%:t:s?.php??')`}
{
${2}
}
snippet lseedfile
<?php
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\\`expand('%:t:r:s?Seeder??')`;
final class `expand('%:t:r')` extends Seeder
{
public function run(Factory $factory)
{
$factory->create(`expand('%:t:r:s?Seeder??')`::class, 50)->each(function ($`expand('%:t:r:s?Seeder??:s?.?\l&?')`) use ($factory) {
// $`expand('%:t:r:s?Seeder??:s?.?\l&?')`->posts()->save($factory->make(\App\Post::class));
});
}
}
snippet t3file
<?php
@ -211,56 +140,6 @@ snippet file
${4}
}
snippet stestfile
<?php
declare(strict_types=1);
namespace `expand('%:h:gs?src/??:gs?/?\\\?')`;
use PHPUnit\Framework\TestCase;
/**
* Tests `expand('%:t:s?.php??')`
* @package `expand('%:h:gs?src/??:gs?/?\\\?')`
*/
final class `expand('%:t:s?.php??')` extends TestCase
{
/**
* @test
*/
public function ${0}()
{
}
}
snippet ltestfile
<?php
namespace `expand('%:h:gs?/?\\?:s?.?\u&?')`;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
final class ${1:`expand('%:t:s?.php??')`} extends TestCase
{
use RefreshDatabase;
/**
* @var
*/
protected $subject;
public function setUp()
{
parent::setUp();
$this->subject = $this->app->make(::class);
}
${4}
}
snippet testfile
<?php
@ -421,6 +300,13 @@ snippet closure
})();
snippet test
#[Test]
public function ${1:name}(): void
{
${0}
}
snippet testlegacy
/**
* @test
*/
@ -429,8 +315,5 @@ snippet test
${0}
}
snippet dump
var_dump(${1});${2}
snippet die
throw new \Exception('debugging end: ' . var_export(${1}, true));${2}