') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); chore: update rector.php by kenjis · Pull Request #560 · codeigniter4/shield · GitHub
Skip to content

chore: update rector.php - #560

Merged
kenjis merged 11 commits into
codeigniter4:developfrom
kenjis:fix-rector-config
Dec 17, 2022
Merged

chore: update rector.php#560
kenjis merged 11 commits into
codeigniter4:developfrom
kenjis:fix-rector-config

Conversation

@kenjis

@kenjiskenjis commented Dec 14, 2022

Copy link
Copy Markdown
Member
  • add declare(strict_types=1) in rector.php
  • update rector version to ^0.15.1
  • add rector rules
  • remove deprecated TypedPropertyRector
  • refactor test code by rector
  • update .php-cs-fixer.dist.php
PHP Fatal error: Uncaught _PHPStan_9a6ded56a\Nette\Schema\ValidationException: Unexpected item 'parameters › deprecationRulesInstalled'. in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75
Fatal error: Uncaught _PHPStan_9a6ded56a\Nette\Schema\ValidationException: Unexpected item 'parameters › deprecationRulesInstalled'. in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75
Stack trace:
Stack trace:
#0 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_9a6ded56a\Nette\Schema\Processor->throwsErrors()
#0 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_9a6ded56a\Nette\Schema\Processor->throwsErrors()
#1 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ParametersSchemaExtension.php(43): _PHPStan_9a6ded56a\Nette\Schema\Processor->process()
#1 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ParametersSchemaExtension.php(43): _PHPStan_9a6ded56a\Nette\Schema\Processor->process()
#2 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(182): PHPStan\DependencyInjection\ParametersSchemaExtension->loadConfiguration()
#2 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(182): PHPStan\DependencyInjection\ParametersSchemaExtension->loadConfiguration()
#3 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(158): _PHPStan_9 in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75
#3 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(158): _PHPStan_9 in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75
Error: Process completed with exit code 255.

https://github.com/codeigniter4/shield/actions/runs/3692642168/jobs/6251736949

@kenjiskenjis changed the title chore: fix rectore.phpchore: fix rector.phpDec 14, 2022
@samsonasik

Copy link
Copy Markdown
Member

You can pin to phpstan 1.9.2 or use rector dev-main that already include phpstan 1.9.3

@kenjis

Copy link
Copy Markdown
MemberAuthor

@samsonasik Do you know why this error happens?

PHP Fatal error: Uncaught _PHPStan_9a6ded56a\Nette\Schema\ValidationException: Unexpected item 'parameters › deprecationRulesInstalled'. in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75
Fatal error: Uncaught _PHPStan_9a6ded56a\Nette\Schema\ValidationException: Unexpected item 'parameters › deprecationRulesInstalled'. in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php:75
Stack trace:
#0 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_9a6ded56a\Nette\Schema\Processor->throwsErrors()
#1 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ParametersSchemaExtension.php(43): _PHPStan_9a6ded56a\Nette\Schema\Processor->process()
#2 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(182): PHPStan\DependencyInjection\ParametersSchemaExtension->loadConfiguration()
#3 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(158): _PHPStan_9 in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75
Stack trace:
#0 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php(38): _PHPStan_9a6ded56a\Nette\Schema\Processor->throwsErrors()
#1 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ParametersSchemaExtension.php(43): _PHPStan_9a6ded56a\Nette\Schema\Processor->process()
#2 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(182): PHPStan\DependencyInjection\ParametersSchemaExtension->loadConfiguration()
#3 phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php(158): _PHPStan_9 in phar:///home/runner/.composer/vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/schema/src/Schema/Processor.php on line 75
Error: Process completed with exit code 255.

https://github.com/codeigniter4/shield/actions/runs/3692658459/jobs/6251768963

@samsonasik

Copy link
Copy Markdown
Member

You can pin to phpstan 1.9.2 or use rector dev-main that already include phpstan 1.9.3

@kenjis

Copy link
Copy Markdown
MemberAuthor

@samsonasik Thanks! No errors with dev-main .

@kenjiskenjis mentioned this pull request Dec 14, 2022
@kenjis

Copy link
Copy Markdown
MemberAuthor

@samsonasik
I don't feel comfortable changing the GitHub workflow to dev-main, so I'll leave it as is for a while.

Will this be fixed in the next release?

@samsonasik

Copy link
Copy Markdown
Member

Yes, wait for next release seems ok 👍 , the error usually happen when phpstan add new parameters config

@samsonasik

Copy link
Copy Markdown
Member

@kenjis Rector 0.15.1 released, I restarted the build.

@samsonasik

Copy link
Copy Markdown
Member

@kenjis the workflow seems still using rector 0.13

Run composer global require --dev rector/rector:^0.13.3
Changed current directory to /home/runner/.composer
./composer.json has been updated
Running composer update rector/rector
Loading composer repositories with package information
Updating dependencies
Lock file operations: 2 installs, 0 updates, 0 removals
- Locking phpstan/phpstan (1.9.3)
- Locking rector/rector (0.13.10)

composer global require --dev rector/rector:^0.13.3

Please update to ^0.15.1

@kenjiskenjis changed the title chore: fix rector.phpchore: update rector.phpDec 15, 2022
@kenjiskenjis added the github_actions Pull requests that update GitHub Actions code label Dec 15, 2022
Comment threadrector.php Outdated
$rectorConfig
->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [
// Set to false if you use in libraries, or it does create breaking changes.
TypedPropertyFromAssignsRector::INLINE_PUBLIC => false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It false by default, no need to define in config for false value

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes from a template file in devkit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For devkit, that can be on purpose so user know when to enable it, I think it can be removed in here

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the instruction in the devkit template.

If we need to remove the default value, please update the devkit comment.
Otherwise, the code will revert again when I or someone else copy the devkit template to update in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I created PR codeigniter4/devkit#61 for it.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the config line.

@kenjis

Copy link
Copy Markdown
MemberAuthor

Why did the coverage rate drop to 69.743%?

It is 94.95% in my local environment.

Code Coverage Report: 2022-12-14 20:01:58 Summary: Classes: 45.83% (22/48) Methods: 79.86% (222/278) Lines: 94.95% (2484/2616)

@MGatner

Copy link
Copy Markdown
Member

Why did the coverage rate drop to 69.743%?

No clue!

Comment threadtests/Language/AbstractTranslationTestCase.php
It is included in LevelSetList::UP_TO_PHP_74.
@kenjis
kenjis merged commit 22ccaf4 into codeigniter4:developDec 17, 2022
@kenjis
kenjis deleted the fix-rector-config branch December 17, 2022 02:43
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actionsPull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kenjis@samsonasik@MGatner